Usually, you do not need to communicate with the compiler about a control to which you refer; however there are a couple of cases in which you must declare a control. This can happen when the compiler cannot safely assume that you are referring to a control, or when the compiler cannot find the location of the dialog box of the control that you are trying to access. The compiler needs to tell the linker which dialog box is supposed to contain your control. The syntax for declaring a control variable is:
[_nocheck] ObjectName ControlName;
Or you can use:
[_nocheck] _control ControlName;
ObjectName can be one of the following:
_check_box
_combo_box
_command_button
_gauge
_hscroll
_image
_label
_list_box
_picture_box
_radio_button
_text_box
_vscroll
The _nocheck keyword tells the compiler not to check if the control exists on the current dialog box.
The [_nocheck] ObjectNameControlName; declaration is only permitted outside the scope of a function. The [_nocheck] _control ControlName; declaration already supports local procedure scope.
Example:
// Create a form with a command button named ctlcancel, and gauge named ctlgauge1.
// Set the cancel and default properties of the command button to true.
//
#include "slick.sh"
static boolean gcancel;
_command test()
{
// Need to tell compiler ctlgauge1 is a control because
// the form1_wid.ctlgauge1 is too ambiguous.
_control ctlgauge1;
// Show the form modeless so there is no modal wait.
form1_wid=show("form1");
// Disable all forms except form1_wid.
disabled_wid_list=_enable_non_modal_forms(0,form1_wid);
gcancel=0;
for (i=1;i<=100;++i) {
// Read mouse, key, and all other events until none are left or
// until the variable gcancel becomes true.
process_events(gcancel);
if (gcancel) {
break;
}
// Do work here. Replace the delay below with the operation you want to do.
delay(10);
form1_wid.ctlgauge1.p_value=i;
}
// Enable all forms that were disabled.
_enable_non_modal_forms(1,0,disabled_wid_list);
form1_wid._delete_window();
}
defeventtab form1;
ctlcancel.lbutton_up()
{
gcancel=1;
}