Here is sample of my code where the array of CButtons is created. As you'll see this sample only uses RegisterHotKey(). I am not sure if I have to use any other hot key function.
int i;
int y1 = 90;
int y2 = 110;
HBITMAP hBitmap;
CWnd* hwndOwner;
CString StrLabel, StrBitmap;
DWORD dwStyle, dwHotKeyStyle;
RECT resizerect;
hwndOwner = this;
GetWindowRect (&resizerect);
ScreenToClient (&resizerect);
resizerect.left += 200;
resizerect.right +=200;
resizerect.top += 100;
resizerect.bottom += 100;
MoveWindow (&resizerect, true);
UpdateData();
dwStyle = WS_CHILD|WS_VISIBLE|WS_TABSTOP|BS_PUSHBUTTON|BS_CE NTER;
dwHotKeyStyle = CCS_LEFT;
// Establish the bitmap to put on the button
// -------------------
StrBitmap = "d:\\shortcuts\\"+LoggedOnUser+"\\Start\\"+LoggedO nUser + ".BMP";
hBitmap = (HBITMAP)LoadImage(NULL, StrBitmap, IMAGE_BITMAP, 100, 50, LR_LOADFROMFILE);
// if(hBitmap == NULL)
// MessageBox("No se puede cargar el bitmap.");
m_AirlineBMP.SetBitmap(hBitmap);
for(i=1; i<=nbShortcuts; i++)
{
// Create Push Buttons
// Use the Applications data struct to extract the corresponding
// Executable name and display it in the button
// -------------------
MyButtons[i].Create(Applications[i-1].ExeName, dwStyle,
CRect(10, y1-5, 220, y2-5), hwndOwner, i+2);
// Create Hotkeys
// Use the loop index to create the hot key so that button #1 is access by pressing Alt-1
// --------------------
RegisterHotKey(HWND(hwndOwner),i+2,MOD_CONTROL, i+2);
// Change button's y position
y1 = y1 + 30;
y2 = y2 + 30;
if(i > 2)
resizerect.bottom += 35;
MoveWindow (&resizerect, true);
UpdateData(FALSE);
}
I'm also using the DefWindowProc() to capture the PushButton's WM_COMMAND and BN_CLICKED messages as such:
if(message == WM_COMMAND)
{
if(HIWORD(wParam) == BN_CLICKED)
{
How would I add the code to capture the WM_HOTKEY message?
Thanks
|