I've got a dialog box with an Edit Text item. Depending on the state of some radio buttons, I want the Edit Text to either be grayed and uneditable, or normal and editable. What's the proper way to do this?
but it seems to have no effect. But if I use the same technique of calling HiliteControl() on a radio button, it becomes grayed and unclickable. Is there something special that needs to be done to disable an Edit Text item?
I'm frightened by how much of this came flooding back to me. I hope I'm remembering correctly.
Edit text items aren't controls; they're creatures of the Dialog Manager. My guess is you get away with passing them to HighlightControl because they don't appear in the window's control list.
Dialog Manager shares a single instance of TextEdit among all the edit text items. Deactivating it is fine as long as you do nothing which induces Dialog Manager to activate it and as long as you understand that only makes the insertion point stop blinking. (Possibly if you have a selection there is some visual effect there as well.) Deactivating the instance of TE doesn't make the edit text box or text look disabled or prevent the user from clicking in them. I seem to remember all sorts of schemes to work around this, none of which were very good.
Dialog Manager is evil. Unfortunately, you are targeting old systems, so without exerting significant effort it's the best you have available.
More came back to me. Historically, part of the solution was to…
Create an additional item, more specifically a user item, overlaying each edit text item which you might disable. When you want one of the edit text items to look disabled, make sure the corresponding user item is implemented. This amounts to calling SetDItem and casting the item handle to a function pointer. The function in question should use a particular transfer mode to fill gray over top of the edit text item. Done right, this knocks out roughly half of the black pixels of the edit text item, producing the disabled look. The user item can of course remain implemented as long as the relevant function is smart enough to draw nothing when the corresponding edit text item is enabled.
Of course, in addition to striking me as clumsy, this only works acceptably on black-and-white screens and even then only solves part of the problem, the visual part. The fact that the edit text item may be in use when you decide to disable it is a separate problem, as is the fact that the user may still tab into a (visually) "disabled" edit text item. There must have been a solution for these problems as well but I can't remember what they were.