From: vbguy on
I am using this code to move a button at run time.

[code]

If e.Button = Windows.Forms.MouseButtons.Left Then
Button1.Capture = False
Dim msg As Message = _
Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
[/code]

Everything works as planned, however, I can not click on the button.
It basically freezes the click event and is only movable.

I was told to confirm the location on the mouse up event, but do not
exactly know what that means.

Can anyone help me on this subject?


Thanks in advance
From: Cor Ligthert[MVP] on
What do you mean by move?

The location, you use the left property (the property meant for its left
location to something at least I don't understand)

Moving a location 10 points to the right in its parent container, you can
simply do with.

Button1.left = Button1.left+10

Properties to do this are location (which uses points), left and top

Success

Cor

"vbguy" <surfin_chick6(a)yahoo.com> wrote in message
news:eec4ee81-af08-4099-ae62-279e9b4f4517(a)d21g2000yqn.googlegroups.com...
> I am using this code to move a button at run time.
>
> [code]
>
> If e.Button = Windows.Forms.MouseButtons.Left Then
> Button1.Capture = False
> Dim msg As Message = _
> Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
> New IntPtr(HTCAPTION), IntPtr.Zero)
> Me.DefWndProc(msg)
> End If
> [/code]
>
> Everything works as planned, however, I can not click on the button.
> It basically freezes the click event and is only movable.
>
> I was told to confirm the location on the mouse up event, but do not
> exactly know what that means.
>
> Can anyone help me on this subject?
>
>
> Thanks in advance

From: Alex Clark on
Cor,

I believe he's trying to move the button by dragging it with the mouse, and
is using window messages to simulate a taskbar drag but on the button itself
rather than a window.

In answer to vbguy's question:

Have you tried calling ReleaseCapture with an hWnd of 0 afterwards?

Also, you're sending a message to the button indicating the left mouse
button was pressed on it's non-client area. Have you sent a corresponding
WM_NCLBUTTONUP message once the mouse button is released?

HTH,
Alex



"Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message
news:%23F2uH7tgKHA.2188(a)TK2MSFTNGP04.phx.gbl...
> What do you mean by move?
>
> The location, you use the left property (the property meant for its left
> location to something at least I don't understand)
>
> Moving a location 10 points to the right in its parent container, you can
> simply do with.
>
> Button1.left = Button1.left+10
>
> Properties to do this are location (which uses points), left and top
>
> Success
>
> Cor
>
> "vbguy" <surfin_chick6(a)yahoo.com> wrote in message
> news:eec4ee81-af08-4099-ae62-279e9b4f4517(a)d21g2000yqn.googlegroups.com...
>> I am using this code to move a button at run time.
>>
>> [code]
>>
>> If e.Button = Windows.Forms.MouseButtons.Left Then
>> Button1.Capture = False
>> Dim msg As Message = _
>> Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
>> New IntPtr(HTCAPTION), IntPtr.Zero)
>> Me.DefWndProc(msg)
>> End If
>> [/code]
>>
>> Everything works as planned, however, I can not click on the button.
>> It basically freezes the click event and is only movable.
>>
>> I was told to confirm the location on the mouse up event, but do not
>> exactly know what that means.
>>
>> Can anyone help me on this subject?
>>
>>
>> Thanks in advance
>


From: Cor Ligthert[MVP] on
Alex,

Seems to me very difficult to do, to drag a button by a mouse, how do you
know that it was not a click.

But you never know what humans are able to think of they need to do

:-)

Cor

"Alex Clark" <quanta(a)noemail.noemail> wrote in message
news:OSrpFJ2gKHA.3888(a)TK2MSFTNGP02.phx.gbl...
> Cor,
>
> I believe he's trying to move the button by dragging it with the mouse,
> and is using window messages to simulate a taskbar drag but on the button
> itself rather than a window.
>
> In answer to vbguy's question:
>
> Have you tried calling ReleaseCapture with an hWnd of 0 afterwards?
>
> Also, you're sending a message to the button indicating the left mouse
> button was pressed on it's non-client area. Have you sent a corresponding
> WM_NCLBUTTONUP message once the mouse button is released?
>
> HTH,
> Alex
>
>
>
> "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message
> news:%23F2uH7tgKHA.2188(a)TK2MSFTNGP04.phx.gbl...
>> What do you mean by move?
>>
>> The location, you use the left property (the property meant for its left
>> location to something at least I don't understand)
>>
>> Moving a location 10 points to the right in its parent container, you can
>> simply do with.
>>
>> Button1.left = Button1.left+10
>>
>> Properties to do this are location (which uses points), left and top
>>
>> Success
>>
>> Cor
>>
>> "vbguy" <surfin_chick6(a)yahoo.com> wrote in message
>> news:eec4ee81-af08-4099-ae62-279e9b4f4517(a)d21g2000yqn.googlegroups.com...
>>> I am using this code to move a button at run time.
>>>
>>> [code]
>>>
>>> If e.Button = Windows.Forms.MouseButtons.Left Then
>>> Button1.Capture = False
>>> Dim msg As Message = _
>>> Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
>>> New IntPtr(HTCAPTION), IntPtr.Zero)
>>> Me.DefWndProc(msg)
>>> End If
>>> [/code]
>>>
>>> Everything works as planned, however, I can not click on the button.
>>> It basically freezes the click event and is only movable.
>>>
>>> I was told to confirm the location on the mouse up event, but do not
>>> exactly know what that means.
>>>
>>> Can anyone help me on this subject?
>>>
>>>
>>> Thanks in advance
>>
>
>
From: Armin Zingler on
Cor Ligthert[MVP] schrieb:
> Alex,
>
> Seems to me very difficult to do, to drag a button by a mouse, how do you
> know that it was not a click.

Like moving a file in Explorer. You can select it or drag it using an initial
threshold (see API function GetSystemMetric, SM_CXDRAG or SM_CYDRAG)

http://msdn.microsoft.com/en-us/library/ms724385%28VS.85%29.aspx

--
Armin