CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Setting the Window size

    hi

    in a simple SDI-Application created by the MFC-wizard, how do I set the windowsize upon the initialization of the program?
    I´ve tried inserting the following commands in the CView::PreCreateWindow function:

    CWnd* mywin = AfxGetMainWnd(); // Points to my only application window ( I think )
    mywin->SetWindowPos(mywin, 300,300,200,100,SWP_SHOWWINDOW);

    It runs ok but does not do anything at all. Where should this statement be located or what would be the correct command?

    thx


  2. #2
    Join Date
    Apr 1999
    Posts
    24

    Re: Setting the Window size

    You just set the CREATESTRUCT to the disered width, hieght, and starting position :
    Look up CREATESTRUCT in the msdn libraray
    example:
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    if( !CMDIFrameWnd::PreCreateWindow(cs) )
    return FALSE;
    // TODO: Modify the Window class or styles here by modifying
    // the CREATESTRUCT cs
    cs.cx = ?;
    cs.cy = ?;
    cs.x = ?;
    cs.y = ?;

    return TRUE;
    }


  3. #3
    Join Date
    Apr 1999
    Posts
    11

    Re: Setting the Window size

    You should determine the size you want before call
    CWnd::PreCreateWindow

    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    // the CREATESTRUCT cs
    cs.cx = ?;
    cs.cy = ?;
    cs.x = ?;
    cs.y = ?;

    return CFrameWnd::PreCreateWindow(cs);
    }

    Good luck.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured