-
May 26th, 2014, 10:21 AM
#1
Thread Starter
Junior Member
Can i build controls with Begin End of Form Initial Parameters ?
Hi guys!
I'm looking some practical way to create vb-menus without a lot a API's or components.
When i open the form trough the notepad, i can see some structure apparently easy to write.
Like:
Begin VB.Menu MyMenu
.Caption = "Menu"
End
It seems to be easy to use... but i cant use this code inside any class. Can i use this standard by some way?
-
May 26th, 2014, 10:23 AM
#2
Hyperactive Member
Re: Can i build controls with Begin End of Form Initial Parameters ?
just one question instead of hard coding all why not use build in controls ? that i dont understand why people do allot of coding
-
May 26th, 2014, 10:31 AM
#3
Thread Starter
Junior Member
Re: Can i build controls with Begin End of Form Initial Parameters ?
I don't know if i thinking on the same thing...
But, how would this be? (To create a menu)
-
May 26th, 2014, 10:58 AM
#4
Re: Can i build controls with Begin End of Form Initial Parameters ?
As I recall you have to have at least one Item in a menu with an index value at design-time.
Then at run-time you can add or remove menu items from that menu.
How this works is very similar to creating a control array at design-time.
Each menu item has to have an index value.
FileMenu(0), FileMenu(1), Etc...
The cool thing about this is that your FileMenu_Click event returns this index value so you know which item was clicked.
I've used this method to add or remove last used documents from the File menu.
The item could even be a separator bar.
So basically if you have a menu structure in place at design-time with at least one menu item defined in every part of the structure you can happily edit items in that structure.
If you want to do anything fancier then you need the API tools.
Example:
Top Menu item defined at design-time called "File"
the menu name is "MainMenu" and the index is 0.
Also at design-time create a sub-menu under File called "Open"
The menu name is "FileMenu" and the index is 0.
At run-time.
Code:
Private Button1_Click()
Dim i as integer
Load MainMenu(1)
MainMenu(1).Caption = "Edit"
Load MainMenu(2)
MainMenu(2).Caption = "View"
For i = 1 to 3
Load FileMenu(i)
FileMenu(i).Caption = "Save " & i
Next i
End Sub
Last edited by Gruff; May 26th, 2014 at 11:33 AM.
Burn the land and boil the sea
You can't take the sky from me
~T
-
May 26th, 2014, 11:14 AM
#5
Thread Starter
Junior Member
Re: Can i build controls with Begin End of Form Initial Parameters ?
By... only using this way, it's hard or impossible to add sub-itens or multiple menu level's.
-
May 26th, 2014, 12:35 PM
#6
Re: Can i build controls with Begin End of Form Initial Parameters ?
True. That is why some prefer to use the menu API tools.
BTW if you use the API tools to create menus/sub menus always remember to destroy the menus when you are done with them.
They take up more resources than you would think and I do not believe the memory they use is automatically freed up.
Burn the land and boil the sea
You can't take the sky from me
~T
-
May 27th, 2014, 06:58 AM
#7
Thread Starter
Junior Member
Re: Can i build controls with Begin End of Form Initial Parameters ?
Originally Posted by Gruff
True. That is why some prefer to use the menu API tools.
BTW if you use the API tools to create menus/sub menus always remember to destroy the menus when you are done with them.
They take up more resources than you would think and I do not believe the memory they use is automatically freed up.
Do you know someone (API)?
-
May 27th, 2014, 07:38 AM
#8
Re: Can i build controls with Begin End of Form Initial Parameters ?
The answer to the last question was already given to you in your previous thread:
http://www.vbforums.com/showthread.p...B6-application
-
May 28th, 2014, 06:27 AM
#9
Thread Starter
Junior Member
Re: Can i build controls with Begin End of Form Initial Parameters ?
Originally Posted by Arnoutdv
But... not successful
-
May 28th, 2014, 07:50 AM
#10
Re: Can i build controls with Begin End of Form Initial Parameters ?
Originally Posted by Rumblefish
But... not successful
What do you mean? Did you apply that example to your project? Did you get errors? Do you UNDERSTAND the API?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|