Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I have right button down event I have this function:

BOOL CScarView::PreTranslateMessage(MSG * pMsg)


and inside I have all code, but if I must call function PretranslateMessage what message I must put?

pMsg->message = ON_WMRIGHT

THANKS;

What I have tried:

I tried to use code inside pretranslate message directly ma I have much errors..I prefer call function pretranslate message
Posted
Updated 13-Jul-23 9:02am
v2
Comments
jeron1 13-Jul-23 10:23am    
Couldn't you use PostMessage or SendMessage and send the WM_RBUTTONDOWN event to the appropriate window?
Member 14594285 13-Jul-23 10:33am    
I must use pretranslate message
jeron1 13-Jul-23 10:39am    
Any particular reason why?

1 solution

I was uncertain about this so I performed an experiment. I opened a dialog in one of my programs and then I fired up the Spy++ utility and after filtering out a LOT of messages I see what's going on. The dialog receives the message WM_RBUTTONDOWN with fwKeys set to MK_RBUTTON and the coordinates of the click. Then it receives the WM_RBUTTONUP messages with fwKeys set to 0 and the same coordinates sent previously. The coordinates appear to be relative to the dialog's window. There is another message that is relevant: WM_ACTIVATEAPP which activates the app but as long as your program is the foreground window you won't need that.

This was done using a dialog but I saw exactly the same things when using a regular program and clicking in its client area.

I highly recommend checking out Spy++ and learning out to use it. It is very useful for things like this. You can find it in VisualStudio 2022's Common7/Tools directory. Initially you will see tons of messages being logged but it has a configurable filter that can suppress "noise" messages such as WM_KICKIDLE and others like it.
 
Share this answer
 
Comments
Member 14594285 14-Jul-23 3:04am    
I did it:

MSG MSGProiez; // Messaggio da girare al motore delle funzioni.

MSGProiez.hwnd = nullptr;
MSGProiez.message = WM_RBUTTONDOWN;
MSGProiez.pt.x = MSGProiez.pt.y = 0;
MSGProiez.wParam = 0;
MSGProiez.lParam = MAKELONG(0, 0);
MSGProiez.time = 0;

PreTranslateMessage(&MSGProiez);


but if I insert function inside a timer crashes, if I insert trhis inside a button works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900