需求,当前窗口,无论在何种分辨率显示器上,都在固定位置居中显示,如图.求完整代码,谢谢.各位.

解决方案 »

  1.   

    怎么看不到图,我吐血...
    http://www.yinyuepao.com/1.gif
    这是图地址.
      

  2.   

    如果不是上下左右都居中的话就要自己算了,用GetSystemMetrics获取屏幕长和宽,然后MoveWindow
      

  3.   

     
      Example(1):   Center   Window(   );   //Relative   to   it's   parent   
        
      //   Relative   to   Screen   
        
      Example(2):   Center   Window(CWnd::   GetDesktopWindow(   ));   
        
      //Relative   to   Application's   MainWindow   
        
      AfxGetMainWnd(   )   ->   Center   Window
    最苯的方法是
    Rect   rect;   
      GetClientRect(&rect);   
        
      int   dy=GetSystemMetric(SC_Y)   -   rect.Height())/2;   //GetSystemMetric的参数看MSDN   
      int   dx=GetSystemMetric(SC_X)   -   rect.Width())/2;     //GetSystemMetric的参数看MSDN   
      MoveWindow(dx,dy,dx   +   rect.Width(),dy   +   rect.Height());