CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 1999
    Posts
    12

    How to... Resize & Maximize Modal Dialog Box In Runtime?

    To anyone who can help:

    How to make a modal dialog box that is resizable and can be shown maximized (by a programmer in runtime) so all its controls (text boxes, buttons, listboxes, etc.) are resized (and redrawn) as well?

    Or in other words how to resize or maximize a modal dialog box in runtime and than show it on the screen like that, with all its controls in place?

    I tried MoveWindow or SetWindowPlacement with UpdateWindow functions but the controls in the dialog aren't properly redrawn.

    MoveWindow is OK if you don't show the dialog box resized or maximized from the start, but the user changes the size of the dialog box.

    Please help & thanks a lot,
    Marko



  2. #2
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: How to... Resize & Maximize Modal Dialog Box In Runtime?


    There seems to be a bug(?) in repaint when resizing a dialog.
    Use of SetWindowPos(...., SWP_NOCOPYBITS | ...) adds some flicker, but fixes the redraw bug.
    If the flicker is annoying, you might want to be looking for an advanced "Resize" ir "Layout" Manager that uses DeferSetWindowPos.

    Does this answer YOUR question?
    Peter



  3. #3
    Join Date
    Nov 1999
    Posts
    12

    Re: How to... Resize & Maximize Modal Dialog Box In Runtime?

    I'm afraid this doesn't answer my question!

    Since I want dialog to be resized before it is shown on the screen I put:

    BOOL CMyDialog::OnInitDialog()
    {
    CDialog::OnInitDialog();

    ...

    SetWindowPos (
    &wndNoTopMost,
    m_iX, m_iY, m_iW, m_iH,
    SWP_SHOWWINDOW|SWP_NOCOPYBITS
    );
    ...
    }



    ... and the dialog is completely gray and featureless (although it is resized).

    A friend has told me that I have to register my class (CMyDialog) for this to work properly. But I don't know how to do this. Any guidelines please?

    Thanks,
    Marko



  4. #4
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: How to... Resize & Maximize Modal Dialog Box In Runtime?

    Oh, I see...
    Well, what happens to the Dialgo if you use a simple MoveWindow in OnInitDialog? This should work. Do you get repaint artifacts? Or do you want the dialog items to adapt to the dialogs new size (i.e. an "resize manager") ?

    A workaround might be to add an ShowWindow(SW_SHOW) after the SetWindowPos, or MoveWindow. since the dlg isn't displayed initially there should be no annoying flicker.

    Waiting...
    Peter


  5. #5
    Join Date
    Nov 1999
    Posts
    12

    Re: How to... Resize & Maximize Modal Dialog Box In Runtime?

    Ah! It works! Happiness! Joy! :-)

    I’ve put:

    SetWindowPos(
    &wndNoTopMost,
    m_iX, m_iY, m_iW, m_iH,
    SWP_SHOWWINDOW|SWP_NOCOPYBITS
    );

    But NOT in OnInitDialog – it doesn’t work there.
    I’ve put this code in OnShowWindow – that’s the only way this will work.

    I’ve made a little trial program and it resizes its dialog OK, so I wondered how this program works, and the bigger one doesn’t. Of course, I’ve copied everything from the trial program to the bigger program and there you go. :-)

    Anyway Peter, I’m making a shareware system utility, give me your e-mail and I’ll send you a copy for free once when it’s finished (I’m in a good mood).

    Thanks a lot Peter,
    Marko



  6. #6
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: Cool! See my profile for email address (may change)

    new software! cool! that would be nice of you.


    For the address see my profile, currently it's hauptmannp@yahoo.com, but that might change until then...


    Have a good Time
    Peter


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