IonicWind Software

IWBasic => GUI Central => Topic started by: LarryMc on April 09, 2010, 10:26:41 PM

Title: menus in child windows
Post by: LarryMc on April 09, 2010, 10:26:41 PM
Working on the visual designer I was to the point of displaying the menu on the form displayed in the 'form editor' tab.

I put the normal menu commands right after the openwindow command; no menu displayed
I put the normal menu commands in the @IDCreate message handler; no menu displayed
I created a menu using the createmenu() functions in both the above places;; no menu displayed

Created a test program with my menu and it worked fine with the menu code i was using.

Kept trying things for a couple of hours; ; no menu displayed

Started striping code out.
Got it down to where all my handle had was was a closewindow in the handler; no menu displayed

Took all my style flags out when opening the window; no menu displayed

change the parent to 0;  got my menu.

So, I learned the hard way that non-mdi child windows can't display menus.

Anyone know a work-around?

If not then I have to open up the positioning bucket of worms i was trying to avoid and draw a dummy menu bar.

LarryMc
Title: Re: menus in child windows
Post by: Ionic Wind Support Team on April 09, 2010, 10:58:39 PM
You should read the Windows SDK documentation, search for the WS_CHILD style.  Child windows cannot have menus.  MDI child windows don't really have menus either, they just replace the MDI frame main menu when activated. Only top level windows are allowed to have a menu.

Yes it is confusing, but that is Windows.  Consider the CreateWindow and CreateWindowEx API functions.  They have an HMENU parameter that serves two purposes, if it is a top level window you can pass it a menu handle, but if it is a child window then the parameter is used for the child window identifier, and passing it a menu handle would set the identifier to the integer value of the handle. 

So no, there isn't work around.
Title: Re: menus in child windows
Post by: LarryMc on April 10, 2010, 04:32:26 AM
Thanks

LarryMc