Code:
' PROGRESS.INC ' ProgressBar Pseudo-Class #if not %def(%ODT_HEADER) #include "commctrl.inc" #endif %PBM_SETBARCOLOR = %WM_USER + 9 %PBM_SETBKCOLOR = %CCM_SETBKCOLOR %MAX_BARS = 100 ' Maximal number of progressbars ' Member-function ID's %CREATE = 0 %SETRANGE = 1 %STEPIT = 2 %SETSTEP = 3 %SETPOS = 4 %HIDE = 5 %SHOW = 6 %MOVE = 7 %SETBARCOLOR = 8 %SETBKCOLOR = 9 %GETHANDLE = 10 ' "Class" function CProgressBar(byval id_func as long, byval id_bar as long, _ byval param1 as long, _ byval param2 as long, _ byval param3 as long, _ byval param4 as long, _ byval param5 as long, _ byval param6 as long) as long ' Protected member variables static m_n as long ' Number of progressbars static m_hParent as long dim m_hProgress(%MAX_BARS-1) as static long dim m_ID(%MAX_BARS-1) as static long local m_hInst as long local m_x as long, m_y as long local m_xx as long, m_yy as long local m_style as long local m_RangeMin as integer, m_RangeMax as integer local m_stepInc as long local i as long, j as long if m_n > 0 then for j = 0 to m_n-1 if m_ID(j) = id_bar then i = j+1 exit for end if next j end if if id_func <> %CREATE then if i = 0 then exit function decr i ' 0-based else if i > 0 then exit function end if ' Member functions select case id_func case %CREATE m_ID(m_n) = id_bar m_hParent = param1 m_x = param2 m_y = param3 m_xx = param4 m_yy = param5 m_style = %WS_CHILD or param6 m_hInst = GetModuleHandle(byval %NULL) m_hProgress(m_n) = CreateWindow("MSCTLS_PROGRESS32",byval %NULL, _ m_style, _ m_x, m_y, m_xx, m_yy, m_hParent, _ byval %NULL, m_hInst, byval %NULL) if m_hProgress(m_n) = 0 then exit function incr m_n case %SETRANGE if m_hProgress(i) = 0 then exit function m_RangeMin = Param1 m_RangeMax = Param2 SendMessage m_hProgress(i), %PBM_SETRANGE, 0, maklng(m_RangeMin,m_RangeMax) case %STEPIT if m_hProgress(i) = 0 then exit function SendMessage m_hProgress(i), %PBM_STEPIT, 0, 0 case %SETSTEP if m_hProgress(i) = 0 then exit function m_stepInc = Param1 SendMessage m_hProgress(i), %PBM_SETSTEP, m_stepInc, 0 case %SETPOS if m_hProgress(i) = 0 then exit function SendMessage m_hProgress(i), %PBM_SETPOS, Param1, 0 case %HIDE if m_hProgress(i) = 0 then exit function ShowWindow m_hProgress(i), %SW_HIDE case %SHOW if m_hProgress(i) = 0 then exit function ShowWindow m_hProgress(i), %SW_SHOW case %MOVE if m_hProgress(i) = 0 then exit function m_x = Param1 m_y = Param2 m_xx = Param3 m_yy = Param4 MoveWindow m_hProgress(i), m_x, m_y, m_xx, m_yy, %TRUE case %SETBARCOLOR if m_hProgress(i) = 0 then exit function SendMessage m_hProgress(i), %PBM_SETBARCOLOR, 0, Param1 case %SETBKCOLOR if m_hProgress(i) = 0 then exit function SendMessage m_hProgress(i), %PBM_SETBKCOLOR, 0, Param1 case %GETHANDLE function = m_hProgress(i) : exit function end select function = 1 end function ' Wrapper functions function ProgressBarCreate(byval hParent as long, _ byval BarId as long, _ byval x as long, _ ' horizontal position byval y as long, _ ' vertical position byval xx as long, _ ' width byval yy as long, _ ' height byval style as long _ ) as long function = CProgressBar(%CREATE, BarId, hParent,x,y,xx, yy, style) end function function ProgressBarSetRange(byval BarId as long, _ byval RangeMin as long, _ ' Minimum range value. By default, the minimum value is zero. byval RangeMax as long _ ' Maximum range value. By default, the maximum value is 100. ) as long function = CProgressBar(%SETRANGE, BarID, RangeMin, RangeMax, 0,0,0,0) end function function ProgressBarStepIt(byval BarId as long) as long function = CProgressBar(%STEPIT,BarID,0,0,0,0,0,0) end function function ProgressBarSetStep(byval BarId as long, byval StepInc as long) as long function = CProgressBar(%SETSTEP, BarID, StepInc,0,0,0,0,0) end function function ProgressBarSetPos(byval BarId as long, byval NewPos as long) as long function = CProgressBar(%SETPOS, BarID, NewPos,0,0,0,0,0) end function function ProgressBarHide(byval BarId as long) as long function = CProgressBar(%HIDE,BarID,0,0,0,0,0,0) end function function ProgressBarShow(byval BarId as long) as long function = CProgressBar(%SHOW,BarID,0,0,0,0,0,0) end function function ProgressBarSetBarColor(byval BarId as long, byval clrBar as long) as long function = CProgressBar(%SETBARCOLOR,BarID,clrBar,0,0,0,0,0) end function function ProgressBarSetBkColor(byval BarId as long, byval clrBk as long) as long function = CProgressBar(%SETBKCOLOR,BarID,clrBk,0,0,0,0,0) end function function ProgressBarMove(byval BarId as long, _ byval x as long, _ byval y as long, _ byval xx as long, _ byval yy as long _ ) as long function = CProgressBar(%MOVE,BarID,x,y,xx,yy,0,0) end function function ProgressBarGetHandle(byval BarId as long) as long function = CProgressBar(%GETHANDLE,BarID,0,0,0,0,0,0) end function
Leave a comment: