views:

493

answers:

2

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?

Thanks.

+1  A: 

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
ctacke
A: 

thank you so much... I was going crazy with this...

your code worked exactly as expected...

At first I used it and had the same results, the softkey area would be blank except for the SIP input button.

After an hour or so of debugging I tried putting those 2 lines of code at the END of my OnInitDIalog() and it worked :)

My problem ende dup being that in my OnIitDialog() I am creating some child dialogs. when I put the CCommandBar.InsertMenuBar() before I create child dialogs I do not get my "ok" or "Cancel" soft keys, when I put that line after the creation of child dialogs the softkeys show as expected and work great.

Thanks again

snctln