Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

Not Recommended Documentclose button

Important: The information in this document is Not Recommended and should not be used for new development.

Current information on this Reference Library topic can be found here:

The intermittent behavior of SetDialogItemText


Q: While updating some 'Classic' Dialog Manager code for Carbon I have noticed odd behavior with SetDialogItemText. Sometimes it works, other times it doesn't. I haven't been able to find a pattern for the misbehavior and I'm vexed. Will exorcism help?

A: Although a little exorcism never hurt anyone, our bet is it's not going to solve your problem. What you need to do is ask yourself the question, "Do I have an embedding hierarchy in my dialog?"

When embedding is on, you must pass the ControlRef returned by GetDialogItemAsControl to SetDialogItemText, not the item Handle returned by GetDialogItem.

ControlRef theControlRef;

GetDialogItemAsControl(theDialog, theDItem, &theControlRef);
SetDialogItemText((Handle)theControlRef, theText);


This is one of those often missed, sometimes forgotten facts. Documentation for this behavior can be found in the Inside Carbon Dialog Manager Reference under the section "Handling Text in Alert and Dialog Boxes."

Note: The current Appearance savy way to set text is by using the SetControlData API with the kControlEditTextTextTag tag then calling DrawOneControl to draw the item.


[Oct 30 2001]