Article ID: 198439
Article Last Modified on 7/11/2005
int CALLBACK PropSheetCallbackProc(HWND hwndDlg, UINT uMsg, LPARAM
lParam)
{
if (uMsg == PSCB_INITIALIZED)
{
g_hWndPropSheet = hwndDlg; //Store the window handle of the
//property sheet in a global
//variable.
g_hhook = SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)hkProc,
NULL,GetWindowThreadProcessId(g_hWndPropSheet,NULL));
}
return 0;
}
LRESULT CALLBACK hkProc(UINT nCode, WPARAM wParam, LPARAM lParam)
{
if ( nCode < 0 )
{
return CallNextHookEx(g_hhook,nCode,wParam,lParam);
}
if ( ((MSG *)lParam)->message == WM_SYSCHAR )
{
HWND hTabCtrl = (HWND)
SendMessage(g_hWndPropSheet,PSM_GETTABCONTROL,0,0);
int nCount = SendMessage(hTabCtrl,TCM_GETITEMCOUNT,0,0);
TCHAR buf[80],shortcutLower[3],shortcutUpper[3];
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = buf;
shortcutUpper[0] = shortcutLower[0] = _T('&');
shortcutUpper[2] = shortcutLower[2] = _T('\0');
for( int i = 0; i < nCount; i++ )
{
tcItem.cchTextMax = 79;
SendMessage(hTabCtrl,TCM_GETITEM,i,(LONG)&tcItem);
shortcutUpper[1] = shortcutLower[1] =
(TCHAR) ((MSG *)lParam)->wParam;
if ( _istlower(shortcutUpper[1]) )
shortcutUpper[1] = _totupper(shortcutUpper[1]);
if ( _istupper(shortcutLower[1]) )
shortcutLower[1] = _totlower(shortcutLower[1]);
if ( _tcsstr( buf, shortcutLower ) ||
tcsstr(buf,shortcutUpper) )
{
PropSheet_SetCurSel(g_hWndPropSheet,NULL,i);
((MSG *)lParam)->message = WM_NULL; // We have taken care of
// the message, so make
// it WM_NULL.
}
}
}
return CallNextHookEx(g_hhook,nCode,wParam,lParam);
}
Additional query words: kbDSupport
Keywords: kbhowto kbpropsheet kbhook KB198439