|
-
November 3rd, 2000, 10:18 PM
#1
PreTranslateMessage()
Hi there! Can anyone here tell me what is PreTranslateMessage() and what does it do?
Also, what is the MSG* pMsg parameter in PreTranslateMessage()? Thanks!(how do U use it?)
"Hell is calling for you!" - Rufus, from Valkyrie Profile 2 : Silmeria
"I'm getting tired of you devils.....finishing strike......Final Blast!" - Arngrim, from Valkyrie Profile 2 : Silmeria
-
November 4th, 2000, 08:18 AM
#2
Re: PreTranslateMessage()
Hi,
If u look in MSDN: "The TranslateMessage function translates virtual-key messages into character messages."
Now, I've used many times to capture messages form controls of dialog boxes (edits, buttons, etc.).
The MSG *pMsg is a pointer to a MSG structure who contains:typedef struct tagMSG { // msg
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;
So, how u use it: let's say that u want to capture the enter key from a edit box in youd dialog based app. Then in your overriden PreTranslateMessage u must capture the WM_KEYDOWN message (pMsg->message == WM_KEYDOWN) and check your hwnd edit box (pMsg->hWnd == m_edit.m_hWnd) and for what key was pressed (pMsg->wParam == VK_RETURN) and return FALSE if all of this conditions are TRUE.
Tell me if that help or if u need more info.
Regards,
Emi.
Regards,
Emanuel Vaduva
-
November 4th, 2000, 06:36 PM
#3
Re: PreTranslateMessage()
Many times people use PreTranslateMessage when they do not know a more appropriate solution. For example, to capture the enter key from a edit box, give the edit box a multliline style and derive a class from CEdit. Then you can override OnKeyDown, OnkeyUp and/or OnChar.
See: http://home.socal.rr.com/samhobbs/VC...teMessage.html
****************************************************************************************************
Ratings are unimportant but feedback is. Let the helper and the worldwide community know what works, perhaps with ratings.
-
November 4th, 2000, 08:15 PM
#4
Re: PreTranslateMessage()
hi,
a) Why & How do you want to use it? That's the first question that comes not only to Sam Hobb's mind ;-)
b) What it is:
To process windows messages, each (UI) thread has a so called message loop, or message pump. this consists basically of:
1. Get message from Thread's Msg Queue
2. TranslateMessage: creates WM_CHAR messages from 'raw keyboard' messages (WM_KEYDOWN/UP)
3. Dispatch message to the window that is responsoble for handling
MFC allows you to get hold of each message beetween 1 and 2. This is sometimes necessary to intercept messages that can#t be handled otherwise.
c) The members of the MSG struct are documented in MSDN. The relate to the parameters of a WindowProc.
Peter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|