用代码控制新建Console的位置大小

CreateNewConsole(AnsiString& name, int x,int y, int width,int height)

{

PROCESS_INFORMATION pi;

STARTUPINFO si;

SECURITY_ATTRIBUTES sa;

 

ZeroMemory(&si,sizeof(si));

si.cb=sizeof(si);

si.wShowWindow = SW_SHOW;

si.dwFlags = STARTF_USESHOWWINDOW |STARTF_USEPOSITION | STARTF_USESIZE ;

si.dwX = x;

si.dwY = y;

si.dwXSize = width;

si.dwYSize = height;

 

CreateProcess(NULL,

name.c_str(),

         NULL,

         NULL,

         true,

         CREATE_NEW_CONSOLE,

         NULL,

         NULL,

         &si,

         &pi);

 

}

//----------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

  int x,y,width,height ;

  x = 10; y = 50;

  width = 10;height = 5;

  for(int i = 0; i <5 ;i++)

  {

    CreateNewConsole("cmd.exe",x,y, width,height);

    x += 150;

  }

}

 

你可能感兴趣的:(用代码控制新建Console的位置大小)