Results 1 to 5 of 5

Thread: What the hey!?

  1. #1

    Thread Starter
    Fanatic Member Illspirit's Avatar
    Join Date
    Mar 2001
    Location
    Blackpool, England
    Posts
    815

    just an idea...

    I did this by adding a bunch of menu items a design time and unchecking their visible property. Then at runtime, when i wanted to 'add' one, i simply changed one of the item's caption and made it visible.

  2. #2
    AIS_DK
    Guest
    Or you could make a menuitem collection.

    Under the forms menueditor, simply add an element, and set its index to 0.

    When you then scan the favorites directory, you simple add new menuitems to the collection. One for each file found.

    Code:
    ...
    if i>0 then
       load objFavorites(i)
    end if
    
    objFavorites(i).caption = Filename
    objFavorites(i).visible = true
    
    i=i+1

  3. #3
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75
    Hmm... that works but now I'm having trouble adding subdirectories and such. First, I don't know how to add subdirectories to a objfavorites(index) and then there is that other problem of looping through every directory in the favorites directory and adding every directory in that and so on endless loop kinda thing. I think I can figure that second problem out, but for adding submenus I'm clueless. Any help is appreciated.

    Thanks!

  4. #4
    AIS_DK
    Guest
    Well vb comes to a direct holdt, when you try to create fancy things like dynamically added submenuitems.

    To fix your problem, you would have to take over the creation of menuitems from VB, which means subclassing and alot of API writing.

  5. #5
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    I collected this on this forum, it may help:

    Create a menu called mnuFolder with the caption Folder.
    Than create a submenu called mnucontents with the caption Contents.

    And add this code:

    Code:
    Private Sub Form_Load()
        On Error Resume Next
        Dim FileLister
        FileLister = Dir$("C:\*.*")
        Do While Len(FileLister)
            Load mnucontents(mnucontents.Count)
            MyInt = mnucontents.Count - 1
            mnucontents(MyInt).Caption = FileLister
            FileLister = Dir
        Loop
    End Sub

    Then to find out path to user's favourites:

    Code:
    Option Explicit
    
    Private Declare Function SHGetFolderPath Lib "shfolder" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal pszPath As String) As Long
    
    Private Const CSIDL_FAVORITES As Long = &H6 ' <user name>\Favorites
    
    Private Sub Command1_Click()
    Dim Path As String
    
    Path = String(260, 0)
    'Path must have a length, And 260 is large enough To contain any path
    
    SHGetFolderPath 0, CSIDL_FAVORITES, 0, 0, Path
    
    MsgBox Path
    End Sub

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