CEdit pedit[20];
for(int i=0;iCreate(text,WS_CHILD|WS_VISIBLE|SS_LEFT,CRect(10,10,20,10),this,1);
CFont *font = new CFont;
font->CreateFont(20,0,0,0,70,0,0,0, ANSI_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "宋體");
pstatic->SetFont(font);
if(nTemp<=8)//動態產生個數小於8個
{
pedit[i].MoveWindow(250,30+i*40,100,20,true);
pstatic->MoveWindow(100,30+i*40,100,20,true);
pedit[i].ShowWindow(SW_SHOW); pstatic->ShowWindow(SW_SHOW);
}
else if(nTemp>8&&nTemp<=20)//動態產生個數大於8個小於20個
{
int half=nTemp/2;
if(iMoveWindow(70,30+i*30,70,20,true);
pedit[i].ShowWindow(SW_SHOW);
pstatic->ShowWindow(SW_SHOW);
}
else
{
pedit[i].MoveWindow(350,30+(i-half)*30,70,20,true);
pstatic->MoveWindow(250,30+(i-half)*30,70,20,true);
pedit[i].ShowWindow(SW_SHOW);
pstatic->ShowWindow(SW_SHOW);
}
} 關於cedit的創建可以參閱 http://faq.csdn.net/read/194594.html
以下爲效果圖