Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a filelistbox when dir contents change 1

Status
Not open for further replies.

murrayja

Programmer
May 6, 2000
90
US
I am using a filelistbox to display a list of files for a user to choose from. Is there a mechanism whereby I can be alerted when the contents of the directory change say, by a user adding or deleting files from the displayed directory?
regards
jim murray
 
You could always add a timer and refresh the control periodically.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Const WM_SETREDRAW = &HB

Private Sub Timer1_Timer()
SendMessage Me.hwnd, WM_SETREDRAW, 0, 0
File1.Refresh
SendMessage Me.hwnd, WM_SETREDRAW, 1, 0
End Sub

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Actually I think I found a better solution, take a look at the FindChangeNotification API. Basically you monitor the folder for changes and when a change occurs call the File1.Refresh method.

Here's link to an example:


"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Bizarre. I know we've posted FindFirstChangeNotification solutions in this forum in the past (I've posted at least two), but I can't seem to find any of them. All I can find is my code in thread222-719707, which contains synchronous and asynchronous versions of a ReadDirectoryChangesW solution (which may not becompletely appropriate for this question, but does have the advantage of provding the exact file change that occurred and the name of the file the change occurred to)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top