Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C# Windows messaging problem

Status
Not open for further replies.

HerbertMunch

New Member
Hi all,
im trying to implement toolbar docking but have run into a problem.

Im using c# forms as toolbar windows and have overridden the tool windows wndproc.

I listen out for WM_NCLBUTTONDOWN messages to detect when to start dragging, which works fine.

The problem is that my wndproc method never seems to get any WM_Mousemove messages when the form is being dragged by the NC area.

This is strange as Ms spy records WM_Mousemove messages, even when the window is being dragged by the nc region.

Here are some of the recorded messages that spy obtained from my tool window form, as i dragged it using the title bar.

<00059> 00010572 S WM_NCHITTEST xPos:551 yPos:213
<00060> 00010572 R WM_NCHITTEST nHittest:HTCAPTION
<00061> 00010572 S WM_MOUSEACTIVATE hwndTopLevel:00010572 nHittest:HTCAPTION uMsg:WM_LBUTTONDOWN
<00062> 00010572 R WM_MOUSEACTIVATE fuActivate:MA_NOACTIVATE
<00063> 00010572 S WM_SETCURSOR hwnd:00010572 nHittest:HTCAPTION wMouseMsg:WM_LBUTTONDOWN
<00064> 00010572 R WM_SETCURSOR fHaltProcessing:False
<00065> 00010572 P WM_NCLBUTTONDOWN nHittest:HTCAPTION xPos:551 yPos:213
<00066> 00010572 S WM_NCACTIVATE fActive:True
<00067> 00010572 R WM_NCACTIVATE
<00068> 00010572 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:367 yPos:-9
<00069> 00010572 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:366 yPos:-10
<00070> 00010572 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:366 yPos:-12
<00071> 00010572 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:365 yPos:-13
<00072> 00010572 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:362 yPos:-15


Does anyone know why if spy can see the messages, why the WinForms windows wndproc doesnt?


I thought that maybe the dotnet windows forms wndproc was somehow limited so i just tried using SetWindowLong api to subclass the wndproc.

Didnt work, exactly the same results as overriding the Wndproc method.

here are the messages that were recorded using the subclassed window inside my program:

WM_MOVE
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_WINDOWPOSCHANGED
WM_MOVE
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_WINDOWPOSCHANGED
WM_MOVE
WM_WINDOWPOSCHANGING
WM_GETMINMAXINFO
WM_WINDOWPOSCHANGED
...... etc

As you can see, the WM_MOUSEMOVE message is not being received by my form, even though the spy output shows it as being sent to the form.

I think that maybe its something to do with the fact that the WM_MOUSEMOVE is sent as Postmessage and not sendMessage().

Thanks in advance to anyone that can shed any light on this.
 
Hi all,

dont worry I have sorted out what was wrong. it appears that i needed to call win32api SetCapture() method in response to WM_NCLBUTTONDOWN, in order to receive the wm_mousemove messages that spy++ found:) .

Chris.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top