Windows – How to use the softkeys with a CDialog based application in windows mobile 6 via MFC

mfcwindows-mobile

How do I use the softkeys with a CDialog based application in windows mobile 6 via MFC?

I have a CDialog based Windows Mobile 6 (touchscreen) Professional app that I am workign on.

The default behavior of a CDialog based app in WM6 Professional is to not use any softkeys by default… I want to map the softkeys to "Cancel" and "OK" functionality that sends IDOK and IDCANCEL to my Main Dialog class.

I have been trying to work with CCommandBar with no luck, and SHCreateMenuBar was not working out for me either.

Does anyone have a sample of how to get this to work?

Best Answer

What's "not working" with the CCommandBar for you? You should be able to add a CCommandBar member to your dialog class, then in teh DIalog's InitDialog you call Create and InsertMenuBar on the command bar - something like this:

m_cmdBar.Create(this);
m_cmdBar.InsertMenuBar(IDR_MENU_RESRC_ID);

Your menu resource might look something like this:

IDR_MENU_RESRC_ID MENU DISCARDABLE
BEGIN
MENUITEM "OK", IDOK
MENUITEM "Cancel", IDCANCEL
END
Related Topic