Post by mePost by Jeff Partch [MVP]Post by VinceHello,
I would like to be able to create a CStatic object, to put it on a CDialog
and to move it.
But I have no idea how to do this.
Make it a member of the CDialog, call its Create and MoveWindow functions
during the lifetime of the dialog's HWND.
Hi Jeff,
I'm trying to do somthing similar. I declare and array of buttons in the
dialog and then try to crate them in runtime. The buttons do not appear.
void SelectChannelsDialog::MakeButtons()
{
int i,j,dy, dx, ledge, tedge;
CDC *dc;
CRect rect;
CString s;
dy = rect.Height() * 0.75 / 5;
dx = rect.Width() * 0.75 / 4;
GetClientRect(rect);
for(i=0; i<4; i++)
for(j=0;j<5; j++);
{
s.Format("%i",i*4 +j);
bt[i*4 +j].Create( s, BS_CHECKBOX | WS_CHILD |WS_VISIBLE,
CRect(ledge + i * dx, tedge + j * dy, dx/2, dy/2 ), this, NULL);
bt[i*4 +j].ShowWindow(SW_SHOW);
}
}
Any ideas?
Muz
Here's a few in advance of Jeff:
move GetClientRect to before first use (before the dy = line);
take the semicolon off the end of the second for statement of you'll do
nothing with it;
put something into ledge and tedge before use;
since you are creating 5 buttons per outer loop count, use i*5 instead of
i*4 or you'll crash;
you don't need showwindow as you already said WS_VISIBLE; and
you'll need to fix the code in the CRect position used in create to move the
right and bottom as well as the left and top else you'll not see most of
them at all.
Presumably you have declared bt as a member variable array of 20 CButton
Do those things and you'll see some checkboxes on your dialog...
hth,
Johnny.