代码改变世界

MFC界面伸缩

2012-11-05 13:49  龙成  阅读(288)  评论(0编辑  收藏  举报
 1 CString str;
 2     if(GetDlgItemText(IDC_BUTTON1,str),str == "收缩<<")
 3     {
 4         SetDlgItemText(IDC_BUTTON1,"扩展>>");
 5     }
 6     else
 7     {
 8         SetDlgItemText(IDC_BUTTON1,"收缩<<");
 9     }
10     static CRect rectLarge;
11     static CRect rectSmall;
12     if(rectLarge.IsRectNull())
13     {
14         CRect rectSeparator;
15         GetWindowRect(&rectLarge);
16         GetDlgItem(IDC_P)->GetWindowRect(&rectSeparator);
17         rectSmall = rectLarge;
18 
19         rectSmall.bottom = rectSeparator.top;
20     }
21     if(str == "收缩<<")
22     {
23         SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),SWP_NOMOVE|SWP_NOZORDER);
24     }
25     else
26     {
27         SetWindowPos(NULL,0,0,rectLarge.Width(),rectLarge.Height(),SWP_NOMOVE|SWP_NOZORDER);
28     }

其中,IDC_P是pictrue空间的标识、、