changing_20a_20control_27s_20colours
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
changing_20a_20control_27s_20colours [2018/03/31 13:19] – external edit 127.0.0.1 | changing_20a_20control_27s_20colours [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====Changing a control' | =====Changing a control' | ||
- | //by Richard Russell, September 2007//\\ \\ You will normally want dialogue box controls to use their default colour scheme, for reasons of uniformity with other Windows applications, | + | //by Richard Russell, September 2007//\\ \\ You will normally want dialogue box controls to use their default colour scheme, for reasons of uniformity with other Windows applications, |
+ | |||
+ | <code bb4w> | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
INSTALL @lib$+" | INSTALL @lib$+" | ||
Line 14: | Line 16: | ||
WS_GROUP = &20000 | WS_GROUP = &20000 | ||
WS_BORDER = &800000 | WS_BORDER = &800000 | ||
- | Note that version 1.3 or later of SUBCLASS.BBC is required.\\ \\ Next we can create the dialogue box template in the usual way:\\ | + | </ |
+ | |||
+ | Note that version 1.3 or later of SUBCLASS.BBC is required.\\ \\ Next we can create the dialogue box template in the usual way: | ||
+ | |||
+ | <code bb4w> | ||
dlg% = FN_newdialog(" | dlg% = FN_newdialog(" | ||
Line 21: | Line 27: | ||
PROC_pushbutton(dlg%, | PROC_pushbutton(dlg%, | ||
PROC_pushbutton(dlg%, | PROC_pushbutton(dlg%, | ||
- | So far everything is conventional, | + | </ |
+ | |||
+ | So far everything is conventional, | ||
+ | |||
+ | <code bb4w> | ||
PROC_subclassdlg(dlg%, | PROC_subclassdlg(dlg%, | ||
PROC_subclassdlg(dlg%, | PROC_subclassdlg(dlg%, | ||
PROC_subclassdlg(dlg%, | PROC_subclassdlg(dlg%, | ||
PROC_subclassdlg(dlg%, | PROC_subclassdlg(dlg%, | ||
- | Note that in this particular case the same function is used for both the CTLCOLORDLG and CTLCOLORBTN messages because in each case all we want to do is change the background colour. If you don't change the background colour of the buttons to match the dialogue box background an ugly border around the buttons will be visible.\\ \\ Now we can display the dialogue box and initialise any controls that need it:\\ | + | </ |
+ | |||
+ | Note that in this particular case the same function is used for both the CTLCOLORDLG and CTLCOLORBTN messages because in each case all we want to do is change the background colour. If you don't change the background colour of the buttons to match the dialogue box background an ugly border around the buttons will be visible.\\ \\ Now we can display the dialogue box and initialise any controls that need it: | ||
+ | |||
+ | <code bb4w> | ||
PROC_showdialog(dlg%) | PROC_showdialog(dlg%) | ||
Line 33: | Line 47: | ||
SYS " | SYS " | ||
SYS " | SYS " | ||
- | Again, this is conventional.\\ \\ Finally we run our main loop which, for the purposes of the exercise, does nothing useful:\\ | + | </ |
+ | |||
+ | Again, this is conventional.\\ \\ Finally we run our main loop which, for the purposes of the exercise, does nothing useful: | ||
+ | |||
+ | <code bb4w> | ||
ON CLOSE PROC_closedialog(dlg%) : QUIT | ON CLOSE PROC_closedialog(dlg%) : QUIT | ||
ON ERROR PROC_closedialog(dlg%) : SYS " | ON ERROR PROC_closedialog(dlg%) : SYS " | ||
Line 46: | Line 64: | ||
PROC_closedialog(dlg%) | PROC_closedialog(dlg%) | ||
END | END | ||
- | Note that while subclassing is in effect you must avoid statements which may take a long time to execute, such as **GET**, **INKEY**, **INPUT** and **WAIT** (WAIT should be avoided even if the delay is short). You should also be careful not to use **SOUND** when the sound queue is already full. You can find suitable replacements for these functions in the [[http:// | + | </ |
+ | |||
+ | Note that while subclassing is in effect you must avoid statements which may take a long time to execute, such as **GET**, **INKEY**, **INPUT** and **WAIT** (WAIT should be avoided even if the delay is short). You should also be careful not to use **SOUND** when the sound queue is already full. You can find suitable replacements for these functions in the [[http:// | ||
+ | |||
+ | <code bb4w> | ||
DEF FNctlcolorbackgnd(M%, | DEF FNctlcolorbackgnd(M%, | ||
PRIVATE B% | PRIVATE B% | ||
Line 65: | Line 87: | ||
IF B%=0 SYS " | IF B%=0 SYS " | ||
=B% | =B% | ||
- | The colours are here specified in the usual Windows hexadecimal " | + | </ |
+ | |||
+ | The colours are here specified in the usual Windows hexadecimal " | ||
+ | |||
+ | <code bb4w> | ||
DEF FNctlcolorstatic(M%, | DEF FNctlcolorstatic(M%, | ||
CASE L% OF | CASE L% OF | ||
Line 75: | Line 101: | ||
ENDCASE | ENDCASE | ||
=B% | =B% | ||
- | Here **hStatic1%** is a global variable containing the handle of the particular Static Control whose colour needs to be changed. Because that handle isn't known until after you have shown the dialogue box, you will need to force the static control to redraw itself:\\ | + | </ |
+ | |||
+ | Here **hStatic1%** is a global variable containing the handle of the particular Static Control whose colour needs to be changed. Because that handle isn't known until after you have shown the dialogue box, you will need to force the static control to redraw itself: | ||
+ | |||
+ | <code bb4w> | ||
SYS " | SYS " | ||
SYS " | SYS " | ||
+ | </ | ||
+ | |||
Also, remember to initialise **hStatic1%** (e.g. to zero) so you don't get a 'No such variable' | Also, remember to initialise **hStatic1%** (e.g. to zero) so you don't get a 'No such variable' |
changing_20a_20control_27s_20colours.1522502348.txt.gz · Last modified: 2024/01/05 00:18 (external edit)