Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Accessing the statusbar in a worker thread problem Pin
Diddy8-Feb-04 9:18
Diddy8-Feb-04 9:18 
GeneralRe: Accessing the statusbar in a worker thread problem Pin
J.B.8-Feb-04 13:54
J.B.8-Feb-04 13:54 
GeneralWeb View Pin
Prakash Nadar3-Feb-04 18:20
Prakash Nadar3-Feb-04 18:20 
GeneralPLZ help me on web server stuff Pin
laurentz_wei3-Feb-04 15:33
laurentz_wei3-Feb-04 15:33 
GeneralRe: PLZ help me on web server stuff Pin
Christian Graus3-Feb-04 17:51
protectorChristian Graus3-Feb-04 17:51 
GeneralRe: PLZ help me on web server stuff Pin
laurentz_wei3-Feb-04 18:48
laurentz_wei3-Feb-04 18:48 
Questionhow should RegisterHotKey() be used? Pin
Zephyr1233-Feb-04 14:50
sussZephyr1233-Feb-04 14:50 
AnswerRe: how should RegisterHotKey() be used? Pin
Antti Keskinen3-Feb-04 18:23
Antti Keskinen3-Feb-04 18:23 
Simple.

You use RegisterHotKey to register a new, global, system wide hotkey that can be used to send a predefined WM_HOTKEY message to the targetted window.

For example, this code piece creates a hotkey ALT+Z for the calling thread.
RegisterHotKey(NULL, 0x0010, MOD_ALT, VK_Z);
Now, whenever you press ALT+Z, a WM_HOTKEY message is generated and posted into the calling thread's message queue. You can then create a message-map entry for MFC applications using
BEGIN_MESSAGE_MAP( CMyWindow )
   ON_MESSAGE( WM_HOTKEY, HandleHotKeyPress )
END_MESSAGE_MAP
See ON_COMMAND for information about the declaration of the handler function. It generally is a function taking two parameters of type WPARAM and LPARAM and returning a UINT or a boolean value. It might also return nothing.

You should store the hotkey identifier (0x0010) into a global variable, like a const UINT. This way you can call the UnregisterHotKey by using a constant instead of a raw number. Always remember to call the unregistration function when you no longer need the hotkey. Otherwise your application will fail to register a hotkey, because it's already reserved. Also, keeping the hotkey association active without having the target handler available may cause a system crash on Windows 95/98/Me.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: how should RegisterHotKey() be used? Pin
zephyr1233-Feb-04 18:43
susszephyr1233-Feb-04 18:43 
GeneralStatus Of Object. Pin
kimsangwoo3-Feb-04 13:19
kimsangwoo3-Feb-04 13:19 
GeneralRe: Status Of Object. Pin
Christian Graus3-Feb-04 17:49
protectorChristian Graus3-Feb-04 17:49 
GeneralRe: Status Of Object. Pin
kimsangwoo3-Feb-04 19:16
kimsangwoo3-Feb-04 19:16 
GeneralRe: Status Of Object. Pin
Steve S3-Feb-04 22:58
Steve S3-Feb-04 22:58 
GeneralSerial project in Visual C++ problem Pin
rmnowick3-Feb-04 12:32
rmnowick3-Feb-04 12:32 
GeneralRe: Serial project in Visual C++ problem Pin
rmnowick4-Feb-04 8:42
rmnowick4-Feb-04 8:42 
Questionhow to print to a specific tray of a printer Pin
asawari3-Feb-04 11:36
asawari3-Feb-04 11:36 
AnswerRe: how to print to a specific tray of a printer Pin
basementman3-Feb-04 16:47
basementman3-Feb-04 16:47 
GeneralCapture windows messages Pin
benny23233-Feb-04 10:22
benny23233-Feb-04 10:22 
GeneralRe: Capture windows messages Pin
Neville Franks3-Feb-04 10:27
Neville Franks3-Feb-04 10:27 
GeneralRe: Capture windows messages Pin
Anonymous4-Feb-04 11:58
Anonymous4-Feb-04 11:58 
Generalstill can't use SQL database Pin
halblonious3-Feb-04 10:12
halblonious3-Feb-04 10:12 
GeneralRe: still can't use SQL database Pin
Vic Mackey3-Feb-04 10:24
Vic Mackey3-Feb-04 10:24 
GeneralRe: still can't use SQL database Pin
halblonious3-Feb-04 10:54
halblonious3-Feb-04 10:54 
GeneralRe: still can't use SQL database Pin
Vic Mackey3-Feb-04 11:23
Vic Mackey3-Feb-04 11:23 
GeneralRe: still can't use SQL database Pin
Steve S3-Feb-04 23:01
Steve S3-Feb-04 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.