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

Re: better than SetDlgItemText by Scherbina

Scherbina
Sun Nov 27 10:42:25 CST 2005

"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



Re: better than SetDlgItemText by ama

ama
Sun Nov 27 11:06:44 CST 2005


"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 :-}