modal dialog box not closing quickly enough

Hi.

I have a single threaded MDI application with several windows that are concurrently open and displayed during normal operation. I need to print the contents of a user-selected window. Per end-user request I display a CDialog based modal dialog box that allows the user to select the window he wants to print and then click on the OK button. I have code that then takes a bitmap snapshot of the requested window and prints it to the printer(from KB article q186736).

So far so good, but if the dialog box overlaps the window that the user wants to print, the overlapping part of the dialog box is also printed. This doesn't make sense to me - the dialog should completely go away as I understand it. FWIW here's a code snippet:

if (wantdialog)

{

CPrintWindowDlg dlg;

if (dlg.DoModal() == IDOK)

{

index = dlg.m_nSelection;

}

}

switch (index)

{

case 0:

m_pMyFirstView->PostMessage(WM_PRTWND);

break;

etc etc etc

Anyway, the point of the snippet is to show that that dialog is enclosed by braces, and should be long gone when the rest of the code executes. That's what I think should happen but obviously it's not.

Any ideas All I want is for this dialog to completely disappear before I take a bitmap snapshot of the window to be printed. BTW, this code occurs in the document class.

Thanks in advance

mike



Answer this question

modal dialog box not closing quickly enough

  • Michael Bachar

    Viorel. wrote:

    Before posting the WM_PRTWND message, I would suggest updating the content of the window:

    m_pMyFirstView->UpdateWindow();

    Or do this within the handler of WM_PRTWND message. I hope this helps.

    If Viorel's suggestion doesn't help you out, I'd recommend you to post such questions in win32.programmer.ui newsgroup, since visual c++ general forum is not handling such UI issues, see visual c++ general forum's scope. I am going to close this thread by mark it as answered.

    good luck

    rico



  • Nichole158860

    Before posting the WM_PRTWND message, I would suggest updating the content of the window:

    m_pMyFirstView->UpdateWindow();

    Or do this within the handler of WM_PRTWND message. I hope this helps.


  • RPriesing

    Forgot to mention this is built using Visual Studio 2003.


  • modal dialog box not closing quickly enough