locked
Handling messages for Windows Mobile 6 softkeys in dialog RRS feed

  • Question

  • Hi

    I'm having a problem using softkeys in my dialogs. Basically if I click the softkey, nothing happens, maybe I'm not handling the message properly?

    Here's the code:

    LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) // this function is the callback passed to DialogBox
    {
        int wmId, wmEvent;
    	switch(Msg)
    	{
    	case WM_INITDIALOG: // this seems to be working fine
    	{
    	    BOOL rb;
    	    SHINITDLGINFO sid;
    		SHMENUBARINFO mbi;
    
    		memset(&mbi, 0, sizeof(SHMENUBARINFO));
    		mbi.cbSize = sizeof(SHMENUBARINFO);
    		mbi.hwndParent = hWndDlg;
    		mbi.nToolBarId = IDR_OPTIONS_MENUBAR;
    		mbi.hInstRes = g_hInst;
    		mbi.dwFlags |= SHCMBF_HMENU;
    
    	    sid.dwMask = SHIDIM_FLAGS;
    	    sid.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
    	    sid.hDlg = hWndDlg;
    
    		rb = SHCreateMenuBar(&mbi);
    		if (rb == FALSE)
    		{
    		    return E_FAIL;
    		}
    	    rb = SHInitDialog(&sid);
    	    if (rb == FALSE)
    	    {
    			return E_FAIL;
    		}
    		break;
    	}
    	case WM_COMMAND:  // I've set up a breakpoint here, but it never reaches it
            wmId    = LOWORD(wParam); 
            wmEvent = HIWORD(wParam); 
    		switch(wmId)
    		{
    		case IDM_OK: // this is supposed to be the left soft key
    			EndDialog(hWndDlg, 0);
    			return TRUE;
    		case IDM_MORE: // this is supposed to be the right soft key
    			return TRUE;
    		}
    		break;
    	}
    
    	return FALSE;
    }
    

    And the resources:

    IDR_OPTIONS_MENUBAR MENU DISCARDABLE
    BEGIN
        MENUITEM "Ok" IDM_OK
        MENUITEM "More Options" IDM_MORE
    END
    Would someone please be so kind to tell me what's wrong here? I think I'm handling the messages wrong, the soft keys are being displayed, but if I click on them nothing happens.

    Regards

    Lionel
    "The moon could not continue shining if it had to pay attention to all the dogs barking at it."
    Thursday, July 2, 2009 4:40 PM

Answers

  • Solved my own problem - there's nothing wrong with listed code, problem was in the main window.
    "The moon could not continue shining if it had to pay attention to all the dogs barking at it."
    • Marked as answer by Y-Lionel Sunday, July 5, 2009 7:11 AM
    Sunday, July 5, 2009 7:11 AM