Click to See Complete Forum and Search --> : Random questions / issues (mostly API)


Viper187
June 8th, 2008, 08:03 AM
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:

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;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(ELF_MAIN), NULL, DlgProc);
}

Igor Vartanov
June 8th, 2008, 12:30 PM
I've a done a lot of stuff, but API is confusing as hell and poorly documented, IMO."You don't like cats??? You just have no idea how to cook them properly." (A very old joke :))

In contrary, as for me the Windows API is the only part of Windows technologies that deserves for "well documented" nomination category. Just because it had enough time to become this.

Ok, my current concern is how to catch key presses globally.Look at WH_MSGFILTER and WH_GETMESSAGE (http://msdn.microsoft.com/en-us/library/ms644990.aspx) local hooks if you're looking for a really global solution..

egawtry
June 9th, 2008, 10:36 AM
Also take a look at WM_GETDLGCODE.


-Erik