Just for the intertainment i'm trying to implement a class-like setup in PowerBasic. The nice thing about such a construction is that you can avoid global variables. The member-functions share the same data. In the following example the handles and the ID's of the progressbars are saved and protected inside the class. The user never see the handles (allthough he can get them by the ProgressBarGetHandle member-function).
First i show the example. In the next post the implementation of the class is given (progress.inc ).
Regards
Peter
First i show the example. In the next post the implementation of the class is given (progress.inc ).
Regards
Peter
Code:
#compile exe #dim all #register none #include "win32api.inc" #include "progress.inc" declare callback function DlgProc %ID_BUT_TEST = 1000 %ID_PROGRESS = 1001 %NUM_BARS = 75 %MAX_RANGE = 150 function pbmain local hDlg as long dialog new 0, "A lot of ProgressBars!",,,400, 450, %WS_SYSMENU or %WS_MINIMIZEBOX or %DS_CENTER to hDlg control add button, hDlg, %ID_BUT_TEST, "Test", 350, 5, 40, 14 dialog show modal hDlg call DlgProc end function callback function DlgProc local id as long, j as long, r as long, h as long local s as string select case cbMsg case %WM_INITDIALOG for id = 1 to %NUM_BARS ProgressBarCreate cbhndl, id, 5, 5 + (id-1)*9, 500, 7, %WS_VISIBLE ProgressBarSetRange id, 0, %MAX_RANGE ProgressBarSetStep id, sqr(id) ProgressBarSetBarColor id, %Red ProgressBarSetBkColor id, %LtGray'%White next id ProgressBarCreate cbhndl, %ID_PROGRESS, 5, 682, 500, 20, %WS_VISIBLE ProgressBarSetRange %ID_PROGRESS, 0, %MAX_RANGE ProgressBarSetStep %ID_PROGRESS, 1 ProgressBarSetBarColor %ID_PROGRESS, %Yellow ProgressBarSetBkColor %ID_PROGRESS, %Black case %WM_CTLCOLORDLG function = GetStockObject(%WHITE_BRUSH) case %WM_COMMAND select case lowrd(cbwParam) case %ID_BUT_TEST control disable cbhndl, %ID_BUT_TEST for j = 1 to %MAX_RANGE ProgressBarStepIt %ID_PROGRESS for id = 1 to %NUM_BARS ProgressBarStepIt id next id next j for id = 1 to %NUM_BARS ProgressBarSetPos id, 0 next id ProgressBarSetPos %ID_PROGRESS, 0 control enable cbhndl, %ID_BUT_TEST end select end select end function
Comment