Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dynamic Menu Creation in VB?

Started by Promit Jun 11, 2002 at 7:25 PM 5 replies 250+ views
Original Post
Promit
Promit
I''m sort of familiar with dynamic control creation in VB. I found out earlier today, however, that I can''t control menus. The problem is as follows: I have a menu, lets call it mnuFile. This should have submenus such as mnuFileLoad, mnuFileSave, etc. Now suppose I want to create a Recent file list, and I need to create a new menu for this. After declaring an object As New Menu, how do I set it as being under mnuFile? How do I set it''s position, so that it doesn''t end up under "Exit" or something? ____________________________________________________________ Direct3D vs. OpenGL
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
ragonastick
ragonastick
Use the application wizard to set up a simple app with a recent file list (by default they have them). This shows how MS have done it. You might also be able to get it done using some API calls, look for code for adding pictures to menu items (I know that exists at least), and you will probably get a good lead.

Trying is the first step towards failure.
Trying is the first step towards failure.
Promit
Promit
The AppWizard uses a really crummy hack to do it. The 4 recent files are simply 4 menu items(created at DESIGN TIME) that start with .Visible = False. This is not what I want at all. I need to set up a whole new menu from nothing, and I don''t want to have to subclass my window to do it.

Of course, there are hacks I can use to avoid subclassing, but aren''t there any clean ways to do this?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Promit
Promit
How come everytime I need to know something, nobody ever knows? Is it cause it''s VB?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
ragonastick
ragonastick
Oh. Good on MS for that bit of brilliance.

Alright, then. I assume you have tried creating a menu item with an index of 0 (not blank). Then in code:


Load mnuMyMenu(1)

mnuMyMenu.Caption = "Blah"
mnuMyMenu.Visible = True


If you have tried that, then what was the error message?

Trying is the first step towards failure.
Trying is the first step towards failure.
ragonastick
ragonastick
Oh, and as for the order of the menu. What I would seriously consider doing is to dynamically create the *entire* menu, even the bits which you aren''t going to change. Then, to change the order, you can just change the caption of the items yourself and have a nice elegant handler for clicks.

Trying is the first step towards failure.
Trying is the first step towards failure.
Promit
Promit
I was aware of using a control array of menus, but I was kind of hoping there''d be a rreally f''ing easy way, which is what I''ve come to expect from Vb as compensation for sucking at everything else In any case, I guess I''ll have to go with that.

____________________________________________________________
Direct3D vs. OpenGL
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.