怎样让程序启动时最大化,但又不允许用户再还原成原始大小或者改变窗口大小,谢谢!

解决方案 »

  1.   

    ShowWindow(SW_SHOWMAXIMIZED)就最大了。不允许改变可重载WM_SIZE。
      

  2.   

    你可以在app初始化函数中加入
    m_pMainWnd->ShowWindow(SW_MAXIMIZE);
      

  3.   

    ShowWindow(SW_MAXIMIZE);,屏蔽掉中间的那个最大化按钮,在CMainWnd::OnSize()中进行处理.
      

  4.   

    CMainFrame::PreCreateWindow(CreateStruct &cs)
    {
     cs.style=cs.style&~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
    }
      

  5.   

    我有个简单办法。
    把窗口属性设成没有标题栏。在初始化时:int iWidth = ::GetSystemMetrics(SM_CXSCREEN);
    int iHeight = ::GetSystemMetrics(SM_CYSCREEN);
    MoveWindow(0, 0, iWidth, iHeight);OK,谁也别想动了
      

  6.   

    各位大侠:
        用上面的方法试过之后,发现并没有完全解决问题
        比如说用户双击标题栏,应用程序同样会恢复成普通窗口,而且再也不能
    最大化。
         ZHENG017所说的重载CMainWnd::OnSize()方法。不知代码怎样写?还请
    赐教。
         还有其它的方法吗?
      

  7.   

    什么叫钩子截取wm_size信息
    代码怎么写?
    或者什么叫钩子?
    谢谢!
      

  8.   

    void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) 
    {
    switch(nID & 0xFFF0)
    {
    case SC_MOVE:
    return;
    case SC_RESTORE:
    if(!IsIconic())return;
             break;
    }
    CFrameWnd::OnSysCommand(nID, lParam);
    }
      

  9.   

    ON_WM_GETMINMAXINFO
    修改MINMAXINFO
      

  10.   

    不知在OnGetMinMaxInfo()函数中
    怎样修改MINMAXINFO?
      

  11.   

    同意 AloneWolf(孤狼)的方法
      

  12.   

    在对话框文挡的APP类中初始化,
    m_pMainWnd->ShowWindow(SW_MAXIMIZE);
    修改preCreateWindow
    CMainFrame::PreCreateWindow(CreateStruct &cs)
    {
     cs.style=cs.style&~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);
    }
      

  13.   

    我用了孤狼的函数,但好像还是不行
    我在class wizard中找不到onSysCommand命令,
    所以我是手工加入的这个函数,
    结果运行后,和没加没什么区别,还是能正常还原和最大化。
    不知何故?用dongchaomissyou(超)的方法,运行时双击标题栏还是可以还原,
    而且再也不能最大化。
      

  14.   

    好像要映射On_Sizing;将里面关于更改尺寸的屏掉(就是不让它变)
    然后可以用GetSysTemMenu(),得到关于最大化和关闭的系统菜单,将它设为gray,这样应该可以了吧.(具体函数名可能不准,就这意思)
      

  15.   

    修改MINMAXINFO 中的
        POINT ptMaxSize;
        POINT ptMinTrackSize;
        POINT ptMaxTrackSize;
    成员,都改成一样的窗口尺寸(这里是最大窗口尺寸)就可以了
    这样窗口大小就不会变化了
      

  16.   

    可截取系统消息,然后吃掉消息就行了(WINDOWS在最大化、最小化、改变大小都是用发消息实现的)
      

  17.   

    解决用户双击标题栏:
    接管窗口的WM_NCLBUTTONDBLCLK事件处理就可以。
      

  18.   

    WM_GETMINMAXINFO 
    <br />
     
    The  WM_GETMINMAXINFO  message  is  sent  to  a  window  when  the  size  or  position  of  the  window  is  about  to  change.  An  application  can  use  this  message  to  override  the  window's  default  maximized  size  and  position,  or  its  default  minimum  or  maximum  tracking  size.   
    <br />
    <br />
     
    A  window  receives  this  message  through  its  WindowProc  function.   
    <br />
    <br />
     
    LRESULT  CALLBACK  WindowProc( 
    <br />
     
        HWND  hwnd,              //  handle  to  window 
    <br />
     
        UINT  uMsg,              //  WM_GETMINMAXINFO 
    <br />
     
        WPARAM  wParam,      //  not  used 
    <br />
     
        LPARAM  lParam        //  window  information  (LPMINMAXINFO) 
    <br />
     
    ); 
    <br />
     
    Parameters 
    <br />
     
    wParam   
    <br />
     
    This  parameter  is  not  used.   
    <br />
     
    lParam   
    <br />
     
    Pointer  to  a  MINMAXINFO  structure  that  contains  the  default  maximized  position  and  dimensions,  and  the  default  minimum  and  maximum  tracking  sizes.  An  application  can  override  the  defaults  by  setting  the  members  of  this  structure.   
    <br />
     
    Return  Values 
    <br />
     
    If  an  application  processes  this  message,  it  should  return  zero.   
    <br />
    <br />
     
    Res 
    <br />
     
    The  maximum  tracking  size  is  the  largest  window  size  that  can  be  produced  by  using  the  borders  to  size  the  window.  The  minimum  tracking  size  is  the  smallest  window  size  that  can  be  produced  by  using  the  borders  to  size  the  window.   
    <br />
    <br />
     
    Requirements   
    <br />
     
        Windows  NT/2000:  Requires  Windows  NT  3.1  or  later. 
    <br />
     
        Windows  95/98:  Requires  Windows  95  or  later. 
    <br />
     
        Header:  Declared  in  Winuser.h;  include  Windows.h. 
    <br />
    <br />
     
    See  Also 
    <br />
     
    Windows  Overview,  Window  Messages,  MoveWindow,  SetWindowPos,  MINMAXINFO   
    <br />
    <br />
     
    Built  on  Thursday,  October  12,  2000Requirements   
    <br />
     
        Windows  NT/2000:  Requires  Windows  NT  3.1  or  later. 
    <br />
     
        Windows  95/98:  Requires  Windows  95  or  later. 
    <br />
     
        Header:  Declared  in  Winuser.h;  include  Windows.h. 
    <br />
     
    See  Also 
    <br />
     
    Windows  Overview,  Window  Messages,  MoveWindow,  SetWindowPos,  MINMAXINFO   
    <br />
      

  19.   

    要使窗口的大小不可改变,可以在该窗口的PreCreateWindow(CREATESTRUCT&  cs)中添加以下代码:cs.style&=~(WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX); 
     
    另外,还可以通过SetWindowLongPtr()方法修改窗口的风格。
     
    关于SetWindowLongPtr的使用方法可以参考 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winclass_3qia.asp 
     
    关于窗口风格的更详细的信息,请参考 
     
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_window_styles.asp 
      

  20.   

    截取WM_SYSCOMMAND消息。
    该消息参数为:
        uCmdType = wParam; // type of system command requested 
        xPos = LOWORD(lParam); // horizontal postion, in screen coordinates 
        yPos = HIWORD(lParam); // vertical postion, in screen coordinates 
        其 中 uCmdType表 示 用 户 的 选 择 : 
        SC_CLOSE Closes the window. 
        SC_CONTEXTHELP Changes the cursor to a question  with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message. 
        SC_DEFAULT Selects the default item; the user double-clicked the System menu. 
        SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate. 
        SC_HSCROLL Scrolls horizontally. 
        SC_KEYMENU Retrieves the System menu as a result of a keystroke. 
        SC_MAXIMIZE (or SC_ZOOM) Maximizes the window. 
        SC_MINIMIZE (or SC_ICON) Minimizes the window. 
        SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer. 
        SC_MOUSEMENU Retrieves the System menu as a result of a mouse click. 
        SC_MOVE Moves the window. 
        SC_NEXTWINDOW Moves to the next window. 
        SC_PREVWINDOW Moves to the previous window. 
        SC_RESTORE Restores the window to its normal position and size. 
        SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file. 
        SC_SIZE Sizes the window. 
        SC_TASKLIST Executes or activates Windows Task Manager. 
        SC_VSCROLL Scrolls vertically. 
      

  21.   

    谢谢各位大侠。
    我用了AloneWolf(孤狼)的方法,完全成功了。
    把方法奉献给大家:
    代码就是他上面给出的。
    WM_SYSCOMMAND消息在class wizard中找不到,
    要手工在消息映射中添加ON_WM_SYSCOMMAND就行。再次谢谢各位大侠的关注。