-
January 13th, 2004, 11:58 AM
#1
In-Place label edit
How do I edit a (CStatic) label string at run time.
Examples/Links are cool.
-
January 13th, 2004, 12:01 PM
#2
One solution is to add a member variable of type CSting that corresponds to the static control via resource editor.
Kuphryn
-
January 13th, 2004, 01:06 PM
#3
Originally posted by kuphryn
One solution is to add a member variable of type CSting that corresponds to the static control via resource editor.
Interesting technique... It is new to me that you can add variables in the resource editor...
@voidspace: Do you mean editing or changing? In the first case, you'd better use a CEdit control instead (you can change its style between read-only and editable). If you just want to change its text at runtime, use ClassWizard to add a DDX member variable of type CString for the control. Make sure to change the control ID from the default IDC_STATIC to something else, as IDC_STATIC has a special meaning and will prevent you from adding a DDX variable.
-
January 13th, 2004, 02:11 PM
#4
Oh No!
And CStatic member control variables is required if you want to change the value programatically. ( also renaming)
I understand that.
What I meant was when the program is running. I have a label say
"Name"(displayed and it has a control variable) and adjacent to it I have a edit ctrl in which they type name. I want the user to be able to click on the label "Name" and the label should turn into a edit control momentarily and allow "Name" to be modified to "Alias". Upon lossing focus from that control it should turn back into a label.
In Place edting of static label
-
January 13th, 2004, 02:22 PM
#5
Originally posted by voidspace
In Place edting of static label
I see. So if a read-only edit control (which you temporarily change to editable) doesn't fit your needs, what about the following approach:
When the static control is clicked, dynamically create an edit control having the same bounds. As soon as it loses focus, get the text and destroy the control.
-
January 13th, 2004, 02:27 PM
#6
Excellent!
Will try that.
Also realised from ur post that a edit control can be used as a static label also.
-
January 13th, 2004, 02:32 PM
#7
Originally posted by voidspace
"Name"(displayed and it has a control variable) and adjacent to it I have a edit ctrl in which they type name. I want the user to be able to click on the label "Name" and the label should turn into a edit control momentarily and allow "Name" to be modified to "Alias". Upon lossing focus from that control it should turn back into a label.
In Place edting of static label
One approach is to have an edit control and a static the same size and location in the resource editor. Hide whichever one you don't want to be seen at the time. Sounds like a kind of counter intuitive user interface though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|