?
Solved

Updating listbox when file is deleted

Posted on 2005-03-31
11
Medium Priority
?
236 Views
Last Modified: 2010-04-05
I have a listbox (specifically a sunisoft file list box) that shows the files in a dir.  In my testing I've found that when I delete the files in the dir its pointed at using explorer, the list doesnt update

Should I use a timer?  that seems like an imperfect solution at best.   Any suggestions?
0
Comment
Question by:hibbidiji
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13670304
Sounds like you need to do some sort of refresh method I guess.
Because your program doesnt actually delete the file itself, you will need to monitor it on a timer event I would think.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13670316
I wonder if there is some sort of a windows message you could be polling for.
If you have 2 explorer windows open pointing to the same directory, and you delete a file from one, it automatically refreshes the other.
There might be a windows call somewhere here you could take advantage of.
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13670324
Thats what I'm hoping for (though I wouldnt know how to poll for the message even if we knew what it was)  :)

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13670354
he he .. unfortunately neither do I, but hopefully my suggestion might be seen by someone who remembers how to do it and can give you the code.
I wish I knew more API stuff, but my knowledge in this area is pretty much non existant. Probably because I have no use for it these days.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13670367
I found one possible link that might help

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_11428379.html

also do a search for "windows explorer refresh" here at EE. Might be a few more links that can help
0
 
LVL 11

Accepted Solution

by:
ZhaawZ earned 800 total points
ID: 13670811
I think TShellChangeNotifier (from 'Samples' tab) could help you to monitor some directory.
0
 
LVL 22

Assisted Solution

by:Mohammed Nasman
Mohammed Nasman earned 200 total points
ID: 13670836
Hello

Drop TShellChangeNotifier from Samples tab, set the Root property to the folder you would to monitor, then call update method of the FileListBox

procedure TForm1.ShellChangeNotifier1Change;
begin
  FileListBox1.Update;
end;

HTH

Regards,
Mohammed
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13670848
sorry ZhaawZ, I didn't see your comments when I open the questions
0
 
LVL 27

Expert Comment

by:BigRat
ID: 13670858
I load files into my IDE but of course some idiot might edit or delete them outside. To monitor this, like Delphi does, I use a directory monitor. This sends me an event when anything changes in any of the directories from which I have loaded files. I'm currently using TDirMon (see Torry's pages) from Juan Carlos Molinos, which I've had to modify. There is another from Francois Piette which I have not yet tried out.

One problem I've found is that the components are very heavy, starting threads to pick up Windows events, but it does work.

I popup a message box saying that the file has changed and whether they want a reload. In your app, I'd popup a box warning of the change and then simply reload the list box.

HTH
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 13673541
check this thread
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21226302.html

there is a link to a unit that implements exactly what you need, something like a Directory Watcher, but without using a Timer
0
 
LVL 1

Author Comment

by:hibbidiji
ID: 13676268
Thanks guys.  Excellent answer.  worked first time
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question