Link to home
Start Free TrialLog in
Avatar of erictankok
erictankok

asked on

1401 Invalid menu handle error when creating window...

Hi,

When I attempt to create a pop up window from a child window, I am getting a "1401 Invalid menu handle" error and the window failed to be created.

The following is the code segment. I am using ATL classes for all windows.

CRect r;
r.SetRect(0, 0, 300, 300);
mMyWnd.Create(NULL, r, "My Window", WS_VISIBLE | WS_POPUP | WS_CAPTION, 0, IDW_MY_WND);

The above code resides in a child window.

I tried setting the first parameter (parent handle) to the child window's m_hWnd, but am still getting the same 1401 error.

Question: Can I create a pop-up window from a child window?

Otherwise, what am I doing wrong here? I am a newbie when it comes to windows programming.

Thanks.
Avatar of nonubik
nonubik

The error appears because it seems that IDW_MY_WND is not a valid menu resource ID. I'm not sure what type is the mMyWnd object nor its Create method. If you can provide more code and mMyWnd's type, it will be helpfull.
Avatar of erictankok

ASKER

I just found the reason why it didn't work for me.

By removing IDW_MY_WND from the Create(...) method and just using the default value of 0, I am able to create the window.

mMyWnd is a class that extends CWindowImpl<CMyWnd>. CWindowImpl is a ATL class.

And the Create(..) method is a class method of this CWindowImpl class.

If the window is a child window, using IDW_MY_WND did not result in the 1401 error. However, for a popup window, I cannot use IDW_MY_WND as the nID parameter.

Don't know the reason why though.

ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial