|
you got a bit closer.
check your code again with my list of requirements.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
PictureBox pic = new PictureBox();<br />
pic.Image = (Bitmap)e.Data.GetData(typeof(Bitmap));<br />
pic.Width = 32;<br />
pic.Height = 32;<br />
pic.Top = Cursor.Position.X;<br />
pic.Left = Cursor.Position.Y;<br />
this.panGameDesign.Controls.Add(pic);
Even closer, this is my own code, it works but it creates the picture box in a random position in the panel.
|
|
|
|
|
From the documentation:
Cursor.Position gets...a Point that represents the cursor's position in screen coordinates
Control.Top ... gets or sets the distance, in pixels, between the top edge of the control and the top edge of its container's client area
So I don't think the position is random, but I am sure it is not what you want either.
If used correctly, Control.PointToClient() should help you.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I've replaced the old placement code with:
pic.Location = this.PointToClient( new Point (e.X, e.Y) );
It creates it nearer to the mouse but not at the exact X and Y of the mouse...
I solved it, it was panGameDesign.PointToClient(); not this.PointToClient();
Thanks for the help
modified on Sunday, January 27, 2008 3:32:20 PM
|
|
|
|
|
I haven't done DragDrop myself lately, and you are not providing much detail on the deviation,
but maybe you could/should use DragEventArgs.X/Y instead of Cursor.Position
Try to find out how the deviation relates to other stuff, such as:
- where exactly you click the source image,
- peculiarities of the PictureBox; what BorderStyle and SizeMode do you use on both?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: I haven't done DragDrop myself lately
Same here. Did some a while back, about 3-4 months ago.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
the "If used correctly" bit was relevant then.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi,
I have a problem I never encountered...and sites across the net didn't help much.
I have a class exposing a public method which clears a queue object. On a form using this object, when calling this method ..is causing an exception : Method not found.
What is exactly this exception!? My method is there and was created normally.
What possible solutions are there?
I'm using C# with .net 2.0 and I have .net 1.1 installed previous to 2.0.
Regards
Kev.
|
|
|
|
|
Hi
The Exception message should tell you the name of the missing method.
The exception can have many causes like:
- there's no method with that name at all
- there's no method that takes parameters of this type
- there's no method with that return time
it can happen if you change a dll and copy the new version of an exe that uses it, but not the new version of the dll...
or the app loads the wrong clr assemblies (1.1 instead of 2.0)
take look at the loaded assemblies. check the versions and their codebase (you cann get a list of all loaded assemblies in the appdomain class. GetLoadedAssemblies i think)
greets
m@u
|
|
|
|
|
What is the exception text? Without seeing it, I have no idea.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Are you using invoke?
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Is it a static method? If so you can't call it on an instance. Without seeing the exception or the code then there's bugger all else we can do to help.
BTW - change your subject to something more intelligent. We know it's a question about C# - this is a C# forum after all.
|
|
|
|
|
No..not static just a simple
public class X
{
public void Y()
{
}
}
the class in a project and the caller is in another project..both c#
Both projects compile...
...during execution/debugging the "Method not found" exception is raised!
Regards
Kev
|
|
|
|
|
HI,
I Like to know if anyone know a good Article about
Code Optimization in C#
i'd like to know how to reduce The memory Occupied by the APP
i don't know where to start becasue it's an unknown world to me
THNKS
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: i don't know where to start
Start with google
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
yeh i know,
but the problem is that i do not really know in which direction to go
but thanks anyway
LUC halped me(THANKS LUC)to begin somewhere
Have Fun
Never forget it
|
|
|
|
|
Glad Luc was able to help you more than I could with just the google bit. Also, when doing memory consumption checking, using the Performance Counter class can be very helpful
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: using the Performance Counter class can be very helpful
can u elaborate more Please?
THANKS for responding
Have Fun
Never forget it
|
|
|
|
|
Performance Counter class google search[^] should be a start for you.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
COOL, THANKS
Have Fun
Never forget it
|
|
|
|
|
No problem. There are plenty of metrics you can measure with the class, so it is worthy to have in your toolbox
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi,
I don't have specific articles in mind.
Is there a specific problem? Most problems get solved by common sense.
Memory related problems need an answer to these questions:
1. are my objects larger than necessary?
2. am I using more objects than necessary?
3. am I keeping them alive longer than necessary?
4. when I don't need an object any longer, and it offers either a Close() or a Dispose() method,
do I call it explicitly? This applies to simple objects such as Pen and Font, as well as
extremely complex things such as Graphics. If you do "new Font" in a Paint handler, you
should Dispose of the Font (or better yet hold it in a class member for future use, so don't
create new ones all the time)
5. if my class is allocating unmanaged resources (say through native code), do I provide
a Dispose() method?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
THANKS
u clarifyed a lot of things
but for a start correct me if i'm wrong
u say be ware of this :
<br />
private void function()<br />
{<br />
class a = new class();<br />
}<br />
<br />
it is better do define it once and use it all along the app?
second :
what do u mean by
Luc Pattyn wrote: 1. are my objects larger than necessary?
and about the Dispose(), i'm learning it now to see how to implement the interface
and again THANKS
Have Fun
Never forget it
|
|
|
|
|
Hi,
half-life wrote: it is better do define it once and use it all along the app?
in programming, most objects mimic real-life objects, so their life span should correspond.
If you replace your car by a new one, that is a new object, don't try to recycle the old object.
But if your paint handler needs a Pen to draw a line, it is a similar pen each time, so why
not keep the pen handy and continue using it, as opposed to always create a new one.
half-life wrote: are my objects larger than necessary?
Data efficiency:
- store text in strings, rather than adding individual characters to a Collection.
- store image pixels in an image, not pixel objects in a Collection.
- don't use a two-dimensional array if a one-dimensional array can do the job.
etc etc.
Overall, don't make objects out of everything, items that belong together, have the same
life span, cannot exist without each other, should be part of a single object. It's things
like that that I meant here.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|