Re: Easy way to modify dialog's controls?
On Aug 7, 12:26 am, "Nick Schultz" <nick.schu...@flir.com> wrote:
Since I already have the necessary information to fill the 4 controls, I =
was
wondering if I can fill them out on the fly without having to create a ne=
w
custom CDialog class and go through ddx
Heh, creating a derived dialog class with the help of MFC is normally
faster than anything else short of creating your own mini-framework
for dialogs.
But since you ask (warning: compiled with the head compiler)...
class CMySpecialDialog : public CDialog
{
std::map<UINT, CString> m_ControlValues;
virtual BOOL OnInitDialog()
{
CDialog::OnInitDialog();
for(std::map<UINT, CString>::const_iterator pItem =
m_ControlValues.begin(); pItem != m_ControlValues.end();
SetDlgItemText(pItem->first, pItem->second);
}
}
then, to use this
CMySpecialDialog d;
d.m_ControlValues[IDC_PROCID_STATIC] = _T("testing1234"); // etc
d.DoModal();
Explanation: due to what David says, you need to wait for dialog and
it's controls to exist, and that is, for example, after the base class
OnInitDialog(). Then, you can set your text (for loop above).
However, don't do this, do as Joe tells you... With MFC, resistance is
futile ;-)