News:

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

Text in Progressbar

Started by x-dream, February 19, 2006, 05:58:42 PM

Previous topic - Next topic

x-dream

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

Mark Jones

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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

sixleafclover

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.

arafel

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.

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

czDrillard

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

x-dream

#6
Thanks guys now i only have to work out howto write text to my statusbar
Anyone got code to do this?

anon

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.

x-dream

#8
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?

evlncrn8

make a txt window over the progress window, which is over the status window? heheheh