|
-
July 15th, 1999, 09:34 AM
#1
Changing static text
I wrote a small dialog box with one static text control and wanted to change the static text on the LMouseDown and the LMouseUp. I made a call to SetDlgItem( IDC_STATIC, CString) but the text didn't change. Do I need to repaint the screen? How do I make the text appear when the Left Mouse buton is down?
A sample of my code is:
void CMyDialog::OnLMouseButtonDown()
{
CString myString("Mouse button is down");
SetDlgItem( IDC_STATIC, myString);
CDialog::OnLMouseButtonDown();
}
Any help is appreciated...
-Dave
-
July 15th, 1999, 09:50 AM
#2
Re: Changing static text
Rename the Ctrl ID to something else besides IDC_STATIC. Like IDC_MYSTATIC or
something like that. It will work then.
Wayne
-
July 15th, 1999, 10:31 AM
#3
Re: Changing static text
Wayne,
Why does changing the name make that much of a difference. The exact name if I recal was IDC_STATIC1. What does MFC do with the default given names? Do they do something different than they would do with user provided names for controls?
-Dave
-
July 15th, 1999, 10:42 AM
#4
Re: Changing static text
The default name for all static controls is IDC_STATIC. They all get the same ID, because they are supposed to be static (i.e. not changing), so Visual C assumes that you are not going to want (or need) to uniquely identify any on these controls, so he gives them all IDC_STATIC. MFC probably just returns if ID == IDC_STATIC or something.
HTH
--michael
-
July 15th, 1999, 11:09 AM
#5
Re: Changing static text
The IDC_STATIC is shared by multiple controls in the dialog. To get another look at what you're trying to do, here is an alternate solution:
CStatic *pStatic = (CStatic *)GetDlgItem(IDC_STATIC);
if ( pStatic != NULL )
pStatic->SetWindowText("string of text");
If pStatic is NULL, this means that there was a problem identifying which control is IDC_STATIC.
Regards,
Paul McKenzie
-
July 16th, 1999, 09:21 PM
#6
Re: Changing static text
Hi,
first I would gave the Static-text a memberVariable (STRG-W) called m_staticedit then I would do this with the onclick. Don't forget the UpdateData(FALSE); //thats mostly the problem, when a text should change
Black Racer
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
|