From: Sylvester on
Hello,

I'm running a mfc dialog based application on a pocket pc. During
mainDlg::OnInitDialog I'm loading a menu which depends on a menu resource.

I'm trying to change the state of a menu item to either checked or unchecked
but a call to GetSubMenu fails, so I'cant change the state.

Is it possible to change the state or is it a constraint to Document/view
architecture based applications?

please help thanks in advance


From: r_z_aret on
I don't use MFC, but I'll try anyway. More below.

On Mon, 7 Feb 2005 14:48:51 +0100, "Sylvester"
<lists_sebastian(a)yahoo.de> wrote:

>Hello,
>
>I'm running a mfc dialog based application on a pocket pc. During
>mainDlg::OnInitDialog I'm loading a menu which depends on a menu resource.
>
>I'm trying to change the state of a menu item to either checked or unchecked
>but a call to GetSubMenu fails, so I'cant change the state.

Without knowing more about how you call GetSubMenu, I can't tell why
it fails. The following is a slightly edited copy of the function I
use. I let the caller pass a negative argument to specify the
top-level menu. It's part of a class, and m_hMenu is a member
variable.

HMENU GetSubMenu
(
int nPosMenu, // (In) Position in menu of
desired submenu
) const
{
HMENU hMenu = nPosMenu < 0 ? m_hMenu : ::GetSubMenu( m_hMenu,
nPosMenu );
return hMenu;
}

>
>Is it possible to change the state or is it a constraint to Document/view
>architecture based applications?

I write only dialog-based applications, but doubt such a constraint
might exist. But the following comment from my code seems relevant:
// Effects of CheckOrUncheckItem are visible only if the function
is called in
// response to a WM_INITMENU or WM_INITMENUPOPUP message



>
>please help thanks in advance
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com