|
-
Nov 11th, 2001, 08:52 AM
#1
Thread Starter
Fanatic Member
Metafiles
I have a PictureBox that contains an Image control.
That Image control contains a WMF (Windows MetaFile).
The PictureBox also contains some Label Controls which I want to move around PictureBox.
When using the Move method, the moving Label control does flicker a lot. When setting the Image control's picture to nothing (or when setting it invisible), the flicker no longer occurs!
The flicker frequency also depends on the complexity of the WMF.
Help? I do not want the flicker!
-
Nov 11th, 2001, 04:30 PM
#2
Addicted Member
The only thing I can come up with is to draw the text contained in label(s) using the TextOut API.
-
Nov 11th, 2001, 04:51 PM
#3
There is an article on VBWorld that uses an API to remove flicker. The reason that you are getting the flickers is that everytime the label moves, the WMF redraws itself (WMF files are simply a series of steps that uses API calls to draw, like LineTo, Rectangle, etc. It is not a collection of pixels). After the WMF redraws, your label redraws. This causes flicker. Use the LockWindowUpdate() API call before you call Move:
Code:
LockWindowUpdate(pic1.hwnd)
Label1.Move(...)
LockWindowUpdate(0)
That should work.
Z.
-
Nov 13th, 2001, 03:49 PM
#4
Thread Starter
Fanatic Member
The LockWindowUpdat() API won't do it, because moving lables across its 'locked' parent won't update the screen!
Only when LockWindowUpdate(0&) is given, the screen will be updated.
But, now I found the solution: I made the Image Control invisible, loaded a WMF into it and used the PlayMetaFile() API directly to the Image Control's parent (=PictureBox).
Now it works smoothly without the flicker!
I had to do this workaround because in VB3, the PlayMetaFile() API doesn't recognize Aldus Placeable Metafiles...
-
Nov 13th, 2001, 04:16 PM
#5
If you do it correctly, LockWindowUpdate() will do the trick. It will draw everything, then when you unlock, its almost like BitBlt from a back buffer.
Z.
-
Nov 14th, 2001, 04:02 AM
#6
Fanatic Member
Not quite sure...
But would the lockwindowupdate also get rid of the speed drop when it's redrawing? Although you can't see it doesn't mean it doesn't get drawn, right? (theoretically)
And another problem: if any other window moves over the locked window, and LockWindowUpdate(0) is called, the whole desktop repaints
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 14th, 2001, 03:23 PM
#7
Thread Starter
Fanatic Member
Ho, guys, I know that my solution (using PlayMetaFile) is good.
But as a reaction to the LockWindowUpdate API, I wrote some code to demonstrate this behaviour - see the attachment.
Try moving the label without the checkbox clicked and then with the checkbox clicked. See the difference and say that I was right, not?
-
Nov 14th, 2001, 03:30 PM
#8
Fanatic Member
No VB here, but looking at your code, you only call LockWindowUpdate() once, I think what we meant was, call LockWindowUpdate before moving, then call again with 0& afterwards, and do this everytime you move
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 14th, 2001, 03:50 PM
#9
Thread Starter
Fanatic Member
This will implement continously a Refresh, which will encourage the flicker, not?
-
Nov 15th, 2001, 02:57 AM
#10
Fanatic Member
It refreshes only after everything has been drawn, thus reducing flicker theoretically. But it's better to have a backbuffer instead of using LockWindowUpdate, like I said, LockWindowUpdate could cause the whole desktop to be repainted, which causes even more flicker than without it
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Nov 15th, 2001, 03:27 PM
#11
Thread Starter
Fanatic Member
I do not use LockWindowUpdate() anymore because the whole desktop refreshes.
Alternatively, I use the WM_SETREDRAW message to the hWnd. This locks only the given window and after the lock everything is drawn very smoothly.
I use this message for simulating a multi-color ListBox using a PictureBox instead.
For smooth redrawing:
SendMessage (hWnd, WM_SETREDRAW, 0&, 0&) 'LOCK
'... do the redrawing in the hWnd
SendMessage (hWnd, WM_SETREDRAW, 1&, 0&) 'UNLOCK
'don't forget to use the Refresh method of the object
Last edited by Mad Compie; Nov 15th, 2001 at 03:30 PM.
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
|