//On Off Toggle Buttons //This must be included to use this control, mailing updatestate will //assures that the proper mail messages are sent to turn off/on the buttons //#DEFINE nMSG_UPDATETOGGLE 10003 //The mail message should look like this, where the state is 0 or 1 //mail (nMSG_UPDATETOGGLE, , ) s_OnOff { GUI_CREATE { int nXOffset = 100 int total_buttons = 2 int nYes = 0 //Flag to change text to Yes/No int i object oOn = s_Text oOn.nFontID = IDS_F_OM_LABEL oOn.cTextColor = cWhite oOn.nJustify = 1 object oOff = s_Text oOff.nFontID = IDS_F_OM_LABEL oOff.cTextColor = cWhite oOff.nJustify = 1 object o_radiobutton[total_buttons] } GUI_INIT { if (nYes) { oOn.nResID = IDS_GN_YES_LC oOff.nResID = IDS_GN_NO_LC } else { oOn.nResID = IDS_GN_ON oOff.nResID = IDS_GN_OFF } oOn.location = location.x + 22,location.y + 1,nZ_TEXT initialize(oOn) oOff.location = location.x + nXOffset + 22,location.y + 1,nZ_TEXT initialize(oOff) for(i = 0; i < total_buttons; i++) { o_radiobutton[i] = s_multistatepanetoggle o_radiobutton[i].location = location.x + (i * nXOffset),location.y, 25 o_radiobutton[i].file = WPATH "radio_17x17_4state.tga" o_radiobutton[i].total_states = 4 o_radiobutton[i].id = i o_radiobutton[i].text = "" initialize(o_radiobutton[i]) } } GUI_MAILBOX { int i for(i = 0; i < total_buttons; i++) { if (sender != o_radioButton[i]) { // turn off every button but the one just received mail(1, o_radioButton[i]) } } if sender == o_radiobutton[0] { mail(nMSG_OPTIONON,parent) } if sender == o_radiobutton[1] { mail(nMSG_OPTIONOFF,parent) } if (getmessage(0) == nMSG_UPDATETOGGLE) { if(getmessage(1) == 1) { mail(2, o_radiobutton[0]) mail(1, o_radiobutton[1]) } else if(getmessage(1) == 0) { mail(1, o_radiobutton[0]) mail(2, o_radiobutton[1]) } } } }