The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: x-dream on February 19, 2006, 05:58:42 PM

Title: Text in Progressbar
Post by: x-dream on February 19, 2006, 05:58:42 PM
Hi.

How do i set text in a progressbar i tried making the progressbar transparent but that wouldn work.. this progressbar (1002) is in my statusbar (1003)


invoke CreateWindowEx,WS_EX_TRANSPARENT,text("msctls_progress32"),0,WS_CHILD+WS_VISIBLE+PBS_SMOOTH,302,2,292,18,FUNC(GetDlgItem,hWin,1003),1002,hInstance,0
mov hwndprogress,eax
mov eax,1000
shl eax,16
mov ax,0
invoke SendMessage,hwndprogress,PBM_SETRANGE,0,eax   
invoke SendMessage,hwndprogress,PBM_SETPOS,300,3
invoke SendMessage,hwndprogress,PBM_SETBARCOLOR,0,002009F7h
Title: Re: Progressbar in Statusbar
Post by: Mark Jones on February 19, 2006, 06:31:51 PM
Hello x-dream. If you're looking to place text in the bottom "statusbar" of a window, try "SetDlgItemText" on its control ID. Say your statusbar ID was 1006:


.data
    szTemp  db  "Hello world!",0

.code
invoke SetDlgItemText,hWnd,1006,addr szTemp


With some ingenuity you could pass it a series of strings like:


.data
    szProgress01  db  "Thinking ",0
    szProgress02  db  "Thinking .",0
    szProgress03  db  "Thinking ..",0
    szProgress04  db  "Thinking ...",0
    szProgress05  db  "Thinking ....",0
    szProgress06  db  "Thinking .....",0
    szProgress07  db  "Thinking ......",0
    szProgress08  db  "Thinking .......",0
    szProgress09  db  "Thinking ........",0
    szProgress10  db  "Thinking .........",0
    szProgress11  db  "Thinking ..........",0
    szProgress12  db  "Thinking ...........",0
    szProgress13  db  "Thinking ............",0
    szProgress14  db  "Thinking .............",0
    szProgress15  db  "Thinking ..............",0
    szProgress16  db  "Thinking ............... done.",0


Of course there are many more interesting ways to do this but that's a start.
Title: Re: Progressbar in Statusbar
Post by: sixleafclover on February 19, 2006, 07:07:21 PM
If you're talking about what i think you are...then comctl32.dll has a prebuilt graphical progress bar you could use. Hope thats of use.
Title: Re: Progressbar in Statusbar
Post by: arafel on February 19, 2006, 08:33:11 PM
x-dream,
You could also use Rectangle api to draw something like a progress bar. That is, everytime the progress changes just redraw the rectangle with new width and thats all.
Title: Re: Progressbar in Statusbar
Post by: donkey on February 20, 2006, 12:28:21 AM
Hi x-dream,

When you create your progress bar just make it a child of the status bar by using the status bar handle in the hWndParent parameter of CreateWindowEx. I think Iposted an example using this once, can't remember, but if you have any troubles figuring it out I can throw one together for you.

Donkey
Title: Re: Progressbar in Statusbar
Post by: czDrillard on February 20, 2006, 06:32:23 AM
Hello x-dream,

This works for me:

invoke GetClientRect,hWndStatus,ADDR rect
mov ecx,rect.bottom
sub ecx,02h
;used to position progressbar in status bar

invoke CreateWindowEx,NULL,ADDR ProgressClass,NULL,\
  WS_CHILD+WS_VISIBLE,302,2,144,ecx,\
  hWndStatus,IDC_PROGRESS,hInstance,NULL

mov hwndProgress,eax
mov eax,512
mov CurrentStep,eax
shl eax,16
invoke SendMessage,hwndProgress,PBM_SETRANGE,0,eax 
invoke SendMessage,hwndProgress,PBM_SETSTEP,1,0

;call a proc here and do update the progressbar
MyProc
invoke SendMessage,hwndProgress,PBM_STEPIT,0,0
sub CurrentStep,1
ret
MyProc endp

invoke DestroyWindow,hwndProgress


best regards,

czDrillard
Title: Re: Progressbar in Statusbar
Post by: x-dream on February 20, 2006, 07:41:41 PM
Thanks guys now i only have to work out howto write text to my statusbar
Anyone got code to do this?
Title: Re: Progressbar in Statusbar
Post by: anon on February 21, 2006, 01:09:22 AM
from PSDK

The SB_SETTEXT message sets the text in the specified part of a status window.

SB_SETTEXT
    wParam = (WPARAM) iPart | uType;
    lParam = (LPARAM) (LPSTR) szText;

Parameters
iPart
Zero-based index of the part to set. If this parameter is set to SB_SIMPLEID, the status window is assumed to be a simple window with only one part.
uType
Type of drawing operation. This parameter can be one of the following values: 0 The text is drawn with a border to appear lower than the plane of the window.
SBT_NOBORDERS The text is drawn without borders.
SBT_OWNERDRAW The text is drawn by the parent window.
SBT_POPOUT The text is drawn with a border to appear higher than the plane of the window.
SBT_RTLREADING The text will be displayed in the opposite direction to the text in the parent window.

szText
Pointer to a null-terminated string that specifies the text to set. If uType is SBT_OWNERDRAW, this parameter represents 32 bits of data. The parent window must interpret the data and draw the text when it receives the WM_DRAWITEM message. The text for each part is limited to 127 characters.

So, something like:
invoke SendMessage,hwndProgress,SB_SETTEXT,0,addr TextToDisplay
would write the contents of TextToDisplay into the first "box" of the statusbar.
Title: Re: Progressbar in Statusbar
Post by: x-dream on February 21, 2006, 09:19:00 AM
The problem is my progressbar overwrites my statusbar so i cant see the text, my code is as donkey said.

How do you solve this problem?
Title: Re: Progressbar in Statusbar
Post by: evlncrn8 on February 22, 2006, 01:25:33 PM
make a txt window over the progress window, which is over the status window? heheheh