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