博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.定义一个CRect保存启动后窗口大小。

 m_rect

2.在OninitDialog事件里写下如下代码

   GetWindowRect(& m_rect); 

   WINDOWPLACEMENT   wp;  

   wp.length=sizeof(WINDOWPLACEMENT);  

   wp.flags=WPF_RESTORETOMAXIMIZED; 

   wp.showCmd=SW_HIDE;     SetWindowPlacement(&wp);

    //设一个定时器,隐藏之后要回复原来的状态,或者在现实窗口的时间里回复也可以,

   SetTimer(6,1,NULL);

 

 3.Timer事件

//恢复原来大小

// SWP_HIDEWINDOW是隐藏选项,SWP_SHOWWINDOW好像是现实的选项。

 SetWindowPos(&wndNoTopMost,    m_rect.left,    m_rect.top,    m_rect.right,    m_rect.bottom,   SWP_HIDEWINDOW);  

KillTimer(6);

 -----------------------------------------------------------------

注:移动窗口到右下角代码

 void MoveToRightCorner(void)
{
   RECT rcWorkArea;
   //获得客户可用工作区
   if ( SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,0))
   {
       CRect rcWindow;
       GetWindowRect(rcWindow);
       //获得移动到右下角的区域
       CRect rcMoveRect;
       rcMoveRect.left  = rcWorkArea.right - rcWindow.Width();
       rcMoveRect.right = rcWorkArea.right;
       rcMoveRect.top = rcWorkArea.bottom - rcWindow.Height();
       rcMoveRect.bottom= rcWorkArea.bottom;
       MoveWindow(rcMoveRect);   
   }
}

 

 

posted on 2010-03-05 15:24  Likwo  阅读(4454)  评论(0编辑  收藏  举报