Click to See Complete Forum and Search --> : Dialog Form not showing up completely


gknierim
February 29th, 2000, 10:59 AM
I have made a dialog that contains an animation control so that the user knows that they are retrieving records from the database. I have a problem, however, that when I load the dialog, while it is processing the records, the dialog doesn't show up(on top I guess). All I see is the transparent outline of the dialog form but no form. Any ideas or suggestions on what might be wrong. Is the dialog losing focus? I have also tried setting focus on LostFocus and Activate events and to no avail.

Thanks in advance.

Cakkie
February 29th, 2000, 11:10 AM
My guess is that you are using a loop to retrieve the records from the db. When you show the form, the processing of the data (wich is looping) causes other tasks to wait until it finishes. The painting of the form happens when the processing is done. You can do two things.

a) If the retrieveing of the data is in (or called in) form_load, move it to a timer, wich activates after like say 200ms. When it does, first set the interval to 0, preventing the loop beeing executed on and on. So when the form is loaded it is displayed, then the timer is activated and the stuff you need to do is done.

b) When you call the form when the processing is already busy, explicitly add a myForm.refresh on the next line. This will force the program to refresh the form, and not resulting in a half shown form.

Hope this is of any help

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

gknierim
February 29th, 2000, 11:21 AM
Ok, I tried the 2nd way but it looks like both ways will produce the same result. The form refreshes but the AVI doesn't play because there is processing (retrieving records...by the way, I am retrieving 2400 records) going on. I would like to use a progress bar perhaps that will track the loading at realtime. Is this possible?

Cakkie
February 29th, 2000, 11:37 AM
this can't be so hard, add a progressbar to the form (found in Microsoft Windows Common Controls (mscomctl.ocx)

dim NumberOfRecords as integer
dim CurrentRecord as integer
' this is used to keep track of the current record if not using a for loop

' code here to get number of records to retrieve

progressbar1.min = 0
progressbar1.max = NumberOfRecords

' start of loop here

' do your stuff here to retrieve the data
' probably with a for or DO statement

' if using a for loop, you can omit the next line, and replace progressbar1.value = currentrecord with the val used in the loop (mostly t ot i)

CurrentRecord = CurrentRecord + 1
progressbar1.value = currentrecord
progressbar1.refresh ' force refresh, otherwise you won't have much of an animation
' end of loop here





Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

gknierim
February 29th, 2000, 11:43 AM
What do you mean by 'this can't be so hard'?

Cakkie
February 29th, 2000, 11:46 AM
just kidding, i meant that the solution for this problem can't be very hard to find. It might however get you some extra porgramming, but it's probably done in just a few minutes, without using very advanced functions

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.

gknierim
February 29th, 2000, 12:02 PM
Ok, thats what I thought. I tried the progress bar and the same kind of thing happens except that I see the progress bar moving. I'm comtemplating not using a progressbar or helpful dialog and possibly just changing the mousecursor. The problem is that I can't really Refresh the progressbar in the loop because it is on a different form than the one I am loading the records from and I'm not showing the form until I am done loading.

I hate to do just a mouse cursor but it may be the best solution since I'm retrieving so many records.

Kyle Burns
February 29th, 2000, 12:12 PM
Use DoEvents. Something to keep in mind while using DoEvents, however, is to disable buttons that would possibly put you into a recursion situation at the beginning of your routine and then once your processing is done, enable the buttons.

gknierim
February 29th, 2000, 12:18 PM
Ok, I'm new to this. What exactly is DoEvents and what do i do with it? (no pun intended.)

JimmyT
February 29th, 2000, 12:23 PM
DoEvents returns control to the operating system, allowing other processes to continue (such as showing your animation) while the longer process (the database search in this case) procedes. Take a look at the DoEvents function in the Language Reference for VB.

Good Luck...

Kyle Burns
February 29th, 2000, 12:48 PM
DoEvents returns control to the message processing loop. Hidden way beneath your code is a procedure that checks for messages in a loop and performs actions based on those messages. When your code is in a loop, the procedure cannot check for messages. Using DoEvents allows the message procedure to run. The main things to remember with DoEvents are:
1) If you have a procedure in Command1_Click() that starts retrieves your recordset and someone clicks that button again because "it's just going too slow", your record retrieval process will run another time. That is why I said to disable the control at the beginning of your procedure and reenable it at the end.
2)You'll give up some processing speed. I often increment a "counter" variable in my loop to only call DoEvents if the counter is divisible by a set number (e.g. 'If iCounter Mod 4 = 0 Then DoEvents' will only call DoEvents every fourth pass through the loop)

gknierim
February 29th, 2000, 01:34 PM
DoEvents did the trick. Learn something new everyday! Thanks everyone.