flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > Right click on a control

Author
Thread Post new topic Reply to topic
ly47



Joined: 24 Sep 2010
Posts: 23
Hi
BM_CLICK message checks if left moude button been clicked on a control.
BUT
How to check if the right mouse button been clicked ?
Thanks
ly
Post 07 Sep 2019, 17:57
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 134
https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-rbuttondown

The message is WM_RBUTTONDOWN or 0x0204

Is this what you mean? You can also handle scenarios where you want the screen coords also, multiple buttons are pressed, etc.

I have a pen tablet and touch tablet and last used a setup like this:

Code:
        .wmPointerEnter:
        cmp rdx, 249h
        jne windowMsgs.wmPointerLeave   ; (Skip/switch)
        ;Handle message
        mov rax, 0
        jmp windowMsgs.completed

        .wmPointerLeave:
        cmp rdx, 24Ah
        jne windowMsgs.wmPointerUp      ; (Skip/switch)
        ;Handle message
        mov rax, 0
        jmp windowMsgs.completed

        .wmPointerUp:
        cmp rdx, 247h
        jne windowMsgs.wmPointerDown   ; (Skip/switch)
        ;Handle message
        mov rax, 0
        jmp windowMsgs.completed

        .wmPointerDown:
        cmp rdx, 246h
        jne windowMsgs.wmPointerUpdate    ; (Skip/switch)
        ;Handle message
        mov rax, 0
        jmp windowMsgs.completed

        .wmPointerUpdate:
        cmp rdx, 245h
        jne windowMsgs.wmUpdate      ; (Skip/switch)
        ;Handle message
        mov rax, 0
        jmp windowMsgs.completed

    


Been a while since I looked at this though, may not be what you're looking for. Going to revisit this message handling soon too, will post any updates or tweaks if I find any.

Good luck...
Post 07 Sep 2019, 18:29
View user's profile Send private message Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 23
Hi
Thanks for your reply.
I tried WM_RBUTTONDOWN and it works only for the main window
on any control it does nothing.
ly
Post 07 Sep 2019, 18:46
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 134
I see, not a Controls expert, sorry. Perhaps this:
https://docs.microsoft.com/en-us/windows/win32/controls/wm-notify

is a clue? wm_notify looks like a generic Control Message. This link shows it sending nm_rclick from a different Controll:
https://stackoverflow.com/questions/21770905/right-click-on-listview-winapi-c (Remy Lebeau's comment)

Have to log off for the day, maybe that's a clue if you're still wanting to resolve and stuck.


Have a good one.
Post 07 Sep 2019, 19:21
View user's profile Send private message Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 23
Hi again
Attached test asm file for right click
Not working on controls only on window itself.


Description:
Download
Filename: right_click_test.asm
Filesize: 4.07 KB
Downloaded: 14 Time(s)

Post 08 Sep 2019, 06:58
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1394
Location: Toronto, Canada
A better way in this case is a message called WM_CONTEXTMENU.
I added few lines into your code (marked with AG62).
Run the code in debugger and watch the debugger output window.
Or, if you not using debugger (weird, because you should) - replace OutputDebugString() with MessageBox().
Right click on any control will cause some printout.
Right click on window itself will not cause the printout, because you intercepted right click and did not let Windows handle it.


Description:
Download
Filename: a-help-btn-rclk.Asm
Filesize: 4.65 KB
Downloaded: 12 Time(s)

Post 08 Sep 2019, 14:08
View user's profile Send private message Send e-mail Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 23
Hi AsmGuru62
Thanks for your reply.
Yes it is working(I use MessageBox)
Now I can in any r.click on control to do something else...
But how can I know which control was right clicked ?
Thanks again
ly
Post 08 Sep 2019, 14:59
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1394
Location: Toronto, Canada
This: https://docs.microsoft.com/en-us/windows/win32/menurc/wm-contextmenu

The HWND of a thing which was clicked is a value of WPARAM.
Compare it with return values from CreateWindowEx() calls you did to create buttons.
Post 08 Sep 2019, 15:56
View user's profile Send private message Send e-mail Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 23
Hi again AsmGuru62
I tried to comapre wParam to return values from CreateWindowEx() calls I did to create buttons.
And nothing happened.
Attached your modified file.
Thank for your help
ly


Description:
Download
Filename: a-help-btn-rclk-2.Asm
Filesize: 4.87 KB
Downloaded: 12 Time(s)

Post 08 Sep 2019, 17:34
View user's profile Send private message Reply with quote
ly47



Joined: 24 Sep 2010
Posts: 23
Hi again AsmGuru62
Problem solved
Attached modified file
Thanks
ly


Description:
Download
Filename: a-help-btn-rclk-2x.Asm
Filesize: 4.28 KB
Downloaded: 10 Time(s)

Post 08 Sep 2019, 18:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.