Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Show system menu of a hwnd
#1
i try to show the system menu of a hwnd.
after searching in google and google groups i found this
Delphi tip#155: show system menu.

int SysMenu always returns values>0.
does using point even make sense ?

Code:
Copy      Help
int hwnd=win("" "SciCalc" "Calc")
POINT p;
GetCursorPos(&p);
int SysMenu=GetSystemMenu(hwnd 0)
int intSelected = TrackPopupMenuEx(SysMenu TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD p.x p.y hwnd 0)
SendMessage(hwnd WM_SYSCOMMAND intSelected 0)


thanks.
pi
#2
For me does not work too. But works if the window belongs to the same thread.

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("Dialog36" &Dialog36)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032000 0x0 0 121 48 14 "Button"
;END DIALOG
;DIALOG EDITOR: "" 0x2020100 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,int hwnd=hDlg
,
,POINT p;
,GetCursorPos(&p);
,int SysMenu=GetSystemMenu(hwnd 0)
,int intSelected = TrackPopupMenuEx(SysMenu TPM_RETURNCMD p.x p.y hwnd 0)
,
,SendMessage(hwnd WM_SYSCOMMAND intSelected 0)

,case IDOK
,case IDCANCEL
ret 1
#3
I used Spy++ to see what messages are sent to a window when you right click its button in the taskbar. The window then receives an undocumented and undefined message 0x313. And it really works.

Code:
Copy      Help
int hwnd=win("" "SciCalc" "Calc")
POINT p; xm p
SendMessage hwnd 0x313 0 p.y<<16|p.x
#4
thats nice.
i might be a good idea to act the hnwd before SendMessage.
or 0.2

thanks
pi
#5
Yes, when inactive sometimes does not work.

Code:
Copy      Help
int hwnd=win("" "SciCalc" "Calc")
act hwnd
SendMessage hwnd 0x313 0 ym<<16|xm


Forum Jump:


Users browsing this thread: 1 Guest(s)