|
-
Jun 22nd, 2003, 11:44 PM
#1
Thread Starter
Frenzied Member
Event sequencing problem: Need Expert help.
This is difficult to describe and I hope some serious guru can help me.
My application is erasing an image in a PictureBox due to some control flow or event sequencing problem. I suspect that event triggering requires some Windows OS activity, probably using interrupt logic. I also suspect that the OS activity is not fast enough to prevent certain sequencing problems.
I have an application which draws an image in a PictureBox. While the Draw Subroutine is active, Focus gets set to the PictureBox, which seems to be reasonable.
The PictureBox Lost Focus Event is used to trigger activity which erases the picture.
To prevent the obvious problem, the Draw Subroutine sets a Boolean variable (DrawingInProgress) to True, and the PictureBox Lost Focus Subroutine tests that Boolean variable, intending to avoid erasing the image at the wrong time.
After the Draw Subroutine is finished generating the image, it sets focus to a Command Button, causing the PictureBox Lost Focus Subroutine to activate. After setting Focus to the Command Button, the Draw Subroutine resets DrawingInProgress to False.
I expected the above code sequence to avoid erasure of the image, but it did not.
I wrote some debugging code which stored data in an array to indicate the order of code execution and event triggering. The data indicated that the PictureBox Lost Focus Subroutine activated after the Boolean variable was reset to False.
The following suggests the code being executed.
VB Code:
Private Sub FractalPainter()
[b]. . .[/b]
DrawingInProgress = True
‘Code to generate the image using PSet
cmdShuffle.SetFocus
‘A few lines of code
DrawingInProgress = False
‘A few lines of code
End Sub
[b]. . .[/b]
Private Sub pixFractal_LostFocus()
If DrawingInProgress Then
Exit Sub
End If
‘Code which erases image
End Sub
The Lost Focus Subroutine finds the Boolean to be false and erases the image.
Does anybody understand my problem?
Does anybody have a suggestion about what to do?
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
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
|