实现窗口的最大化和最小化

上一篇 / 下一篇  2008-01-10 16:14:18 / 个人分类:学习.net 使用编程100例

SetWindowPlacement():

The SetWindowPlacement function sets the show state and the restored, minimized, and maximized positions of the specified window.

GetWindowPlacement():

The GetWindowPlacement function retrieves the show state and the restored, minimized, and maximized positions of the specified window.

1、为菜单编辑器添加菜单——“窗口”,并为菜单添加所需的菜单项“最大化窗口”、“最小化窗口”;

2、为菜单项添加响应命令处理函数OnWindowMax、OnWindowMin;

3、设置showCmd,实现窗口的最大化与最小化;

通过函数GetWindowPlacement 获取当前窗口结构变量指针;再用showCmd确定窗口状态(最大化/最小化),最后通过函数SetWindowPlacement 设置并显示窗口;

void CMainFrame::OnWindowMax()
{
 WINDOWPLACEMENT lwndpl;
 WINDOWPLACEMENT *lpwndpl;
 lpwndpl=&lwndpl;
 GetWindowPlacement(lpwndpl);//获取当前窗口结构变量指针
 lpwndpl->showCmd=SW_SHOWMAXIMIZED;
 SetWindowPlacement(lpwndpl);//设置并来显示窗口


 // TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnWindowMin()
{
 WINDOWPLACEMENT lwndpl;
 WINDOWPLACEMENT *lpwndpl;
 lpwndpl=&lwndpl;
 GetWindowPlacement(lpwndpl);//获取当前窗口结构变量指针
 lpwndpl->showCmd=SW_SHOWMINIMIZED;
 SetWindowPlacement(lpwndpl);//设置并来显示窗口


 // TODO: 在此添加命令处理程序代码
}


TAG:

 

评分:0

我来说两句

Open Toolbar