Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: BeginReceive problem (Sockets question) Pin
Shy Agam6-May-06 22:44
Shy Agam6-May-06 22:44 
GeneralRe: BeginReceive problem (Sockets question) Pin
tmp07-May-06 2:53
tmp07-May-06 2:53 
QuestionTime stamp in applications Pin
_tasleem6-May-06 10:49
_tasleem6-May-06 10:49 
AnswerRe: Time stamp in applications Pin
led mike6-May-06 13:33
led mike6-May-06 13:33 
QuestionListBox Event Pin
Sean896-May-06 10:48
Sean896-May-06 10:48 
AnswerRe: ListBox Event Pin
led mike6-May-06 13:30
led mike6-May-06 13:30 
GeneralRe: ListBox Event Pin
Sean896-May-06 17:26
Sean896-May-06 17:26 
QuestionDragDrop() Event Handler assistance needed... Pin
new_phoenix6-May-06 10:33
new_phoenix6-May-06 10:33 
I have been working on an application that utilizes the DragDrop Event Handler. To accomplish this, I created a "public" variable named dragPoint which has both X and Y coordinates and made the assignment to that point in the MouseDown() Event handler.

The cursor remembers that clicked point on the control from the MouseDown() Event Handler when the user clicks on the control. However, the DragOver() Event handler does not reconcile that point click from the MouseDown() Event handler properly. Could somebody please provide some insights as I am missing some concept here.

The code is as follows:

private static void _ctrl_DragOver(object sender, DragEventArgs e)
{
try
{
if(DragDropHandler.CanDropHere((Control)sender, e.Data))
{
Control cthis = (Control)sender;
e.Effect = DragDropEffects.Move;
Control ctrl = DragDropHandler.GetControl(e.Data, false, true);

// Here is the code with the problem
Point NewLocation = cthis.PointToClient(new Point(e.X, e.Y));
ctrl.Left = NewLocationX + 2;
ctrl.Top = NewLocation.Y + 2;
// End problem code above
}
else
{
// Error Message
}
}
}

Note: I tried subtracting away the dragPoint.X from the "new Point()"
in the cthis.PointToClient() but that only causes the cursor to change to a circle with a slash through it indicating a mathematical conceptual error somewhere. I also tried to add the dragPoint.X to the ctrl.Left and the ctrl.Top, and while that does work, it causes the cursor to be placed to the left and to the top at a point equal to the point that the control is clicked in the MouseDown() Event. When I tried to subtract the dragPoint.X and dragPoint.Y from the ctrl.Left and ctrl.Top statements, then the cursor changes again to a circle with a slash through it.

What concept have I missed here? Should I be using PointToClient() or PointToScreen() ot something else to get the cursor to drag from the point that the user clicks on the control?

// Alternate code tried
Point NewLocation = cthis.PointToClient(new Point(e.X - dragPoint.X, e.Y - dragPoint.Y));
ctrl.Left = NewLocationX - dragPoint.X;
ctrl.Top = NewLocation.Y - dragPoint.Y;
// End alternate code tried

Confused | :confused: Confused | :confused: Confused | :confused:

-- modified at 18:31 Saturday 6th May, 2006
AnswerRe: DragDrop() Event Handler assistance needed... Pin
rudy.net7-May-06 4:11
rudy.net7-May-06 4:11 
Question.m4a Tag Reader Pin
4324235423534253425135143532456-May-06 9:36
4324235423534253425135143532456-May-06 9:36 
Questionwhere can i find ngen.exe? Pin
Susuko6-May-06 8:18
Susuko6-May-06 8:18 
AnswerRe: where can i find ngen.exe? Pin
Ravi Bhavnani6-May-06 9:05
professionalRavi Bhavnani6-May-06 9:05 
GeneralRe: where can i find ngen.exe? Pin
Susuko6-May-06 9:44
Susuko6-May-06 9:44 
GeneralRe: where can i find ngen.exe? Pin
Ravi Bhavnani6-May-06 9:52
professionalRavi Bhavnani6-May-06 9:52 
QuestionConvert a file to stream Pin
QzRz6-May-06 6:42
QzRz6-May-06 6:42 
AnswerRe: Convert a file to stream Pin
DigitalKing6-May-06 6:48
DigitalKing6-May-06 6:48 
GeneralRe: Convert a file to stream Pin
QzRz6-May-06 6:54
QzRz6-May-06 6:54 
AnswerRe: Convert a file to stream Pin
S. Senthil Kumar6-May-06 7:28
S. Senthil Kumar6-May-06 7:28 
Questiontree view represantation of string Pin
majid4u6-May-06 6:39
majid4u6-May-06 6:39 
AnswerRe: tree view represantation of string Pin
S. Senthil Kumar6-May-06 7:31
S. Senthil Kumar6-May-06 7:31 
Questionrepresentation of string in treeview Pin
majid4u6-May-06 6:06
majid4u6-May-06 6:06 
AnswerRe: representation of string in treeview Pin
Josh Smith6-May-06 6:18
Josh Smith6-May-06 6:18 
QuestionCheck box Databinding problems Pin
malikjhangirahmed@hotmail.com6-May-06 3:23
malikjhangirahmed@hotmail.com6-May-06 3:23 
QuestionHow to use IHTMLDocument2 with .NET 2.0 Webbrowser Pin
cweeks786816-May-06 3:20
cweeks786816-May-06 3:20 
AnswerRe: How to use IHTMLDocument2 with .NET 2.0 Webbrowser Pin
led mike6-May-06 6:40
led mike6-May-06 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.