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

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds