Thanks to everyone here for taking pity on a first time programmer. I have finished writing the programs, and will now hand them over for testing.
Just before I do though, I found this snippet that I assume puts a running precentage ie "60%" text in the progress bar.
If OpenWindow(0, 0, 0, 300, 50, "ProgressBarGadget example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ProgressBarGadget(1, 10, 10, 280, 30, 0, 100)
EndIf
percent.f = 50.00
SetGadgetState(1, percent)
gtk_progress_bar_set_text_(GadgetID(1), StrF(percent,2)+"%")
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
The trouble is, it stalls the the following ands says the function is not available
gtk_progress_bar_set_text_(GadgetID(1), StrF(percent,2)+"%")
Nothing I can do, will get it to work.
To be honest, its more of a "would be nice" than a "I must have it thing" so if it will not take up too much of your time, any ideas please.
Thanks
Danny
PB4
Progressbar with text
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
First, use code tags and indention. Second, are you on Linux afterall? Anything starting with gtk_*() is Linux API.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
If you want code for windows, have a look at this thread :
http://www.purebasic.fr/english/viewtopic.php?t=31131
An example :
http://www.purebasic.fr/english/viewtopic.php?t=31131
An example :
Code: Select all
;
; ProgressBar With Text
;
Enumeration
#Window_0
EndEnumeration
Enumeration
#ProgressBar_0
#ProgressBar_1
#Text_0
EndEnumeration
;
Procedure ProcTextProgressBarGadget(hwnd, msg, wParam, lParam)
Protected OldProc.l, ImgID.l, ImgID2.l, hdcOut.l, hdcIn.l, ps.PAINTSTRUCT, GadgetNumber.l
Protected Text.s, BarColor.l, Progression.d, BackColor.l, ProgWidth.d, TextColor2.l
OldProc = GetProp_(hwnd, "OldProc")
TextColor = GetProp_(hwnd, "TextColor")
TextColor2 = GetProp_(hwnd, "TextColor2")
BackColor = GetProp_(hwnd, "BackColor")
BarColor = GetProp_(hwnd, "BarColor")
Select msg
Case #WM_PAINT
GadgetNumber = GetDlgCtrlID_(hwnd)
Progression = (GetGadgetState(GadgetNumber) - GetGadgetAttribute(GadgetNumber, #PB_ProgressBar_Minimum)) / (GetGadgetAttribute(GadgetNumber, #PB_ProgressBar_Maximum) - GetGadgetAttribute(GadgetNumber, #PB_ProgressBar_Minimum))
ProgWidth = GadgetWidth(GadgetNumber)* Progression
Text = StrD(Progression * 100, 0) + "%"
BeginPaint_(hwnd, @ps) ;>
hdcOut = ps\hdc
ImgID2 = CreateImage(#PB_Any, GadgetWidth(GadgetNumber), GadgetHeight(GadgetNumber), #PB_Image_DisplayFormat)
StartDrawing(ImageOutput(ImgID2))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(GetStockObject_(#DEFAULT_GUI_FONT))
Box(0, 0, GadgetWidth(GadgetNumber), GadgetHeight(GadgetNumber), BarColor)
FrontColor(TextColor)
DrawText(GadgetWidth(GadgetNumber) / 2 - 0.5 * TextWidth(Text), GadgetHeight(GadgetNumber) / 2 - 0.5 * TextHeight(Text), Text)
StopDrawing()
ImgID = CreateImage(#PB_Any, GadgetWidth(GadgetNumber), GadgetHeight(GadgetNumber), #PB_Image_DisplayFormat)
hdcIn = StartDrawing(ImageOutput(ImgID))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(GetStockObject_(#DEFAULT_GUI_FONT))
Box(0, 0, GadgetWidth(GadgetNumber), GadgetHeight(GadgetNumber), BackColor)
FrontColor(TextColor2)
DrawText(GadgetWidth(GadgetNumber) / 2 - 0.5 * TextWidth(Text), GadgetHeight(GadgetNumber) / 2 - 0.5 * TextHeight(Text), Text)
If ProgWidth > 0
ImgTmpID = GrabImage(ImgID2 , #PB_Any, 0, 0, ProgWidth, GadgetHeight(GadgetNumber))
DrawImage(ImageID(ImgTmpID), 0, 0)
FreeImage(ImgTmpID)
EndIf
BitBlt_(hdcOut, 0, 0, GadgetWidth(GadgetNumber), GadgetHeight(GadgetNumber), hdcIn, 0, 0, #SRCCOPY)
StopDrawing()
EndPaint_(hwnd, ps) ;<
FreeImage(ImgID)
FreeImage(ImgID2)
ProcedureReturn #Null
Case #WM_NCDESTROY
RemoveProp_(hwnd, "OldProc")
RemoveProp_(hwnd, "TextColor")
RemoveProp_(hwnd, "TextColor2")
RemoveProp_(hwnd, "BackColor")
RemoveProp_(hwnd, "BarColor")
EndSelect
ProcedureReturn CallWindowProc_(OldProc, hwnd, msg, wParam, lParam)
EndProcedure
Procedure CreateTextProgressBarGadget(GadgetNumber.l, X.l, Y.l, width.l, Height.l, Minimum.l, Maximum.l, FirstTextColor.l = #PB_Ignore, SecondTextColor.l = #PB_Ignore, BarColor.l = #PB_Ignore, BackColor.l = #PB_Ignore)
Protected ImgID.l, ImgID2.l
If FirstTextColor = #PB_Ignore
FirstTextColor = GetSysColor_(#COLOR_WINDOWTEXT)
EndIf
If SecondTextColor = #PB_Ignore
SecondTextColor = GetSysColor_(#COLOR_HIGHLIGHTTEXT)
EndIf
If BackColor = #PB_Ignore
BackColor = GetSysColor_(#COLOR_BTNFACE)
EndIf
If BarColor = #PB_Ignore
BarColor = GetSysColor_(#COLOR_HIGHLIGHT)
EndIf
ProgressBarGadget(GadgetNumber, X, Y, width, Height, Minimum, Maximum)
SetProp_(GadgetID(GadgetNumber), "BackColor", BackColor)
SetProp_(GadgetID(GadgetNumber), "BarColor", BarColor)
SetProp_(GadgetID(GadgetNumber), "TextColor", SecondTextColor)
SetProp_(GadgetID(GadgetNumber), "TextColor2", FirstTextColor)
SetProp_(GadgetID(GadgetNumber), "OldProc", SetWindowLong_(GadgetID(GadgetNumber), #GWL_WNDPROC, @ProcTextProgressBarGadget()))
EndProcedure
;
; ----------- T E S T ----------
;
If OpenWindow(#Window_0, 591, 251, 251, 110, "Text in progressbar", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Window_0))
CreateTextProgressBarGadget(#ProgressBar_0, 5, 10, 240, 30, 0, 2000)
CreateTextProgressBarGadget(#ProgressBar_1, 5, 50, 200, 30, 0, 1000, #Blue, #Red, #White, #Green)
TextGadget(#Text_0, 5, 90, 245, 20, "", #PB_Text_Center)
EndIf
EndIf
;
cc=0
Repeat
Event = WaitWindowEvent(1)
If cc<2000:cc+2
SetGadgetState(#ProgressBar_0, cc)
SetGadgetState(#ProgressBar_1, cc)
SetGadgetText(#Text_0, Str(cc) + " / 2000")
EndIf
Select Event
Case #PB_Event_CloseWindow
CloseWindow(#Window_0)
Break
EndSelect
ForEver
Last edited by gnozal on Fri Feb 12, 2010 4:50 pm, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- User
- Posts: 27
- Joined: Sun Jul 13, 2008 9:47 am
- Location: UK
Thanks
Thanks very much for those who helped me here.
I have finsihed the programs, which seem to working well.
Thanks again
Danny
I have finsihed the programs, which seem to working well.
Thanks again
Danny