正文

设定程序窗口初始信息2005-11-02 09:39:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/ainterly/6560.html

分享到:

1、在AppWizard中更改Windos Style 来改变窗口初始是否最大化、最小化,以及是否允许更改。

2、更方便的改变可以在PreCreateWindow()中,用代码实现,如

    (1)//centern window at a certain percentage of full screen

               #define PRCTG    50/100 //define percentage

               int xSize =::GetSystemMetrics(SM_CSSCREEN);// more  information of the function see MSDN

                int ySize=::GetSystemMetrics(SM_CYSCREEN);            

                cs.cx=xSize*PRCTG;//resize the  window

                cs.cy=ySize*PRCTG;

                cs.x=(xSize-cs.cx)/2;  

                 cs.y=(ySize-cs.cy)/2;

                 return CMainFrame::PreCreateWindow(cs);

       (2)  //delete the caption of the window

                  cs.style&=~FWS_ADDTOTITLE;// more information see MSDN about CREATESTRUCT

       (3) //remove the maximize and minimize button from caption

                  cs.style&=~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX);//you can remove only one button too

        (4) // fixed the application window

                   cs.style&=~WS_THICKFRAME;

         (5)//maximize the application window when execute

                   pMainFrame->ShowWindow(SW_SHOWMAXIMIZED)//in CWinApp

                   pMainFrame->UpdateWindow();//you can minimize too

          (6) //maximize a childwindow in a MDI application

                  cs.style=WS_CHILD|WS_VISIBLE|WS_OVERLAPPED|WS_CAPTION_

                  |WS_SYSMENU|FWS_ADDTOTITLE|WS_THICKFRAME

                  |WS_MINIMIZEDBOX|WS_MAXIMIZEDBOX|WS_MAXIMIZE;

                 return CMDIChildWnd::PreCreateWindow(cs);

 

              

         

         

阅读(2539) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册