View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Screen flicker when changing Image.Picture source on UserForm


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 :

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