Manually displaying a system menu
I'm making a form that has a completely owner-draw nonclient area and have to manually hittest to open the system menu.
The code below opens the system menu, but the items don't do anything whn you click them.
Any ideas?
(you can specify an x,y coordinate in place of my code which places the menu neatly underneath the button.)
GetSystemMenu and TrackPopupMenu are win32 api functions.
vb.net Code:
Dim sysmnu As IntPtr = GetSystemMenu(Me.Handle, False)
Dim mnuloc As Rectangle = _systemMenuButtonParams.ToRectangle(Me.Size)
mnuloc.Offset(Me.Location.X, Me.Location.Y)
TrackPopupMenu(sysmnu, TPM_LEFTALIGN Or TPM_NOANIMATION, mnuloc.Left, mnuloc.Bottom, 0, Me.Handle, Nothing)
Re: Manually displaying a system menu
I may be wrong with this, but aren't you forgetting sending WM_COMMAND to your window?
http://msdn.microsoft.com/en-us/libr...91(VS.85).aspx
Re: Manually displaying a system menu
I could have sworn that a system menu being popped up in this manner would still send the commands to the window as wm_syscommand, not wm_command. maybe i'm not understanding it quite right?
Re: Manually displaying a system menu
Well, maybe it is wm_syscommand, but still it's worth trying.