Results 1 to 8 of 8

Thread: Resize MFC SDI Window?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    Belgium
    Posts
    28

    Resize MFC SDI Window?

    How do I resize my SDI window (i want to do it in my OnNewDocument in the document class)?

    Is it something like this?

    Code:
    CMainFrame *pMF = (CMainFrame*)AfxGetMainWnd();
    pMF->SetWindowPos(NULL, 0,0,50,50, SWP_NOMOVE);
    thanks.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, why not try it?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    Belgium
    Posts
    28
    my program crash with that piece of code, i've tried several things, but i think that i have to create a pointer to my mainframe, but i dunno how...

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What kind of crash? I don't think you may pass NULL as first parameter. Use SWP_NOZORDER and pass any of the constants if you don't want to change the z order.

    And you don't need to cast to a CMainFrame, CWnd supports SetWindowPos, so you can write
    AfxGetMainWnd()->SetWindowPos(...);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, and I recommend that you learn using the debugger, it's a wonderful thing...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    Belgium
    Posts
    28
    Well, the pointer to the MainFrame "pMF" or "AfxGetMainWnd()" returns with no value. (pMF = 0x00000000 {CMainFrame hWnd=???})

    So I get the error: "Unhandled exception at 0x7c208dd4 (mfc70d.dll) in MineSweeper.exe: 0xC0000005: Access violation reading location 0x00000020".

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Then you obviously don't have a valid main window, at least not one that's properly registered with MFC.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Can you post your InitInstance function here?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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