There are two modes for progressbar. One is normal 0 - 100% mode. The other
is marquee.
Marquee mode is handy when you dont know how long an operation is going to
take - such as a database query.
The marquee is a blue thing than bounces back and forth along the frame.
You get two styles, smooth and not smooth (not smooth being brick looking)
When I tried to implement Marquee mode a while ago, the window wouldn't
refresh for me.
It would look like it was stuck and never move.
If I let it run for 30 seconds or so and dragged a window overtop of Excel,
then the marquee changed positions. If I dragged it on and off really
quickly then I could tell the marquee was working. It had something to do
with the window refreshing / updating - I didn't get to the bottom of it.
Since Marquee mode is such a nice indicator for users, I think I'll take
another shot soonish.
--
Rob van Gelder -
http://www.vangelder.co.nz/excel
"Jamie Collins" wrote in message
oups.com...
Rob van Gelder wrote:
Jamie, how did you get Marquee working? It wouldn't refresh properly
for me.
Hi Rob,
Refresh? Do you mean change the style of an existing window from smooth
to marquee? I only know how to set the style with CreateWindow. Snippet
expanded:
Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function CreateWindowEx _
Lib "user32" Alias "CreateWindowExA" _
(ByVal lngStyleEx As Long, ByVal lpClassName As String, _
ByVal lpWindowName As String, ByVal lngStyle As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hWndParent As Long, _
ByVal hMenu As Long, ByVal hInstance As Long, _
lpParam As Any) As Long
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Declare Function DestroyWindow _
Lib "user32" (ByVal hwnd As Long) As Long
Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_CHILD As Long = &H40000000
Private Const PBS_SMOOTH As Long = 1
Private Const PBS_MARQUEE As Long = 8
Private Const WM_USER As Long = &H400
Private Const PBM_SETPOS As Long = WM_USER + 2
Private Const PROGRESS_CLASS_NAME As String = _
"msctls_progress32"
Sub test()
Const lngLeft As Long = 1
Const lngTop As Long = 5
Const Width As Long = 190
Const Height As Long = 10
Const SmoothBackground As Boolean = False
Dim m_hProgress As Long
' Get hWnd for Excel's statusbar
Dim hwnd As Long ' Get hWnd for Excel's statusbar
hwnd = FindWindow(vbNullString, Application.Caption)
hwnd = FindWindowEx(hwnd, 0, "EXCEL4", vbNullString)
' Progressbar's style
Dim lngStyleProgress As Long
lngStyleProgress = WS_VISIBLE Or WS_CHILD
If SmoothBackground Then
lngStyleProgress = lngStyleProgress Or PBS_SMOOTH
Else
lngStyleProgress = lngStyleProgress Or PBS_MARQUEE
End If
' Create progressbar window
m_hProgress = _
CreateWindowEx(0, PROGRESS_CLASS_NAME, _
vbNullString, lngStyleProgress, lngLeft, _
lngTop, Width, Height, hwnd, 0, 0, 0)
' Show progress
SendMessage _
m_hProgress, PBM_SETPOS, _
66, 0
DoEvents
' Pause 2 seconds
Sleep 2000
' Destroy progressbar window
DestroyWindow m_hProgress
End Sub
Jamie.
--