flat assembler
Message board for the users of flat assembler.
Index
> Windows > capturing mouse double-clicks |
Author |
|
bitRAKE 04 Apr 2008, 23:04
Use GetDoubleClickTime result to know how long to wait for double click message. I don't like it though. Seems like common usage on Google Code search.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
04 Apr 2008, 23:04 |
|
Yardman 05 Apr 2008, 00:19
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 03:00; edited 1 time in total |
|||
05 Apr 2008, 00:19 |
|
revolution 05 Apr 2008, 00:35
Usually one would use the double click as an extension to the single click. Then the double click is more logical to use. Example: select with single click and perform-some-operation on double click. Any other use might just end up confusing the user anyway.
|
|||
05 Apr 2008, 00:35 |
|
oobie-noobie 05 Apr 2008, 00:46
Thanks for all the replies. All I could find was also the use of a timer (which I don't like either).
I agree revolution, but the app I'm writing is for my own use (and this user is confused enough, lol). Anyways, here's what I ended up with, not pretty but it gets the job done Edited here: also found after plugging this into my main app that you lose the mouse position in the timer wait I've amended the code below to preserve it Code: format PE GUI 4.0 entry start include '%fasminc%\win32axp.inc' section '.code' code readable executable start: invoke GetModuleHandle, 0 mov [wc.hInstance],eax invoke RegisterClass,wc invoke CreateWindowEx,WS_EX_CLIENTEDGE,myClass,NULL,WS_VISIBLE+WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 400, NULL, NULL, [wc.hInstance],NULL mov [hWndMain], eax invoke GetDoubleClickTime shr eax, 1 ;only waiting half the set double-click time mov [DCT], eax msg_loop: invoke GetMessage,msg,NULL, 0, 0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc wndProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je .wmDESTROY cmp [wmsg], WM_LBUTTONDOWN jne @f push [lparam] pop [MousePos] invoke SetTimer, [hwnd], NULL, [DCT], NULL xor eax, eax jmp .wmBYE @@: cmp [wmsg], WM_LBUTTONDBLCLK jne @f invoke KillTimer, [hwnd], NULL push [MousePos] pop [lparam] jmp .wmLBUTTONDBLCLK @@: cmp [wmsg], WM_TIMER jne @f invoke KillTimer, [hwnd], NULL push [MousePos] pop [lparam] jmp .wmLBUTTONDOWN @@: jmp .wmDEFAULT .wmDEFAULT: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .wmBYE .wmLBUTTONDBLCLK: invoke MessageBox, 0, lbdcStr, 0, MB_OK xor eax, eax jmp .wmBYE .wmLBUTTONDOWN: invoke MessageBox, 0, lbdStr, 0, MB_OK xor eax, eax jmp .wmBYE .wmDESTROY: invoke PostQuitMessage, 0 xor eax,eax jmp .wmBYE .wmBYE: pop edi esi ebx ret endp section '.data' data readable writeable wc WNDCLASS CS_DBLCLKS, wndProc, 0, 0, NULL, NULL, NULL, COLOR_BTNFACE+1, NULL, myClass myClass db "test", 00 hWndMain dd ? msg MSG lbdStr db "Left button down", 00 lbdcStr db "Left button double click", 00 DCT dd ? MousePos dd ? section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32, 'USER32.DLL' include '%fasminc%\apia\Kernel32.inc' include '%fasminc%\apia\User32.inc' |
|||
05 Apr 2008, 00:46 |
|
bitRAKE 05 Apr 2008, 01:58
When a double click happens a timer is created for the second WM_LBUTTONDOWN - unless I'm miss reading the code, or the second one isn't sent? Seems to work just fine.
Edit: okay, the second WM_LBUTTONDOWN come before the WM_LBUTTONDBLCLK, and so poses no problem. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
05 Apr 2008, 01:58 |
|
bitRAKE 05 Apr 2008, 02:41
It's like the double click message isn't needed, lol.
Code: ;**************** ;* DblClick.asm * ;**************** format pe gui 4.0 include 'win32axp.inc' .code start: invoke GetModuleHandle, 0 mov [wc.hInstance],eax invoke LoadCursor,NULL,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc invoke CreateWindowEx,WS_EX_CLIENTEDGE,myClass,"DblClick",\ WS_VISIBLE+WS_OVERLAPPEDWINDOW,\ CW_USEDEFAULT,CW_USEDEFAULT,300,400,\ NULL,NULL,[wc.hInstance],NULL mov [hWndMain],eax msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc wndProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je .wmDESTROY cmp [wmsg],WM_LBUTTONDOWN je .wmLBUTTONDOWN ; cmp [wmsg],WM_LBUTTONDBLCLK ; je .wmLBUTTONDBLCLK jmp .wmDEFAULT .wmDEFAULT: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .wmBYE ; .wmLBUTTONDBLCLK: ; invoke KillTimer,[hwnd],1 ; invoke MessageBox,[hwnd],lbdcStr,myClass,MB_OK ; xor eax,eax ; jmp .wmBYE .wmLBUTTONDOWN: test [WM_Flags],1 jne .double or [WM_Flags],1 invoke GetDoubleClickTime invoke SetTimer,[hwnd],1,eax,TimerProc xor eax,eax jmp .wmBYE .double: and [WM_Flags],-2 invoke KillTimer,[hwnd],1 invoke MessageBox,[hwnd],lbdcStr,myClass,MB_OK xor eax,eax jmp .wmBYE .wmDESTROY: invoke PostQuitMessage,0 xor eax,eax jmp .wmBYE .wmBYE: pop edi esi ebx ret endp proc TimerProc hwnd,uMsg,idEvent,dwTime and [WM_Flags],-2 invoke KillTimer,[hwnd],[idEvent] invoke MessageBox,[hwnd],lbdStr,myClass,MB_OK endp .data ;CS_DBLCLKS wc WNDCLASS 0,wndProc,0,0,NULL,NULL,NULL,\ COLOR_BTNFACE+1,NULL,myClass myClass db "DblClick",0 hWndMain dd ? WM_Flags dd ? msg MSG lbdStr db "Left button down",0 lbdcStr db "Left button double click",0 .end start _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
05 Apr 2008, 02:41 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.