Screen flicker when changing Image.Picture source on UserForm

  • Thread starter Thread starter Paul Martin
  • Start date Start date
P

Paul Martin

Hi All

On a UserForm, I have an Image control whose Picture property changes
according to the user's selection. The image is a GIF copy of a
chart. As the image loads, it flashes across the form, and turning
off Application.ScreenUpdating has no effect. I have used Me.Repaint,
to force the new image to appear (previously it wasn't). I would like
the image to appear without the 'flash' or flicker, if possible.

Any suggestions are appreciated.

Paul Martin
Melbourne, Australia
 
Hi Paul,

Try adding an identical image control directly on top of the
existing control.
Then in your code, load the hidden control with the new image,
followed by making the top control not visible and the bottom one
visible.
I've done something similar with text boxes on a form, using the mouse
move event and the results are impressive.

Regards,
Jim Cone
San Francisco, USA
 
application.screenupdating wonly affects excel's windows.
try lockwindowupdate api

as in:
Option Explicit
Private Declare Function FindWindow Lib "user32.dll" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function LockWindowUpdate Lib "user32.dll" ( _
ByVal hwndLock As Long) As Long

Dim b As Boolean

Property Get hwnd() As Long
Static h&
If h = 0 Then
h = FindWindow(IIf(Val(Application.Version) < 9, _
"ThunderXFrame", "ThunderDFrame"), Me.Caption)
End If
hwnd = h
End Property

Private Sub UserForm_Click()
LockWindowUpdate Me.hwnd
If b Then
Me.Image1.Picture = LoadPicture("c:\img1.jpg")
Else
Me.Image1.Picture = LoadPicture("c:\img2.jpg")
End If
b = Not b
LockWindowUpdate 0&
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Paul Martin wrote :
 
how many layers can you use? This sounds like a lot of fun if fade in and out
by several layers.
 
Only two controls are used.
The new image goes in the one that is not visible, then the visible
property of both is switched.

Jim Cone
San Francisco, USA
 
Back
Top