Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Html Print Preview

Status
Not open for further replies.

GabrielTdr

Programmer
Sep 12, 2006
2
RO
Greetings, this question is not entirely delphi related but i don't know on what other form to post it.

I have a Grid in delphi which can export its data in HTML.

Now, i don't want the users to open the file manually and select print - preview ...

i want to be able to show a print preview of the HTML. I used ShellExec and opened the Html using the default browser ... but is there a way to open directly in print preview?

or is there another way to show a preview of the html file?
 
Could you not place a web browser control on a form and navigate to the file that way?


Hope this helps.

[vampire][bat]
 
unfortunately no. because the browser will only show me the document. I need the entire print preview interface. Control over the landscape portrait, margins etc .... Next page etc

I can write a form which looks like the print preview one but it will take me a day and i hoped there is a way to open iexplorer(for example) in print preview mode
 
I wrote my web browser years ago and I'm not sure what methods the stock one have and what methods it have not, but this is the way I print/preview with it:

Code:
procedure TXWebBrowser.InvokeCMD(    InvokeIE    : boolean;
                                     Val1, Val2  : integer;
                                 var vaIn, vaOut : OleVariant);
  const
    CLSID_WebBrowser: TGUID = '{ED016940-BD5B-11cf-BA4E-00C04FD70816}';
  var
    CmdTarget : IOleCommandTarget;
    PtrGUID   : PGUID;
  begin
    New(PtrGUID);
    if InvokeIE
      then PtrGUID^ := CLSID_WebBrowser
      else PtrGuid := PGUID(nil);
    if Document <> nil
      then
        try
          Document.QueryInterface(IOleCommandTarget, CmdTarget);
          if CmdTarget <> nil
            then
              try
                CmdTarget.Exec(PtrGuid, Val1, Val2, vaIn, vaOut);
              finally
                CmdTarget._Release;
              end;
        except end;
    Dispose(PtrGUID);
  end;

procedure TXWebBrowser.Print(Prompt : boolean);
  var
    vaIn, vaOut : Olevariant;
    OlePrompt   : integer;
  begin
    vaIn := varEmpty;
    vaOut := varEmpty;
    if Prompt
      then OlePrompt := OLECMDEXECOPT_PROMPTUSER
      else OlePrompt := OLECMDEXECOPT_DONTPROMPTUSER;
    InvokeCmd(FALSE, OLECMDID_PRINT, OlePrompt, vaIn, vaOut);
  end;

The other point is that my browser have a lot of interfaces implemented (IDocHostShowUI, IDocHostUIHandler, IDispatch, IServiceProvider, IOleCommandTarget), but at glance those methods above are not using any of them.

HTH.
buho (A).


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top