15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Property Page Accelerators

Steve Mark -- steve@otms.com
Friday, September 06, 1996

Environment: VC++ 1.52c, Win 95


I've got an app that creates property sheet, which adds a property page, which contains a dialog resource.  Buttons in the dialog resource are captioned with accelerator keys.  I'd like MFC to first check the dialog accelerators, then check the mainframe accelerators if the dialog didn't recognize a key.  Currently. as long as the property sheet is display, NO accelerators are processed.


I've gone thru the KB and added the following function to the property sheet class:


BOOL CMySheet::PreTranslateMessage(MSG* pMsg)

{

        HACCEL hAccel = ((CMainFrame*)AfxGetMainWnd())->GetAccelTable();

	 if(hAccel && ::TranslateAccelerator(AfxGetMainWnd()->m_hWnd, hAccel, pMsg))
                return TRUE;

        else

                return AfxGetMainWnd()->PreTranslateMessage(pMsg);

}



Now the mainframe menu accelerators work fine, but not the ones on the CPropertyPage dialog.


Any suggestions?


Steve



_________________________________________________________________

Steven Mark                           E-mail: steve@otms.com

On-The-Mark Systems                   Tel:    510.648.9514

3494 Camino Tassajara Rd., Suite 239  Fax:    510.648.9507

Danville, CA 94506                    Web:    http://www.otms.com


     Custom Software Analysis, Design, and Implementation



John Howard Robertson -- jrobert@howard-ind.com
Monday, September 09, 1996

Steve,=20

I have created a property sheet that contains 5 different property =
pages. =20

My solution was to create an accelerator table for each property page =
and to implement the PreTranslateMessage function for each property =
page.

snip ------
BOOL DPropPage1::PreTranslateMessage(MSG* pMsg)=20
{
	if (d_hAccel =3D=3D NULL)
		return FALSE;	// we didn't process.
=09
	return ::TranslateAccelerator(m_hWnd, d_hAccel, pMsg);
}

snip -----

The property page with focus processes any accelerators it has defined =
and passes on all others to the property sheet.

This seems to work OK for my application; however, I'm not sure if it is =
the optimal solution.  I am interested in seeing the other responses =
submitted.=20


Good Luck.
Hope this might help.
	John Howard Robertson






| Вернуться в корень Архива |