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

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • Live Event Date: August 14, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Data protection has long been considered "overhead" by many organizations in the past, many chalking it up to an insurance policy or an extended warranty you may never use. The realities of today makes data protection a must-have, as we live in a data-driven society -- the digital assets we create, share, and collaborate with others on must be managed and protected for many purposes. Check out this upcoming eSeminar and join Seagate Cloud …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds