CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jun 2008
    Posts
    24

    Random questions / issues (mostly API)

    I've a done a lot of stuff, but API is confusing as hell and poorly documented, IMO. Anyway, I'm writing an editor of sorts and I'm having trouble getting certain things to work.

    Ok, my current concern is how to catch key presses globally. I want the key press, regardless of which control has focus. Is an accelerator the only way? I didn't really understand how to use those.

    This is how I setup the main dialog in mine:
    Code:
    BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
        LVCOLUMN LvCol; // Make Column struct for ListView
        HWND hEditBox;
        char txtInput[256];
        HWND hListData = GetDlgItem(hwnd, LST_DATA);
    
    	switch(Message)
    	{
    		case WM_KEYDOWN:
    		{
                         //This doesn't seem to catch keys when any control has focus.
                     }
    		case WM_CLOSE:
    			EndDialog(hwnd, 0);
    		break;
    		default:
    			return FALSE;
    	}
    	return TRUE;
    }
    Code:
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	return DialogBox(hInstance, MAKEINTRESOURCE(ELF_MAIN), NULL, DlgProc);
    }
    Last edited by Viper187; June 8th, 2008 at 08:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured