'Po mans ProgressBar 'Ian Casey 4/2008 'Uses 2 labels to set progress or percentage value 'for testing I used a timer and RND function to provide values GUI "Form1",PIXELS CONST Stc1_Style = WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_NOTIFY CONST Stc1_ExtStyle = WS_EX_STATICEDGE CONST Stc2_Style = WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_NOTIFY |WS_EX_TRANSPARENT CONST Stc2_ExtStyle = WS_EX_STATICEDGE CONST Btn1_Style = WS_CHILD|WS_VISIBLE|WS_TABSTOP CONST Btn1_ExtStyle = WS_EX_STATICEDGE ENUM ID_Stc1 ID_Stc2 ID_Stc3 ID_Btn1 END ENUM Type VTimer ID AS UINT Enabled AS Boolean Interval As Integer bOpen as Integer vType as Integer End Type GLOBAL Form1 AS HWND GLOBAL hStc1 AS CONTROL GLOBAL hStc2 AS CONTROL GLOBAL hBtn1 AS CONTROL GLOBAL hStc3 AS CONTROL GLOBAL progWidth as LONG GLOBAL myTimer as VTimer SUB FORMLOAD() Form1 = BCX_FORM("Po'mans ProgressBar", 0, 0, 314, 235) hStc2 = BCX_LABEL("",Form1,ID_Stc1, 20, 20, 230, 30, Stc1_Style, Stc1_ExtStyle) hStc1 = BCX_LABEL("",Form1,ID_Stc2, 20, 20, 25, 30, Stc2_Style, Stc2_ExtStyle) hBtn1 = BCX_BUTTON("END",Form1,ID_Btn1, 80, 140, 130, 60, Btn1_Style, Btn1_ExtStyle) hStc3 = BCX_LABEL("",Form1,ID_Stc3, 20, 75, 210, 28, Stc2_Style, Stc2_ExtStyle) progWidth = 210 'Width of the label 1 CENTER(Form1) SHOW(Form1) myTimer.Interval = 1000 myTimer.bOpen = False myTimer.vType = 1 StartTimer(&myTimer) END SUB BEGIN EVENTS SELECT CASE CBMSG CASE WM_COMMAND SELECT CASE CBCTL CASE ID_Stc1 CASE ID_Stc2 CASE ID_Btn1 KillTimer(NULL, myTimer.ID) END END SELECT CASE WM_CTLCOLORSTATIC 'set the label colors LOCAL cFG, cBG cBG = 250'16777215 cFG = 16711808 BCX_SET_LABEL_COLOR(hStc1, cFG, cBG) BCX_SET_LABEL_COLOR(hStc2, cBG, cFG) END SELECT END EVENTS Sub StartTimer (BYREF mTimer AS VTimer) 'AS Bool (mTimer).ID = SetTimer(NULL,0, (mTimer).Interval,myTIMERPROC) (mTimer).bOpen = TRUE End Sub Function myTIMERPROC (hwnd AS HWND , u1 AS UINT, u2 AS UINT, d AS DWORD) AS VOID CALLBACK Dim nRet as SINGLE Dim nSize as INTEGER nSize = (CINT( RND * progWidth)) SetCtrlWidth(hStc1, nSize) BCX_SET_TEXT(hStc3,str$(nSize)) End Function FUNCTION SetCtrlWidth(hWnd as HWND, d as integer) as integer Dim rc as RECT GetWindowRect(hWnd,&rc) rc.right = d SetWindowPos(hWnd,HWND_TOP, rc.left , rc.top, rc.right, rc.bottom - rc.top,SWP_NOMOVE | SWP_NOZORDER) function = rc.right End Function