VC:窗口收缩和扩展的方法

采用一个高度为1矩形,暂作为窗口的分割线。

 

 CString str;
 if(GetDlgItemText(IDC_BUTTON2,str),str=="收缩<<")
 {
  SetDlgItemText(IDC_BUTTON2,"扩展>>");
 }
 else
 {
  SetDlgItemText(IDC_BUTTON2,"收缩<<");
 }

 static CRect rectLarge;
 static CRect rectSmall;
 
 if(rectLarge.IsRectNull())
 {
  CRect rectSeparator;
  GetWindowRect(&rectLarge);
  GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator);

  rectSmall.left=rectLarge.left;
  rectSmall.top=rectLarge.top;
  rectSmall.right=rectLarge.right;
  rectSmall.bottom=rectSeparator.bottom;
 }
 if(str=="收缩<<")
 {
  SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),
   SWP_NOMOVE | SWP_NOZORDER);
 }
 else
 {
  SetWindowPos(NULL,0,0,rectLarge.Width(),rectLarge.Height(),
   SWP_NOMOVE | SWP_NOZORDER);
 }

 

你可能感兴趣的:(编程)