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