Software Archive
Read-only legacy content
17061 Discussions

Help with SendMessage API

sumitm
Beginner
479 Views
Hi,
I need to close a graphics window with a right mouse click option. Currently the window closes when I hot enter. I was advised by Leo quite some time back that I need to use the SendMessage API with WM_Keydown message with VK_Return as the virtual keycode. I have gotten this far but need help with the VK_Return implementation. Can anyone please guide a novice like me a little more.

Thanks

Sumit
logi=.TRUE. 
do while(logi)
bret=waitonmouseevent(MOUSE$RBUTTONDOWN,keystate,ixpos,iypos)
if (keystate == MOUSE$KS_RBUTTON) then
iret= Messageboxqq('Close Window ?','Mouse Action'C,MB$ICONEXCLAMATION.OR.MB$YESNO)
IF(IRET == MB$IDYES) then !call exit()
hWnd= GetHWNDQQ(5)
iret=Focusqq(5)
iret=SetActiveQQ(5)
iret=SendMessage(hWnD,WM_Keydown,0,0)
...
logi=.FALSE.
end if
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
479 Views
Should be iret=SendMessage(hWnd, WM_KEYDOWN, VK_RETURN, 0) (perhaps 1 as last argument). I don't guarantee that the method will work though.
0 Kudos
sumitm
Beginner
479 Views
Dear Jugoslav,

Thanks for your response. It defintely encouraged me to think that I was on the right path. The following worked. Thanks again
iret=SendMessage(hWnD,WM_IME_Keydown,VK_RETURN,0)
0 Kudos
Reply