May 12, 2016

Customizing Message/Input Boxes

Filed under: General,Scripting — Marcus Tettmar @ 12:30 pm

Every now and then someone asks something like “How do I change the font in a modal dialog box?” or “Can I make an Input box multi-line?”.

Well, no, you can’t do those things to the standard Message/MessageModal or Input box functions. But, don’t forget that with Macro Scheduler you have the ability to create your own dialogs and make them act and feel pretty much any way you like. So the answer to the above questions, is “Create your own versions”.

As an example, let’s say you want a modal dialog that looks and acts much like the standard modal message box created by MessageModal. Only you want the text to be green in an italicized aerial font. Here you go:

//this would go at the top - customize as you wish
Dialog>CustomMsgBox
object CustomMsgBox: TForm
  Left = 493
  Top = 208
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  BorderStyle = bsSingle
  Caption = 'My Message'
  ClientHeight = 170
  ClientWidth = 319
  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 MSMemo1: tMSMemo
    Left = 0
    Top = 0
    Width = 321
    Height = 137
    Font.Charset = ANSI_CHARSET
    Font.Color = clGreen
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold, fsItalic]
    ParentFont = False
    TabOrder = 0
  end
  object MSButton1: tMSButton
    Left = 121
    Top = 143
    Width = 75
    Height = 25
    Caption = 'OK'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>CustomMsgBox

SRT>ShowMsg
  SetDialogProperty>CustomMsgBox,,Position,poScreenCenter
  SetDialogProperty>CustomMsgBox,MSMemo1,Text,ShowMsg_Var_1
  Show>CustomMsgBox,r
END>ShowMsg

//do this to call your message
Let>MyMsg=Hello world, this is a lovely custom message box
GoSub>ShowMsg,MyMsg

And don’t forget that once created you can call the dialog any time you like. And if you want to use it in lots of scripts then put the dialog block and subroutine into an include file and use Include> at the top of each script you want to use it in.

Now, it’s over to you. Use your imagination and style the dialog any way you like. We have some Custom Dialog tutorials here: Part1, Part2