You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
How do I create an icon animation in a statusbar panel? I would like to be able to simulate something like the Mirosoft Word 'Print Job Spooling' feedback loop to the user.
Any help appreciated.
Best regards
Andrew Lindsay
--------------
andrew dot lindsay at westnet dot com dot au
There's a demo here somewhere of putting a progress bar in a status bar.
But basically that just reduces to creating a child window of the status bar and 'doing something' with it.
When that child window is a progress bar control, you control it with the PBM_xxx messages or the ProgressBar_xxx macros.
Make that window 'something' upon which you do do animation. I'm not an animation guy, but don't you just 'display' an icon/animation file on that window?
You could get an animation effect by using a timer to cycle through a succession of images placed on the status bar with SB_SETICON.
Another way could be to place an image control displaying an animated icon over the status bar. Something like this..
Code:
#Compile Exe
#Dim All
#Include "Win32API.inc"
'#Resource "Sb Test.pbr" ' Un-rem if using icon from resource
' Not built-in (copied from CommCtrl.inc)
%SB_GETRECT = %WM_USER + 10
%SB_SETICON = %WM_USER + 15
'Equates
%IDC_IMAGEX = 1004
%ST_BAR = 1003
%BTN_Test = 1002
%LBL_LABEL1 = 1001
'------------------
CallBack Function DlgProc()
Local hIcon As Dword, x, y As Long
Local rcd, rc As Rect
Select Case As Long CbMsg
Case %WM_INITDIALOG
Case %WM_Paint ' deal with changed postion after resize
GetClientRect CbHndl, rcd
Control Send CbHndl, %ST_BAR, %SB_GETRECT, 1, Varptr(rc)
x = rcd.nRight - (rc.nRight - rc.nLeft) + 5
y = rcd.nBottom - (rc.nBottom - rc.nTop) + 2
MoveWindow GetDlgItem(CbHndl, %IDC_IMAGEX), x, y, 16, 16, 0
Case %WM_COMMAND
Select Case As Long CbCtl
Case %BTN_Test
If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
' Load from .ani file
hIcon = LoadImage(%NULL, "c:\Windows\cursors\hand.ani", %IMAGE_ICON, 16, 16, %LR_LOADFROMFILE)
' Load from animated icon in resource? Un-Rem next line
' hIcon = LoadImage(GetModuleHandle(""), "#100", %IMAGE_ICON, 16, 16, 0)
Control Send CbHndl, %IDC_IMAGEX, %STM_SETIMAGE, %IMAGE_ICON, hIcon
End If
End Select
Case %WM_SYSCOMMAND
If (CbWParam AND &HFFF0) = %SC_CLOSE Then
Dialog End CbHndl
End If
Case %WM_CLOSE
Case %WM_DESTROY
DestroyIcon hIcon
End Select
End Function
'------------------/DlgProc
Function PBMain()
Local hDlg As Dword
Dialog New 0, "Test", , , 200, 120, %WS_OVERLAPPEDWINDOW, To hDlg
Control Add Label, hDlg, %LBL_LABEL1, "Click 'Test' for Icon", 70, 15, 120, 20
Control Add Button, hDlg, %BTN_Test, "Test", 75, 45, 50, 15
Control Add StatusBar, hDlg, %ST_BAR, "", 0, 0, 0, 0
StatusBar Set Parts hDlg, %ST_BAR, 125, 600
StatusBar Set Text hDlg, %ST_BAR, 1, 0, "Status Bar" ' NB iPart is 1 based - API calls are 0 based
Control Add ImageX, hDlg, %IDC_IMAGEX, "", 0, 0, 0, 0, %WS_CHILD OR %WS_VISIBLE OR %SS_ICON
Dialog Show Modal hDlg, Call DlgProc
End Function
'------------------/PbMain
#IF 0
//Sb Test.rc Resource file
#define RT_ANIICON 22
100 22 C:\\Windows\\cursors\\hand.ani
#ENDIF
Haven't done it with a Statusbar, but I have used an ANI file before in a image control. Perhaps it will work there as well, then no need for a timer solution...otherwise Timer is pretty much it unless you combine a picture control and take the child of Statusbar approach. I did what MCM suggested before and did a SetParent making a progressbar a child and it worked fine.
sigpic
Mobile Solutions
Sys Analyst and Development
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment