Grey items in a dialog
I am making an import dialog box, and I'd like to disable the OK button until the user has put stuff into the box that makes sense.
Actually, the default stuff will make sense, but I want to disable the OK button if the user puts something stupid in there (like trying to import thingy #5 from a file that has only 4 thingies. You get the point), and then re-enable the OK button after they delete the stupid stuff and put back in the thoughtful, intelligent stuff.
I'm sure this is a common thing, but suddenly I can't find any documentation or code examples in my FB books to do it.
I even looked twice and indeed, I was again stricken with the lack of info.
Can anyone point me in the right direction? I'm not afraid of the toolbox, and looked in that part of the Handbook as well to no avail.
You need to get the handle to the control in question (the OK button) using CALL GETDITEM(theDLOGPtr&,theItemNo,iType,iHandle&,itemRect)
and then grey it out using
CALL HILITECONTROL(iHandle&,255)or bring it back via:
CALL HILITECONTROL(iHandle&,0)If you want to toggle it, you can take a look at PEEK([iHandle&] + _contrlHilite), which will either be 255 (it is grey) o 0 (normal)
Heres a snippet of one of the DLOG functions (got lots of DLOG functions) that I use for item control hilighting.
LOCAL FN EnableDlgItem(DLOGptr&,whichItem,enabled) DIM rect;8:' common rect CALL GETDITEM(DLOGptr&,whichItem,theType,theHandle&,rect):' read LONG IF (theType AND _CtrlItem) = _CtrlItem IF enabled THEN Highlight = 0 ELSE Highlight = 255 CALL HILITECONTROL (theHandle&, Highlight) END IF END FNPass it the DLOGptr (the window pointer for the DLOG), the item # in the dlog and _True or _False (for enable/disable).
Heres one for toggling a check box :
LOCAL FN GetControlVal(DLOGptr&,whichItem):' values a check box DIM rect;8:' common rect CALL GETDITEM(DLOGptr&,whichItem,theType,theHandle&,rect):' read END FN=FN GETCTLVALUE(theHandle&):' get the value ' LOCAL FN ToggleDlgCheckBox(DLOGptr&,whichItem):' toggles a check box DIM rect;8:' common rect CALL GETDITEM(DLOGptr&,whichItem,theType,theHandle&,rect):' read CALL SETCTLVALUE (theHandle&,(FN GETCTLVALUE(theHandle&) AND 1) XOR 1) theVal=FN GetControlVal(DLOGptr&,whichItem):' then the control val END FN = theValEven got ones for a series of radio buttons if anyone needs it.