HTMLViewer -read up and display a single page?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

HTMLViewer -read up and display a single page?

Post by bbrink » Thu Sep 01, 2016 8:26 pm

Hi,

Can the HTMLViewer be fed a single HTML page from a known location? If so how?

I have c:\mydocs\helloworld.html

The html file gets written by another program, I want to write a script that can read it up and display it. I do not want to use a browser because I need to lock this down.

Thanks in advance,

Bob

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: HTMLViewer -read up and display a single page?

Post by JRL » Thu Sep 01, 2016 8:56 pm

Something like this? The dialog viewer will not give the same results as a browser. You may need to do a lot of tweaking to the html and to the dialog to make it look like you want it to look.

Code: Select all

HTTPRequest>https://www.mjtnet.com,,get,,vData,,,,

Dialog>Dialog1
object Dialog1: TForm
  Left = 388
  Top = 128
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 900
  ClientWidth = 1600
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  Position = poScreenCenter
  TextHeight = 13
  object MSHTMLViewer1: tMSHTMLViewer
    Left = 0
    Top = 0
    Width = 1600
    Height = 900
    TabOrder = 8
    BorderStyle = htFocused
    DefFontName = 'Times New Roman'
    DefPreFontName = 'Courier New'
    HistoryMaxCount = 0
    NoSelect = False
    PrintMarginBottom = 2.000000000000000000
    PrintMarginLeft = 2.000000000000000000
    PrintMarginRight = 2.000000000000000000
    PrintMarginTop = 2.000000000000000000
    PrintScale = 1.000000000000000000
  end
  object MSButton1: tMSButton
    Left = 288
    Top = 531
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

SetDialogProperty>Dialog1,MSHTMLViewer1,html,vdata
show>dialog1,

bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: HTMLViewer -read up and display a single page?

Post by bbrink » Thu Sep 01, 2016 9:48 pm

Wow, I see what you mean about messy. I know browsers did a lot of heavy lifting but it is quite something to put it up against the viewer.

Instead of HTML, I could output c:\mydocs\helloworld.jpg -that would eliminate the formating issues except the length of the jpg may exceed the dialog. If I used HTMLViewer to display the JPG would I get scrollbars? Can you provide example?

Thanks again, you have been very helpful,

Bob

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: HTMLViewer -read up and display a single page?

Post by JRL » Fri Sep 02, 2016 1:26 pm

There is a sample script that ships with Macro Scheduler called "Display Image Example". I modified it slightly so that it captures a large image and displays a large image and also so that the dialog has scroll bars. You, of course, will use your own image rather than the screen capture from the first line of the script. To do that you need to replace "%temp_dir%dialogsample.bmp" with the path and name of the image you wish to display. Macro Scheduler dialogs can display image types .BMP, .JPG and .PNG.

You will set the size of the image object defined in the dialog block (MSImage1)to the size of the jpg you wish to display. In the sample below the size is Width = 2000 x Height = 2000.



Code: Select all

ScreenCapture>0,0,2000,2000,%temp_dir%dialogsample.bmp

Dialog>Dialog1
object Dialog1: TForm
  Left = 10
  Top = 0
  HelpContext = 5000
  AutoScroll = True
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  ClientWidth = 439
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSImage1: tMSImage
    Left = 0
    Top = 0
    Width = 2000
    Height = 2000
    LoadImage = ''
  end
end
EndDialog>Dialog1

SetDialogProperty>Dialog1,MSImage1,LoadImage,%temp_dir%dialogsample.bmp

Show>Dialog1,res1

DeleteFile>%temp_dir%dialogsample.bmp

bbrink
Pro Scripter
Posts: 71
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: HTMLViewer -read up and display a single page?

Post by bbrink » Sun Sep 25, 2016 9:52 pm

thank you again for your help!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts