HTML Preview

A Snippet from: Dominic_Fichera

Let>FileSaved=False
Dialog>MainMenu
object MainMenu: TForm
  Left = 3645
  Top = 452
  HelpContext = 5000
  BorderIcons = [biSystemMenu, biMaximize]
  Caption = 'Web-Preview'
  ClientHeight = 337
  ClientWidth = 634
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  Menu = MainMenu
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  DesignSize = (
    634
    337)
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 8
    Top = 0
    Width = 618
    Height = 41
    Anchors = [akLeft, akTop, akRight]
    BevelOuter = bvNone
    TabOrder = 4
    object Bold: tMSButton
      Left = 8
      Top = 8
      Width = 25
      Height = 25
      Caption = 'B'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'Calibri'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 0
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Red: tMSButton
      Left = 104
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Red'
      TabOrder = 3
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Purple: tMSButton
      Left = 488
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Purple'
      TabOrder = 9
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Blue: tMSButton
      Left = 424
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Blue'
      TabOrder = 8
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Cyan: tMSButton
      Left = 360
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Cyan'
      TabOrder = 7
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Green: tMSButton
      Left = 296
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Green'
      TabOrder = 6
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Yellow: tMSButton
      Left = 232
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Yellow'
      TabOrder = 5
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Orange: tMSButton
      Left = 168
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Orange'
      TabOrder = 4
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Italics: tMSButton
      Left = 72
      Top = 8
      Width = 25
      Height = 25
      Caption = 'I'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'Calibri'
      Font.Style = [fsItalic]
      ParentFont = False
      TabOrder = 2
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Underline: tMSButton
      Left = 40
      Top = 8
      Width = 25
      Height = 25
      Caption = 'U'
      Font.Charset = ANSI_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'Calibri'
      Font.Style = [fsUnderline]
      ParentFont = False
      TabOrder = 1
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object Black: tMSButton
      Left = 488
      Top = 8
      Width = 57
      Height = 25
      Caption = 'Black'
      TabOrder = 10
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object White: tMSButton
      Left = 552
      Top = 8
      Width = 57
      Height = 25
      Caption = 'White'
      TabOrder = 11
      DoBrowse = False
      BrowseStyle = fbOpen
    end
  end
  object HTML: tMSMemo
    Left = 8
    Top = 40
    Width = 289
    Height = 289
    Text = ''#13#10''#13#10''#13#10#13#10''#13#10''
    ScrollBars = ssBoth
    Anchors = [akLeft, akTop, akBottom]
    TabOrder = 0
  end
  object Website: tMSHTMLViewer
    Left = 304
    Top = 40
    Width = 322
    Height = 285
    TabOrder = 1
    Anchors = [akLeft, akTop, akRight, akBottom]
    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 Browse: tMSButton
    Left = 312
    Top = 312
    Width = 75
    Height = 25
    Caption = 'Browse'
    TabOrder = 3
    Visible = False
    DoBrowse = False
    InitialDir = 'D:\Users\%USER_NAME%\Desktop'
    Filter = 'HTML Files (*.html) | *.HTML|All Files (*.*) | *.*'
    BrowseStyle = fbSave
  end
  object Open: tMSButton
    Left = 392
    Top = 312
    Width = 75
    Height = 25
    Caption = 'Open'
    TabOrder = 2
    Visible = False
    DoBrowse = False
    Filter = 'HTML Files (*.html) | *.HTML|All Files (*.*) | *.*'
    BrowseStyle = fbOpen
  end
  object MainMenu: tMSMainMenu
    object MenuItem1: tMSMenuItem
      Caption = '&File'
      object OpenMenu: tMSMenuItem
        Caption = '&Open'
      end
      object SaveAs: tMSMenuItem
        Caption = '&Save As'
      end
      object Close: tMSMenuItem
        Caption = '&Close'
      end
    end
  end
end
EndDialog>MainMenu

