No announcement yet.

Strange PrintDlg behavior

  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange PrintDlg behavior

    I have an application in which I call PrintDlg(pd) from several points. I note the following common behaviour when the printer is unavailable.

    First time I try to print, the PrintDlg appears and then when I click OK I get an error in my print routine. Nothing strange so far. Then I try to print again. This time the dialog doesn't appear but in its place there's a message box with "The printer could not be found". Again, nothing strange.

    The strange thing is the text in the caption bar of the message box, which seems to depend on the pd.hWndOwner member of the PRINTDLGAPI structure passed to the dialog. I see the following.

    pd.hWndOwner			Message box caption
    Main application window		same as application window
    A QHTM control			"Printer Error"
    A graphics pane			"Printer Error"
    A multi line edit control	the whole contents of the edit control
    The thing that really surprises me, and looks very ugly, is the behaviour when the parent window is an edit control. Is this a Windows bug or some mistake on my part?



    [This message has been edited by Keith Waters (edited September 09, 2001).]

  • #2
    The .hWndOwner member should be set to the handle of the dialog/window that is launching PrintDlg().

    Your message seems to imply that you are setting the .hWndOwner member to that of a <U>control</U> in the dialog/window, rather than the dialog/window itself.

    If I understand the PrintDlg() error dialog caption effect properly, it is doing a GetWindowText(Pd.hWndOwner) to derive the caption text for the error dialog. However, if the returned text is NULL (an emty string), it is substituting "Printer Error" as the caption.

    This would make sense, since the error dialog would inherit the caption text of the parent window/dialog, which is likely to be your application name, or some other equally important title. Hence, it gives you the "strange" caption text effect you see when you nominate the handle of a control as the parent window.

    Does this help?

    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    mailto:[email protected]


    • #3

      Your prompt reply does help and confirms what I was already suspecting - that it is doing GetWindowText(Pd.hWndOwner).

      Actually, I've got round the problem. I could set pd.hWndOwner to the main application window whenever I call PrintDlg but the caption of my main window can include a long path name that would appear in the message box caption. I don't want that so I set the %PD_NOWARNING flag, to suppress the message, and then use CommDlgExtendedError() to get the error status and display my own message box as appropriate.

      Many thanks for the help