Ive got my program running (yeay yeay - so I will run out of
questions soon I think - you hope ) but my (Semens actually) progress bar
dissapears after a while. I takes about 5mins but the progress
bar just dissapears.
I have spent all day on this and the file Error 75 problem. I
could not duplicate the File Error problem but this one I can!
the following code will do it. Somewhere around iteration 170 it
will stop (allthough the program continues fine)
It will take a few minutes tho
I suspect i am not releasing something that should be released,
or Im slowly using up something but I have studied and studied it
and i cant find it.
This code is the smallest example I could make that demonstrates
the problem.
------------------
Kind Regards
Mike
questions soon I think - you hope ) but my (Semens actually) progress bar
dissapears after a while. I takes about 5mins but the progress
bar just dissapears.
I have spent all day on this and the file Error 75 problem. I
could not duplicate the File Error problem but this one I can!
the following code will do it. Somewhere around iteration 170 it
will stop (allthough the program continues fine)
It will take a few minutes tho

I suspect i am not releasing something that should be released,
or Im slowly using up something but I have studied and studied it
and i cant find it.
This code is the smallest example I could make that demonstrates
the problem.
Code:
#COMPILE EXE "Test.exe" #INCLUDE "WIN32API.INC" GLOBAL hDlg AS LONG GLOBAL Wdth AS LONG, Hght AS LONG, BtnW AS LONG, BtnS AS LONG, BtnH AS LONG, FrmS AS LONG, FrmW AS LONG GLOBAL TxtS AS LONG, TxtW AS LONG, Disp AS LONG, TxtH AS LONG, TickCount AS LONG, Done AS LONG GLOBAL LpProgBarPaint AS PaintStruct GLOBAL tRectProgBar AS Rect GLOBAL zTProgBar AS ASCIIZ*255 GLOBAL hDlgProgBar AS LONG, PBiProgBar AS LONG, nProgBar AS LONG GLOBAL ghBrushProgBar() AS LONG, ghDCProgBar() AS LONG, ghBmpProgBar() AS LONG, gClrProgBar() AS LONG %PROGBARID = %WM_USER + 2048 '************************************************************************ FUNCTION ProgBarClr( R AS LONG, G AS LONG, B AS LONG, BkR AS LONG, BkG AS LONG, BkB AS LONG ) AS LONG ghBrushProgBar(1) = CREATESOLIDBRUSH(RGB( R, G, B)) ghBrushProgBar(2) = CREATESOLIDBRUSH(RGB(BkR, BkG, BkB)) gClrProgBar(1) = RGB(BkR, BkG, BkB) gClrProgBar(2) = RGB( R, G, B) END FUNCTION '************************************************************************ CALLBACK FUNCTION DrawProgBar SELECT CASE CBMSG CASE %WM_INITDIALOG REDIM ghBrushProgBar(2) REDIM ghDCProgBar (2) REDIM ghBmpProgBar (2) REDIM gClrProgBar (2) CASE %WM_DESTROY DELETEOBJECT ghBrushProgBar(1) DELETEOBJECT ghBrushProgBar(2) INVALIDATERECT GETPARENT(CBHNDL), BYVAL 0, %True UPDATEWINDOW GETPARENT(CBHNDL) CASE %WM_ERASEBKGND EXIT FUNCTION CASE %PROGBARID nProgBar = CBWPARAM ' % complete sent INVALIDATERECT CBHNDL, BYVAL 0, %True UPDATEWINDOW CBHNDL CASE %WM_PAINT GETCLIENTRECT CBHNDL, tRectProgBar ghDCProgBar(0) = BEGINPAINT(CBHNDL, LpProgBarPaint) FOR PBiProgBar = 1 TO 2 ghDCProgBar (PBiProgBar) = CREATECOMPATIBLEDC (ghDCProgBar(0)) ghBmpProgBar(PBiProgBar) = CREATECOMPATIBLEBITMAP(ghDCProgBar(0), tRectProgBar.nRight, tRectProgBar.nBottom+10) SELECTOBJECT ghDCProgBar(PBiProgBar), ghBmpProgBar(PBiProgBar) FILLRECT ghDCProgBar(PBiProgBar), tRectProgBar, ghBrushProgBar(PBiProgBar) SETBKMODE ghDCProgBar(PBiProgBar), %TRANSPARENT SETTEXTCOLOR ghDCProgBar(PBiProgBar), gClrProgBar(PBiProgBar) zTProgBar = STR$(nProgBar) + "%" DRAWTEXT ghDCProgBar(PBiProgBar), zTProgBar, -1, tRectProgBar, %DT_SINGLELINE OR %DT_CENTER OR %DT_VCENTER NEXT BITBLT ghDCProgBar (2), 0, 0, tRectProgBar.nRight*nProgBar*0.01, tRectProgBar.nBottom, ghDCProgBar(1), 0, 0, %SRCCOPY BITBLT ghDCProgBar (0), 0, 0, tRectProgBar.nRight, tRectProgBar.nBottom, ghDCProgBar(2), 0, 0, %SRCCOPY ENDPAINT CBHNDL, LpProgBarPaint DELETEDC ghDCProgBar (1) DELETEDC ghDCProgBar (2) DELETEOBJECT ghBmpProgBar(1) DELETEOBJECT ghBmpProgBar(2) END SELECT END FUNCTION '************************************************************************ FUNCTION TestProgBar() AS LONG LOCAL i AS LONG, sz AS LONG, Res AS LONG, d AS LONG, k AS LONG, Chunck AS LONG LOCAL aStr AS STRING DIALOG NEW hDlg, "", FrmS, Disp, FrmW-2, 9, %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER TO hDlgProgBar ' Create Progress Bar DIALOG SHOW MODELESS hDlgProgBar CALL DrawProgBar DIALOG SEND hDlgProgBar , %PROGBARID, 0, 0 Chunck = 4000 FOR i = 1 TO 400 ProgBarClr 251,235,098, 005,005,005 ' process 1 FOR k = 1 TO Chunck IF k MOD 200 = 0 THEN DIALOG SEND hDlgProgBar, %PROGBARID, ROUND(k/Chunck*100 ,0), 0 aStr = DATE$+TIME$+SPACE$(50) aStr = MID$(aStr, 3, 40) aStr = LEFT$(aStr, 28) NEXT aStr = SPACE$(200000) ' make a 2k string DIALOG DOEVENTS ProgBarClr 120,255,055, 005,005,005 ' process 2 FOR k = 1 TO Chunck IF k MOD 200 = 0 THEN DIALOG SEND hDlgProgBar, %PROGBARID, ROUND(k/Chunck*100 ,0), 0 aStr = DATE$+TIME$+SPACE$(50) aStr = MID$(aStr, 3, 40) aStr = LEFT$(aStr, 28) NEXT aStr = SPACE$(200000) ' make a 2k string DIALOG DOEVENTS ProgBarClr 120,170,255, 005,005,005 ' process 3 FOR k = 1 TO Chunck IF k MOD 200 = 0 THEN DIALOG SEND hDlgProgBar, %PROGBARID, ROUND(k/Chunck*100 ,0), 0 aStr = DATE$+TIME$+SPACE$(50) aStr = MID$(aStr, 3, 40) aStr = LEFT$(aStr, 28) NEXT aStr = SPACE$(200000) ' make a 2k string DIALOG DOEVENTS CONTROL SET TEXT hDlg, 114, STR$(i) IF Done THEN EXIT FUNCTION NEXT aStr = "" END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' CALLBACK FUNCTION MainCB() AS LONG SELECT CASE CBMSG CASE %WM_COMMAND SELECT CASE CBCTL CASE 134 : CALL TestProgBar CASE 124 : Done = 1 : DIALOG END hDlg END SELECT END SELECT END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤' FUNCTION PBMAIN Wdth = 110 : Hght = 98 : BtnW = 90 : BtnH = 14 : BtnS = Wdth/2-BtnW/2 : FrmS = 4 : FrmW = Wdth-2*FrmS TxtH = 12 : TxtS = 10 : TxtW = Wdth-TxtS-FrmS-2 : Disp = Hght-43 DIALOG NEW 0, "Demonstrate dissapearing ProgBar", 330, 60, Wdth, Hght, 0 TO hDlg CONTROL ADD BUTTON, hDlg, 134, "&Run", BtnS, 20, BtnW, BtnH, 0 CONTROL ADD LABEL, hDlg, 114, "", FrmS, Hght-29, FrmW, TxtH, %SS_CENTER CONTROL ADD BUTTON, hDlg, 124, "&Quit", FrmS, Hght-16, FrmW, BtnH, 1 DIALOG SHOW MODAL hDlg CALL MainCB END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'
Kind Regards
Mike
Comment