Hello! I believe hotkeys or keyboard shortcuts is the correct term. (Ctrl+C is copy etc...) Well I'm having troubles trying to figure out how to do this. I'm very new to the win32 api and such And I'm just clueless. Any help is very much appreciated!

I suggest you reading about keyboard accelerators here on MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646337%28v=vs.85%29.aspx

Keyboard accelerators is an easier way to handle combinations of keystrokss like Ctrl+Z or Ctrl+C

You define the accelerators in your resource file, assign a hotkey and give it a unique name.

// In your code, declare a handle to an accelerator table
HACCEL hAccelTable;

// Load the accelerators in your program with LoadAccelerators() function

// Handle accelerators in a special way with TranslateAccelerator() function
while (GetMessage(&msg, NULL, 0, 0) > 0) 
    if (!TranslateAccelerator(msg.hwnd, CWinBase::hAccelTable, &msg))
        TranslateMessage(&msg); // Convert virutal key codes to character.
        DispatchMessage(&msg);  // Passes message to window procedure.

// Process the accelerators in your window procedure under the WM_COMMAND id
// Respond to accelerator events.
    int accel_id = LOWORD(wParam);

    switch (accel_id) {
        case ID_EDIT_UNDO:    // Ctrl+Z
            // Undo an action

        case ID_EDIT_REDO:    // Ctrl+Y
            // Redo an action

Edited 4 Years Ago by dx9_programmer

This article has been dead for over six months. Start a new discussion instead.