Using Upper/Lowercase Shortcut Keys for Property Pages

This is a update from the article 'Using Shortcut Keys for Property Pages' from Zafir Anjum. The article only handled Uppercase shortcuts, here is one that handle both upper and lowercase shortcut keys.


You need to implement the following procedure to do the work:

BOOL CBasePropertySheet::PreTranslateMessage(MSG* pMsg) 
{
	if( pMsg->message == WM_SYSKEYDOWN && pMsg->wParam > 32 )
	{
		CTabCtrl *pTab = GetTabControl();
		int n = pTab->GetItemCount();

		TCHAR buf[80], shortcut1[3], shortcut2[3];
		TC_ITEM tcItem;

		tcItem.mask = TCIF_TEXT;
		tcItem.pszText = buf;
		shortcut2[0] = shortcut1[0] = _T('&');
		shortcut2[2] = shortcut1[2] = _T('\0');
		for( int i = 0; i < n; i++ )
		{
			tcItem.cchTextMax = 79;
			pTab->GetItem( i, &tcItem );
			shortcut1[1] = _totupper((TCHAR) pMsg->wParam);
			shortcut2[1] = _totlower((TCHAR) pMsg->wParam);
			if( _tcsstr( buf, shortcut1 ) || _tcsstr( buf, shortcut2 ) )
			{
				SetActivePage( i );
				return TRUE;
			}
		}
	}
	return CPropertySheet::PreTranslateMessage(pMsg);
}

Date Posted: 08/13/98



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: January 7, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT The Flash Visionary Chat series of webinars brings together IT and business leaders as well as thought leading industry analysts to discuss how the flash revolution is eradicating inefficiency, unleashing innovation, and accelerating businesses. Join us for this next episode where we are excited to host not only the 451 Research, who will share their recent industry research, but also one of our top customers, who will share their perspective on …

Most Popular Programming Stories

More for Developers

RSS Feeds