Results 1 to 10 of 10

Thread: Can i build controls with Begin End of Form Initial Parameters ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2013
    Location
    Brazil
    Posts
    28

    Unhappy 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?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2014
    Posts
    321

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2013
    Location
    Brazil
    Posts
    28

    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)

  4. #4
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    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

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2013
    Location
    Brazil
    Posts
    28

    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.

  6. #6
    Frenzied Member Gruff's Avatar
    Join Date
    Jan 2014
    Location
    Scappoose Oregon USA
    Posts
    1,293

    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

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2013
    Location
    Brazil
    Posts
    28

    Re: Can i build controls with Begin End of Form Initial Parameters ?

    Quote Originally Posted by Gruff View Post
    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)?

  8. #8
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2013
    Location
    Brazil
    Posts
    28

    Re: Can i build controls with Begin End of Form Initial Parameters ?

    Quote Originally Posted by Arnoutdv View Post
    The answer to the last question was already given to you in your previous thread:
    http://www.vbforums.com/showthread.p...B6-application
    But... not successful

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Can i build controls with Begin End of Form Initial Parameters ?

    Quote Originally Posted by Rumblefish View Post
    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
  •  



Click Here to Expand Forum to Full Width