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

  • Traditional approaches to application modernization, either manual rewrite or auto-migration tools, have been proven time and again as inefficient. Rewrite needs scarce dev skills, is slow, risky and costly; auto-migration is what Verccio Dale of Gartner defines as "a pig with a lipstick, is still a pig." Are there alternatives? Find out, download this short practical guide now!

  • Following an IT incident through to resolution is more than just acknowledging an alert and restarting a server. The recent State of On-Call Report found that it takes most companies an average of 10-30 minutes to resolve an incident with an average of 5 people involved. Imagine how much money and time companies are spending to deal with incident resolution. But what if you had a tool that offered solutions baked in? Or a tool that sent alerts to the right person or team every time? These are the kind of …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date