Results 1 to 12 of 12

Thread: Menus at Runtime????

  1. #1

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302

    Question Menus at Runtime????

    i am making a web browser, and i am attempting to construct a favourites type list. I have a form with a textbox on it and a command button, when the user types in a fave URL into the txt box and clicks the button, what i want to happen is that URL gets added to a menu at runtime.
    Get what i am saying?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  2. #2
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    Create a blank menu and set visible to false, set the index property to 0 and then at runtime you can use the load statement and set the properties. ie.

    Code:
    load mnuX(1)
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

  3. #3

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    Hmmm i ahve a menu already setup, so the user can add a fave site whenever they want to, maybe the fave list can be saved to a text file?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  4. #4
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    Sounds like a good idea
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

  5. #5

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    But how would i do this?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  6. #6
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    You can open a text file to append line by line with:

    Code:
    dim intX as integer
    
    intX = freefile 'tells you the next free file handle
    
    open "Path" For Append As #intX
    
    Print #intX, URL_Info_To_Add
    
    close #intx
    Then comes the reading bit:

    Code:
    dim intx as integer
    
    intx = freefile
    
    open "Path" For Input as #intX
    
    Input #filenumber, Variable_To_Hold_Data
    
    close #intX
    Then you'd need some string manipulation to get the URL's out of the text file. I tend to use the split function to get the data into an array of values and loop thru them.
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

  7. #7

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    explain more?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  8. #8
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    OK.......... each time they add to faves you'll want to save the details in the text file with the following type of code and add to the menu with the load statement:

    Code:
    dim intX as integer
    
    intX = freefile 'tells you the next free file handle
    
    open "Path" For Append As #intX
    
    Print #intX, URL_Info_To_Add
    
    close #intx
    then when your app loads you'd use the other code to load the text file to memory and then using string manipulation pull out the page title and the url and create your menus. I'm off home now post back a specific questions and i'll answer them when i get in about an hour.
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

  9. #9

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    i get what u mean, but i have no idea on how to do this : -

    then when your app loads you'd use the other code to load the text file to memory and then using string manipulation pull out the page title and the url and create your menus. I'm off home now post back a specific questions and i'll answer them when i get in about an hour.

    i am a newby programmer need a little help
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  10. #10

    Thread Starter
    Hyperactive Member gamezfreakuk's Avatar
    Join Date
    Mar 2002
    Location
    Nottingham, UK
    Posts
    302
    heh?
    Gamezfreak
    Visual Basic 6 Enterprise Edition
    Borland C++ Builder 6 Enterprise Edition

  11. #11
    agent_008
    Guest

    use Ubound

    Let's take, that you have a menu, called "Favorites", and you want to add items to it:
    First, you'll have to find the next free index, and then load new menu item; then assign the text1.text as a caption to that menu.

    load mnuFavorites(mnuFavorites.UBound+1)
    mnuFavorites(mnuFavorites.UBound+1).Caption = text1.text

    For responding to the click event, you can use the index of the new menu items.
    Try it

  12. #12
    Hyperactive Member -=XQ=-'s Avatar
    Join Date
    Mar 2002
    Location
    Liverpool, England, UK
    Posts
    278
    I think it's getting the data from the file that's the prob rather than creating the menu's at runtime. On the form's load event you need to read from the text file:

    Code:
    private sub form_load
      dim intX as integer
      dim intY as integer 'keep count of the menu items
      dim strTemp as string
    
      intx = freefile
      intY = 1 'as the menu there is already 0
      open "PATH" for input as #intx
    
      do until eof(intx) 'checks for the end of the text file.
        input #intx, strTemp 'reads line by line of the text file
        load mnuFav(intY)
        mnuFav(intY).caption = strtemp
      loop
    
      close #intX
    end sub
    See ya later,

    -=XQ=-

    "Reality is merely an illusion, albeit a very persistent one. "
    - Albert Einstein (1879-1955)
    This is the coolest site ever!!!

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