Results 1 to 9 of 9

Thread: [RESOLVED] need help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    5

    Resolved [RESOLVED] need help

    i'm trying to build a picture database , i want vb to track a specified folder so when u add new pictures to that folder it will automaticly add it to the database. is that possible in vb6?

    thanx.

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: need help

    Welcome to VB Forums

    There are two possible ways i can think of... one is to have a timer every minute to check the folder for any changes. The other is to use an API. The timer method could possibly use the filelistbox control, and then every minute check the total number of items, if its different then it means something was added or removed. The API method would be something like this (from the API Guide)
    VB Code:
    1. Private Const FILE_NOTIFY_CHANGE_ATTRIBUTES = &H4
    2. Private Const FILE_NOTIFY_CHANGE_DIR_NAME = &H2
    3. Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
    4. Private Const FILE_NOTIFY_CHANGE_SIZE = &H8
    5. Private Const FILE_NOTIFY_CHANGE_LAST_WRITE = &H10
    6. Private Const FILE_NOTIFY_CHANGE_SECURITY = &H100
    7. Private Const FILE_NOTIFY_CHANGE_ALL = &H4 Or &H2 Or &H1 Or &H8 Or &H10 Or &H100
    8. Private Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
    9. Private Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    10. Private Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    11. Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    12. Private Declare Function ResetEvent Lib "kernel32" (ByVal hEvent As Long) As Long
    13. Private Sub Form_Load()
    14.     'KPD-Team 2000
    15.     'URL: [url]http://www.allapi.net/[/url]
    16.     'E-Mail: [email][email protected][/email]
    17.     Dim Ret As Long
    18.     'Set the notification hook
    19.     Ret = FindFirstChangeNotification("C:\", &HFFFFFFFF, FILE_NOTIFY_CHANGE_ALL)
    20.     'Wait until the event is triggered
    21.     WaitForSingleObject Ret, &HFFFFFFFF
    22.     MsgBox "Event Triggered for the first time"
    23.     'Reactivate our hook
    24.     FindNextChangeNotification Ret
    25.     'Wait until the event is triggered
    26.     WaitForSingleObject Ret, &HFFFFFFFF
    27.     MsgBox "Event Triggered for the second time"
    28.     'Remove our hook
    29.     FindCloseChangeNotification Ret
    30. End Sub
    But this will pause your program until it finds a change.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    5

    Re: need help

    thank you for reply,

    i think i'm going to try timer first but i cannot find filelistbox control in the component or Refrences. can you help where i can get that control from plz.

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: need help

    its in the VB controls... its icon is white with lines on it (it looks like a textfile)

    Just a quick example on how you might use it
    VB Code:
    1. Private Sub Form_Load()
    2.     File1.Path = "C:\"
    3.     Timer1.Interval = 60000
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7.     Static PrevListCount As Long
    8.     File1.Refresh
    9.     If File1.ListCount <> PrevListCount Then
    10.         'go through all the files to check what was added
    11.         PrevListCount = File1.ListCount
    12.     End If
    13. End Sub
    Attached Images Attached Images  

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    5

    Re: need help

    thank you very much, i think its clear to me now.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    5

    Re: need help

    hi again, i made a little progress now, i want to group some pictures in folders. is there any control allow me to track folders creation? actualy i have too much folders with images so i decided to make the program to group my pictures by folder name.

    thank you.

  7. #7
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: need help

    You can use a ImageListBox inside your program.
    Select ProjectMenu-->Components-->MicrosoftComponets Control
    Please mark you thread resolved using the Thread Tools as shown

  8. #8
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: need help

    Or the DirListBox, its the control next to the FileListBox (its got the icon of the folder)

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    5

    Re: need help

    thank you guys.

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