CStatic *pStatic=new CStatic[20]; //控件数组
CRect rect1(5,5,270,25); //初始位置
int IDC_STATICX=0; //初始IDC,不能重复,如果用IDC_STATIC1---IDCSTATIC9,要在资源头定义
pStatic[0].Create("Recipe Parameters",SS_LEFT|WS_CHILD|WS_VISIBLE|SS_SUNKEN,rect1,this,IDC_STATIC);
for(int i=1;i<=15;i++)
{
IDC_STATICX=IDC_STATICX+i; //IDC自加
//pStatic[i-1].CreateEx(NULL,"STATIC","Staitc",WS_CHILD|WS_VISIBLE,rect1,this,IDC_STATICX,NULL); //创建按钮,和下句效果一样
pStatic[i].Create("Recipe Parameters",SS_LEFT|WS_CHILD|WS_VISIBLE|SS_SUNKEN,rect1,this,IDC_STATICX);
//rect1.left=rect1.left+100; rect1.right=rect1.left+90; //横向位置
GetDlgItem(IDC_STATICX)->EnableWindow( true );
rect1.top=rect1.top+20;
rect1.bottom=rect1.top+20;
rect1.left=5;
rect1.right=270;
}