AddDialogHandler>MainMenu,HTML,OnChange,doCreateWebsite
AddDialogHandler>MainMenu,,onClose,doClose
AddDialogHandler>MainMenu,Close,onClick,doClose
AddDialogHandler>MainMenu,SaveAs,onClick,doSaveAs
AddDialogHandler>MainMenu,OpenMenu,onClick,doOpen
AddDialogHandler>MainMenu,Bold,onClick,doBold
AddDialogHandler>MainMenu,Underline,onClick,doUnderline
AddDialogHandler>MainMenu,Italics,onClick,doItalics
AddDialogHandler>MainMenu,Red,onClick,doRed
AddDialogHandler>MainMenu,Orange,onClick,doOrange
AddDialogHandler>MainMenu,Yellow,onClick,doYellow
AddDialogHandler>MainMenu,Green,onClick,doGreen
AddDialogHandler>MainMenu,Cyan,onClick,doCyan
AddDialogHandler>MainMenu,Blue,onClick,doBlue
AddDialogHandler>MainMenu,Purple,onClick,doPurple
AddDialogHandler>MainMenu,Black,onClick,doBlack
AddDialogHandler>MainMenu,White,onClick,doWhite

Show>MainMenu
Label>IdleLoop
Wait>.001
Goto>IdleLoop
LabelToVar>HTML1,varDefaultHTML
/*
HTML1:






*/
SRT>doCreateWebsite
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    SetDialogProperty>MainMenu,Website,HTML,varWebsiteText
    If>FileSaved=True
    SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%*
    Endif
END>doCreateWebsite
SRT>doClose
  Exit>0
END>doClose
SRT>doSaveAs
    SetDialogProperty>MainMenu,Browse,Filename,*.html
    SetDialogProperty>MainMenu,Browse,doBrowse,True
    GetDialogProperty>MainMenu,Browse,Filename,varFilename
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetDialogProperty>MainMenu,,Caption,varWindowName
    Position>html,varFilename,1,varHTMlExists,TRUE
    If>varHTMlExists<1
        ConCat>varFilename,.html
    Endif
    /*
    IfFileExists>%varFilename%
    Ask>%varFilename% already exists. Would you like to overwrite?,varFileExists
        If>varFileExists=YES
            DeleteFile>%varFilename%
            WriteLn>%varFilename%,nWLNRes,varWebsiteText
            Let>FileSaved=True
            SetDialogProperty>MainMenu,,Caption,%varWindowName% - %varFilename%
        Endif
    Else
        WriteLn>%varFilename%,nWLNRes,varWebsiteText
        Let>FileSaved=True
        SetDialogProperty>MainMenu,,Caption,%varWindowName% - %varFilename%
    Endif
    */
    IfFileExists>%varFilename%
        DeleteFile>%varFilename%
    Endif
    WriteLn>%varFilename%,nWLNRes,varWebsiteText
    Let>FileSaved=True
    SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%
END>doSaveAs
SRT>doOpen
    SetDialogProperty>MainMenu,Open,doBrowse,True
    GetDialogProperty>MainMenu,Open,Filename,varFilename
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    ReadFile>varFilename,varHTML
    If>varHTML=##NOFILE##
        SetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    Else
        SetDialogProperty>MainMenu,HTML,Text,varHTML
        SetDialogProperty>MainMenu,Website,HTML,varHTML
        SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%
    Endif
END>doOpen

SRT>doBold
    SetDialogProperty>MainMenu,HTML,Default,True
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doBold
SRT>doUnderline
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doUnderline
SRT>doItalics
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doItalics
SRT>doRed
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doRed
SRT>doOrange
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doOrange
SRT>doYellow
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doYellow
SRT>doGreen
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doGreen
SRT>doCyan
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doCyan
SRT>doBlue
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doBlue
SRT>doPurple
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doPurple
SRT>doBlack
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doBlack
SRT>doWhite
    GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
    GetClipboard>varOriginalText
    Let>varNewText=%varOriginalText%
    StringReplace>varWebsiteText,varOriginalText,varNewText,varNewText
    SetDialogProperty>MainMenu,HTML,Text,varNewText
    SetDialogProperty>MainMenu,Website,HTML,varNewText
END>doWhite

Select the code above to paste into your macro. Or: View Raw Text

Link: http://www.mjtnet.com/snip.htm?g=55ecf9604bc47

Forum Embed Code - click to select all then copy (CTRL-C):

When pasting into the forum do NOT modify the script code or it will not match what is in the database - create a new snippet instead!