• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 783
  • Last Modified:

Printing using ShellExecute without showing the print dialog!

Hello,

Is there any way to print an HTML file using the ShellExecute API but without showing the Windows print dialog?
The ShellExecute will use the associated application (IE) to print the file.
I think that I have read somewhere in MSDN that this is a security issue and that's why the print dialog is shown in IE when printing!
I know how to bypass the print dialog using the web browser control, but I don't want to use the web browser control!

Thank you.
0
BigBoss
Asked:
BigBoss
  • 7
  • 6
  • 3
1 Solution
 
BrianGEFF719Commented:
0
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

I haven't tried this suggestion, but suspect it would probably work...

The window handle returned from ShellExecute could be used in the SendMessage API in order to force a [RETURN] code (13) to the print dialog window.

[Like a more sophisticated "SendKeys" :)]

BFN,

fp.
0
 
BigBossAuthor Commented:
BrianGEFF719...did you read my question well?????
I said:
>>I know how to bypass the print dialog using the web browser control, but I don't want to use the web browser control!

fanpages...thank you for your comment. This is just a "workaround" and I suspect that it would work!
The ShellExecute does not return a window handle, rather, it returns a success of failure codes!
Can you provide code, please?

Thank you.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
[ fanpages ]IT Services ConsultantCommented:
Hi,

Sorry, I am confused, "ShellExecute" does return the ProcessID of the invoked executable.

Have you proven otherwise?

BFN,

fp.
0
 
BigBossAuthor Commented:
fanpages...the ShellExecute return codes are described in Q170918 of MSDN. It does not return any window handle or ProcessID. Probably, you are confusing it with the Shell function.

Thank you.
0
 
BrianGEFF719Commented:
Why dont you want to use IE?
You dont have to create a "control" on a form, you can do it purly with code.

-Brian
0
 
[ fanpages ]IT Services ConsultantCommented:
Oh, yes, I meant to type "ShellExecuteEx".
The SHELLEXECUTEINFO Structure's "Handle" item will contain the "ProcessId" information.

Are you familiar with this API call?

I can provide code if you are not.

BFN,

fp.

0
 
BigBossAuthor Commented:
BrianGEFF719...I am not sure if you can do it without at least adding a reference to your project.
In other words, the question is: Can my application load and its other functions work even if the user does not have IE?... thank you.

fanpages, can you please provide code for the specific task?, i.e. for sending a message to the print dialog that is opend by IE through my application (using ShellExecuteEx). And, if another instance(s) of my application (component) opens another print dialog(s) at the same time, would everything work fine???

Thank you.
0
 
BrianGEFF719Commented:
First, you can use the IE control entierly by reference, secondly, you are asking fanpages for examples to Open IE?? whats that about, any windows computer will work...because they all come with IE....you dont make sense.


-Brian
0
 
BrianGEFF719Commented:
I resign from this question....good luck.
0
 
BigBossAuthor Commented:
BrianGEFF719...thank you for your comment.
What I want to do is to have my application (ActiveX component) to be able to print several types of stuff, including html pages. If the user machine does not have IE installed, I want my component to still function for the other stuff. In addition, if the user machine has another browser, I want the component to be able to print html using that browser.
Now the problem with IE is that if I don't use the browser control to print, but use IE itself, it shows the print dialog, which I don't want.
If I include any references to the browser control or IE itself in my component, as far as I know, it won't load...am I wrong?

I am not sure if the case in clear now!
0
 
BrianGEFF719Commented:
go to project -> REFERENCES and check off microsoft internet controls


Private WithEvents IEObj As SHDocVw.InternetExplorer

Private Sub Form_Load()
   Set IEObj = New SHDocVw.InternetExplorer
   IEObj.Navigate "c:\yourxmlfile"
End SUb

Private Sub Form_Unload()
   Set IEObj = Nothing
End Sub

Private Sub IEObj_DocumentComplete(...)
   IEObj.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
   Unload Me
End Sub




You do not have to create a control on a form.

-Brian
0
 
BigBossAuthor Commented:
Brian...thank you for your comment and for the code.
Are you sure that my compiled component will load on a machine that does not have IE (and shdocvw.dll) installed?
As far as I know, if an application includes a reference that can not be found on the user machine, on load it will popup an error message and will exit!!!
Am I wrong???
I want my other functions in the component to work if the user does not have IE installed.

Thank you.
0
 
BrianGEFF719Commented:
What i am trying to explain is that all Windows based computers come pre-installed with IE. IE cannot be removed from Windows 95+. The entire operating system is based on IE!!!

-Brian
0
 
BigBossAuthor Commented:
Thanks...
0
 
BrianGEFF719Commented:
Do you need any further help with this issue?

-Brian
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now