Home > Archive > VC Language > November 2005 > better than SetDlgItemText
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
better than SetDlgItemText
|
|
| Maileen 2005-11-27, 7:57 am |
| Hi,
I have some text controls on my form. I would like to change dynamically
their caption.
For now i use SetDlgItemText, but is ther something like :
Label3.Caption = "my text";
thanks a lot,
Maileen
| |
| Scherbina Vladimir 2005-11-27, 7:04 pm |
| "Maileen" <noemail@nospam.com> wrote in message
news:OO1Bue18FHA.1276@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I have some text controls on my form. I would like to change dynamically
> their caption.
>
> For now i use SetDlgItemText, but is ther something like :
>
> Label3.Caption = "my text";
>
> thanks a lot,
> Maileen
AFAIR such syntaxt comes from VB, .NET world.
In VC you may change control's caption using SetDlgItemText or using
SendMessage with WM_SETTEXT (note: SetDlgItemText uses SendMessage).
--
Scherbina Vladimir
| |
|
|
"Maileen"> Hi,
>
> I have some text controls on my form. I would like to change dynamically
> their caption.
>
> For now i use SetDlgItemText, but is ther something like :
>
> Label3.Caption = "my text";
I suppose you could wrap the text portion of a control :
class CControlText
{
public:
CControlText() : m_hCtrl(NULL), m_txt("") {}
CControlText(HWND hCtrl){ m_hCtrl = hCtrl; }
~CControlText(){}
HWND m_hCtrl;
string m_txt;
LPCSTR operator = (LPCSTR pz)
{
if( ::IsWindow(m_hCtrl) )
{
SendMessage(m_hCtrl, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)pz);
m_txt = pz;
}
return m_txt.c_str();
}
};
Later , after the parent Dialog is initialized :
CControlText Label3( GetDlgItem(IDC_BUTTON1) );
Label3 = "some caption here.";
string caption = Label3.m_txt;
etc ...
Although i personaly thing that SetDlgItemText is simple enough :-}
|
|
|
|
|