-
Dynamic Controls
I am writing a reusable class based on CEdit and everything seems to be working OK except that the control does not appear as 3D when created dynamically in a dialog (i.e. no resource ID) but rather appears as a plain old Win16 edit box. The control does appear as 3D when used in a dialog with an associated resource ID.
I would like to create a good framework for dynamic dialgs without having to mess with the resource editor.
BTW, Can anyone point me to a good book or website dealing with creating controls dynamically at runtime?
TIA
-
Re: Dynamic Controls
Hello!
I had the same problem with editbox created dynamiclly. It disappeared when I followed the following style.
void CPropEdit::Create(DWORD style, const RECT &rect, CWnd *pParentWnd, int nNewIndex)
{
CreateEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | style, rect, pParentWnd, 0);
SetFont(pParentWnd->GetFont(), FALSE);
nIndex=nNewIndex;
}
Here I used nIndex to keep track of componentindexes in the dialog.
Good luck
Hussam
-
Re: Dynamic Controls
I came across the same problem before with a custom (CEdit based) control we use at work. I found that by hiding and re-showing it that it drew properly.CMyEdit myEdit;
myEdit.Create(.........);
myEdit.ShowWindow(SW_HIDE);
myEdit.ShowWindow(SW_SHOW);
Ugly, but it worked.
-
Re: Dynamic Controls
Many thanks, it worked like a charm!