I'm not sure how this is different from the built-in HProgressBar control.
Some of the data types are incorrect, handles should be defined as LongPtr so that it will work in 64bit.
forward
global type w_progressbar from window
end type
type cb_increment from commandbutton within w_progressbar
end type
end forward
global type w_progressbar from window
integer width = 1248
integer height = 652
boolean titlebar = true
string title = "Progressbar"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
string icon = "AppIcon!"
boolean center = true
cb_increment cb_increment
end type
global w_progressbar w_progressbar
type prototypes
Private:
Function longptr CreateWindowExW( &
ulong dwExStyle, &
string ClassName, &
longptr WindowName, &
ulong dwStyle, &
long UX, &
long UY, &
long nWidth, &
long nHeight, &
longptr hWndParent, &
longptr hMenu, &
longptr hInstance, &
longptr lpParam &
) Library "user32.dll"
end prototypes
type variables
Private:
LongPtr hProgress
// Window constants
Constant ULong WS_CHILD = 1073741824
Constant ULong WS_VISIBLE = 268435456
// Progressbar window class
Constant String PROGRESS_CLASS = 'msctls_progress32'
// Message constants, we only use a few of these but I'll leave them for posterity
Constant UInt CCM_FIRST = 8192 // &H2000
Constant UInt CCM_SETBKCOLOR = CCM_FIRST + 1
Constant UInt PBM_SETBKCOLOR = CCM_SETBKCOLOR // Sets the Progress Bar background color
Constant UInt WM_USER = 1024
Constant UInt PBM_SETRANGE = (WM_USER + 1) // Sets the total low & high of the Progress Bar
Constant UInt PBM_SETPOS = (WM_USER + 2) // Sets the current % position of the Progress Bar
Constant UInt PBM_DELTAPOS = (WM_USER + 3)
Constant UInt PBM_SETSTEP = (WM_USER + 4)
Constant UInt PBM_STEPIT = (WM_USER + 5)
Constant UInt PBM_SETRANGE32 = (WM_USER + 6)
Constant UInt PBM_GETRANGE = (WM_USER + 7)
Constant UInt PBM_GETPOS = (WM_USER + 8)
Constant UInt PBM_SETBARCOLOR = (WM_USER + 9) // Sets the color of the Progress Bar
Constant UInt PBM_SETMARQUEE = (WM_USER + 10)
Constant UInt PBM_GETSTEP = (WM_USER + 13)
Constant UInt PBM_GETBKCOLOR = (WM_USER + 14) // Get Progress Bar Background Color
Constant UInt PBM_GETBARCOLOR = (WM_USER + 15) // Get Progress Bar bar Color
Constant UInt PBM_SETSTATE = (WM_USER + 16) // NORMAL, ERROR, PAUSED
Constant UInt PBM_GETSTATE = (WM_USER + 17)
end variables
on w_progressbar.create
this.cb_increment=create cb_increment
this.Control[]={this.cb_increment}
end on
on w_progressbar.destroy
destroy(this.cb_increment)
end on
event open;
hProgress = CreateWindowExW( &
0, &
PROGRESS_CLASS, &
0, &
WS_CHILD + WS_VISIBLE, &
10, &
10, &
UnitsToPixels( this.width, XUnitsToPixels! ) - 30, &
15, &
Handle( this ), &
0, &
Handle( GetApplication() ), &
0 )
// Setting min and max values
// Max value needs to be bitshifted by 16 here because the higher 16 bits of the 32 bit variable is used here
Send( hProgress, PBM_SETRANGE, 0, 100 * 2^16 )
// Setting the step size, 10 is the default
Send( hProgress, PBM_SETSTEP, 5, 0 )
end event
type cb_increment from commandbutton within w_progressbar
integer x = 402
integer y = 288
integer width = 407
integer height = 100
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Progress!"
boolean flatstyle = true
end type
event clicked;
// Increment progress bar
Send( hProgress, PBM_STEPIT, 0, 0 )
end event
thank you very much for your help. I will do it this way and hope it works.
André