|
-
February 29th, 2000, 11:59 AM
#1
Dialog Form not showing up completely
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.
-
February 29th, 2000, 12:10 PM
#2
Re: Dialog Form not showing up completely
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
[email protected]
The best way to escape a problem, is to solve it.
-
February 29th, 2000, 12:21 PM
#3
Re: Dialog Form not showing up completely
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?
-
February 29th, 2000, 12:37 PM
#4
Re: Dialog Form not showing up completely
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
[email protected]
The best way to escape a problem, is to solve it.
-
February 29th, 2000, 12:43 PM
#5
Re: Dialog Form not showing up completely
What do you mean by 'this can't be so hard'?
-
February 29th, 2000, 12:46 PM
#6
Re: Dialog Form not showing up completely
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
[email protected]
The best way to escape a problem, is to solve it.
-
February 29th, 2000, 01:02 PM
#7
Re: Dialog Form not showing up completely
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.
-
February 29th, 2000, 01:12 PM
#8
Re: Dialog Form not showing up completely
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.
-
February 29th, 2000, 01:18 PM
#9
Re: Dialog Form not showing up completely
Ok, I'm new to this. What exactly is DoEvents and what do i do with it? (no pun intended.)
-
February 29th, 2000, 01:23 PM
#10
Re: Dialog Form not showing up completely
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...
-
February 29th, 2000, 01:48 PM
#11
Re: Dialog Form not showing up completely
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)
-
February 29th, 2000, 02:34 PM
#12
Re: Dialog Form not showing up completely
DoEvents did the trick. Learn something new everyday! Thanks everyone.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|