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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a form window

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
US
This probably has a blindingly obvious answer, but I'm having trouble thinking of what it could be.

I'm running a program that's getting a lot of information from a database, and while it's getting that information, the form window itself will take on the appearance of whatever was most recently on top of it...for example, if I were to open a webpage, whatever portion of the page was located over the form would still be visible, in the shape of the delphi form.

I'm assuming that this is because the form window is for some reason not refreshing itself while the database connection is running. This is because if I have something on the form that changes (memofields getting new lines from the data, progress bars counting out time, etc), those components, and only those components, will return to normal each time they get changed.

What do I need to make changes to in order to stop this behavior?
 
It's hard to tell what's exactly necessary from the description, but what it sounds like is that the long process of getting the information from the database is keeping the system away from painting the form (or probably other tasks).

I'd say, try one of these things that suits the app best.
1) If the database process is something you have control of, throw Application.ProcessMessages into the loop somewhere. If this doesn't do the trick, call the "OnPaint" or "refresh" or whatever the keyword is which paints the screen.
2) In the absence of that, you could put the database process into a thread.

Any long running process always requires either one or the other, or things like you notice will happen (or like the last app I did that had this problem, wouldn't respond to ANY form event unless I did the above).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top