Native Print Dialog is called from Java Application and the user could click OK and Cancel to return back to the Main Application(print dialog is modal).We need to close the native dialog from the Application without human Intervention.(Something like setVisible(false) or dispose() for Java Components)Please suggest what must be done here.
Anu: I am assuming that you are talking about a Windows print dialog. (For *nix systems, I've only ever printed from a command line; no dialog to work with.) In your native code, once you get the handle to the PRINTDLG, try the following:
Note that the dialog will not display; this will force the printing to the system's default printer. If you don't have access to the native source, I'm not sure how to help you.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Originally posted by Cindy Glass: If you don't want to let your user input info why are you using a Dialog at all? Using a Dialog and then just hiding the fact that you are using it seems sort of silly to me.
'cause that's the Windows API This is the way the documentation says to print to a printer without showing the dialog box. As far as the API is concerned, the Dialog box and the printer settings are the same thing. It's just a matter of showing the settings to the user or not. [ April 02, 2003: Message edited by: Joel McNary ]
Joined: Apr 02, 2003
Thanks for the reply.I shall explain you why we need such an requirement. In Windows XP with JRE1.3.1_06(no other JRE could be used) ,the Print Dialog is Modal.So we need to click OK or Cancel in Print Dialog to get back focus to the main Application. But our problem is, sometimes when the Print Dialog is triggerd,the Application becomes unusable but the Print Dialog does not come up (view is missing). Even in ALT TAB we cannot find the Print Dialog.In this situation as OK or Cancel could not be triggered. So by setting a timer, if we do not get the print dialog response within a certain amount of time we need to close the dialog from Application so that the Main Application gains focus. Expecting you reply Anu
I had a similar problem (though not exact--I could still find the print dialog through ALT-TAB). My solution was to force the dialog to the front. Try this in your native code:
and then, where you initialize your Print dialog:
What you are doing is creating a function that the print dialog will call when it is initialized (the PrintDialogWindowToFront function). All that function does is force the dialog to the front. The second part simply lets the dialog know which function to call upon initialization and turns on the function call. Hope this helps.
Joined: Apr 02, 2003
Thanks for reply.We cannot include native code in our Application. Could you please tell whether there is any method with which the modality set for the Print Dialog could be removed? Anu
Hmm.... I'm afraid that I don't know of any way to set the modality through java. All of my experience with print dialogs has been in C++. I took a look at the java.awt.print package (which I assume you are using; if not, could you please tell us more about what you are doing?) and did not see anything about setting the modality of the Print Dialog. Anybody else have any ideas?