News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Progressbar for counters

Started by bloodhound, May 02, 2006, 06:51:13 AM

Previous topic - Next topic

bloodhound

i have seen icztutes on this but it involves timers.

how about counters or percent??? examples??

lets say 10 files must be copied...

thanks!


PBrennick

bloodhound,
You are one busy fellow and that is good.  Download http://www.pbrennick.com/asmtools/Progress.zip.  The file contains 5 examples, the first 3 are of particular use to you.  Example one shows a method using a percentage and Example two shows a method using a counter.  This is not my stuff, they are RadASM projects from someone else that I archived.  I am pretty sure this is Biterider's stuff and if you want the exact same look and feel you will need to get ObjASM32 from his site.  If you want to learn the methods involved, then just study the sources I am giving you.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

PBrennick

bloodhound,
Here is another example that shows a percentage type progress bar.

Paul


[attachment deleted by admin]
The GeneSys Project is available from:
The Repository or My crappy website

bloodhound

i guess the progress.zip example is much more advance.. but it helps

and the second one is way customized.. yes its ok!

i need a built in progress bar, ya know the 1s built in to windows, the square type?

thanks, i really need the counter part of the code on this..

PBrennick

Bloodhound,
Well the counterpart is found in Examples 2 and 3.  As far as the presentation goes, it imight be a series of filled rectangles that are sequentially displayed as needed.  Let's say that you are going to use 20 boxes in the bar; you would divide the file size (for instance) by 20 and so be able to establish the interval to be used to display each box.  Do you see what I mean?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

bloodhound

no, if you go back to icztutes or masm examples, you'll see the comctl sample, its depending
on the timer, i need the counter. but i still want the one that is being used, the standard thing??


.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comctl32.inc
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD

.const
IDC_PROGRESS equ 1
IDC_STATUS equ 2
IDC_TIMER equ 3

.data
ClassName db "CommonControlWinClass",0
AppName  db "Common Control Demo",0
ProgressClass db "msctls_progress32",0
Message db "Finished!",0
TimerID dd 0

.data?
hInstance HINSTANCE ?
hwndProgress dd ?
hwndStatus dd ?
CurrentStep dd ?

.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax
invoke WinMain, hInstance,NULL,NULL, SW_SHOWDEFAULT
invoke ExitProcess,eax
invoke InitCommonControls

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov   wc.cbSize,SIZEOF WNDCLASSEX
mov   wc.style, CS_HREDRAW or CS_VREDRAW
mov   wc.lpfnWndProc, OFFSET WndProc
mov   wc.cbClsExtra,NULL
mov   wc.cbWndExtra,NULL
push  hInst
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_APPWORKSPACE
mov   wc.lpszMenuName,NULL
mov   wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov   wc.hIcon,eax
mov   wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov   wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,ADDR AppName,\
           WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_VISIBLE,CW_USEDEFAULT,\
           CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
           hInst,NULL
mov   hwnd,eax
.while TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endw
mov eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_CREATE
invoke CreateWindowEx,NULL,ADDR ProgressClass,NULL,\
            WS_CHILD+WS_VISIBLE,100,\
          200,300,20,hWnd,IDC_PROGRESS,\
           hInstance,NULL
mov hwndProgress,eax
mov eax,1000
mov CurrentStep,eax
shl eax,16
invoke SendMessage,hwndProgress,PBM_SETRANGE,0,eax
invoke SendMessage,hwndProgress,PBM_SETSTEP,10,0
invoke CreateStatusWindow,WS_CHILD+WS_VISIBLE,NULL,hWnd,IDC_STATUS
mov hwndStatus,eax
invoke SetTimer,hWnd,IDC_TIMER,100,NULL
mov TimerID,eax
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.if TimerID!=0
invoke KillTimer,hWnd,TimerID
.endif
.elseif uMsg==WM_TIMER
invoke SendMessage,hwndProgress,PBM_STEPIT,0,0
sub CurrentStep,10
.if CurrentStep==0
invoke KillTimer,hWnd,TimerID
mov TimerID,0
invoke SendMessage,hwndStatus,SB_SETTEXT,0,addr Message
invoke MessageBox,hWnd,addr Message,addr AppName,MB_OK+MB_ICONINFORMATION
invoke SendMessage,hwndStatus,SB_SETTEXT,0,0
invoke SendMessage,hwndProgress,PBM_SETPOS,0,0
.endif
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp

end start


this is the timer, i need to change it to counter..

but you already gave the examples for this, i have to figure out how to insert
this on thre above..

thanks!

PBrennick

Bloodhound,
You have gotten lost.  I am talking about Examples 2 and 3 that you downloaded from my website.  Or did you?  I have a feeling ...

There are five Examples in Progress.zip
-----------------------------------------------------
Example #1 - Timer
Example #2 - Counter
Example #3 - Counter
Example #4 - Graphics Example
Example #5 - Graphics Example
-----------------------------------------------------

Do you understand what I am saying here??

Paul
The GeneSys Project is available from:
The Repository or My crappy website

bloodhound

no, im not.. im still hehe  :bg just kidding!

i just need help for the code above, its based on timers..  just want to modify that into counters..
that's pretty clear

although, your examples are really way too much advance for me!  :U

thanks again Paul!

Faiseur

Quotehttp://www.pbrennick.com/asmtools/Progress.zip.  The file contains 5 examples, the first 3 are of particular use to you.  Example one shows a method using a percentage and Example two shows a method using a counter.  This is not my stuff, they are RadASM projects from someone else that I archived.

For information, in fact in pBrennick website is the "standalone" version. This is a static lib that you can include without problem in a Masm32 project.

On this link http://www.masmforum.com/simple/index.php?topic=1945.0 the version for Radasm (IDE)  is which was improved (in particular for the use of several progressbars in the same application) to be more practical to use (dll and static version). But RadAsm is necessary.

French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

Ian_B

It's as simple as this, if you want small numbers (say 1 to 10, as in a count of files copied etc., where num<65536):

Set the initial progress range:
        invoke  SendMessage, ProgresshWnd, PBM_SETRANGE, 0, num*65536
        (num must be in the high word of the last param)

Set the start value:
        invoke  SendMessage, ProgresshWnd, PBM_SETPOS, 0, 0

Make the bar visible if it was originally hidden:
        invoke  ShowWindow, ProgresshWnd, SW_SHOW

Set an intermediate count value while window is visible:
        invoke  SendMessage, ProgresshWnd, PBM_SETPOS, val, 0
        (val must be <=original num)

Hide window again:
        invoke  ShowWindow, ProgresshWnd, SW_HIDE

This example is simple if you have only positive numbers with a lower range of 0. I believe you are actually permitted a range of 65535 to -65535. You'd need to check the SDK for how to set that up.

If you want to work with percentages or byte values, especially if you want to be able to deal with large files with 64-bit filelengths, then you need to have a strategy for mapping the arbitrary DWORD or QWORD max value onto a max PBM_SETPOS parameter of 65535, and then using the same mapping to create the intermediate param values. There's probably going to be some multiplication and even division in there, or at the very least choosing which significant WORD that you use as a param.

Ian_B