Click to See Complete Forum and Search --> : Dynamic Controls


arf
May 17th, 1999, 01:43 PM
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

Hussam
May 18th, 1999, 05:26 AM
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

BrianOG
May 18th, 1999, 07:42 AM
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.

arf
May 18th, 1999, 09:24 AM
Many thanks, it worked like a charm!