Create and show multiple dialogs

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
nodochau
Pro Scripter
Posts: 131
Joined: Wed Jan 16, 2019 12:59 pm

Create and show multiple dialogs

Post by nodochau » Tue Sep 06, 2022 5:46 pm

Hello All,
How to create 2 or three dialogs and show them all on screen?
I would like to create two of them and show each of them on my two screens. (one screen one dialog)

Thanks

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Create and show multiple dialogs

Post by Dorian (MJT support) » Tue Sep 06, 2022 6:32 pm

Just give each a unique name :

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label1'
  end
end
EndDialog>Dialog1


Dialog>Dialog2
object Dialog2: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label2'
  end
end
EndDialog>Dialog2


Dialog>Dialog3
object Dialog3: TForm
  Left = 1073
  Top = 214
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label3'
  end
end
EndDialog>Dialog3

show>dialog1
show>dialog2
show>dialog3


label>loop
wait>0.5
goto>loop
Yes, we have a Custom Scripting Service. Message me or go here

nodochau
Pro Scripter
Posts: 131
Joined: Wed Jan 16, 2019 12:59 pm

Re: Create and show multiple dialogs

Post by nodochau » Wed Sep 07, 2022 12:26 pm

Thanks a lot Dorian.

nodochau
Pro Scripter
Posts: 131
Joined: Wed Jan 16, 2019 12:59 pm

Re: Create and show multiple dialogs

Post by nodochau » Wed Sep 07, 2022 12:45 pm

And I am not able to set the dialog3 position to the second screen.
I am using these:

Code: Select all

SetDialogProperty>Dialog1,,Left,0
SetDialogProperty>Dialog1,,Top,10
SetDialogProperty>Dialog2,,Left,800
SetDialogProperty>Dialog2,,Top,10
SetDialogProperty>Dialog3,,Left,1920
SetDialogProperty>Dialog3,,Top,10

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Create and show multiple dialogs

Post by Dorian (MJT support) » Wed Sep 07, 2022 1:15 pm

Are you using SetDialogProperty before or after Show? Use it after :

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 500
  Top = 1000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label1'
  end
end
EndDialog>Dialog1


Dialog>Dialog2
object Dialog2: TForm
  Left = 500
  Top = 2000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label2'
  end
end
EndDialog>Dialog2


Dialog>Dialog3
object Dialog3: TForm
  Left = 500
  Top = 3000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label3'
  end
end
EndDialog>Dialog3

show>Dialog1
show>Dialog2
show>Dialog3

SetDialogProperty>Dialog1,,Left,0
SetDialogProperty>Dialog1,,Top,10
SetDialogProperty>Dialog2,,Left,800
SetDialogProperty>Dialog2,,Top,10
SetDialogProperty>Dialog3,,Left,1920
SetDialogProperty>Dialog3,,Top,10

label>loop
wait>0.5
goto>loop
Also ensure your screen coordinates are correct - I always restart Macro Scheduler after connecting my 2nd screen.
Yes, we have a Custom Scripting Service. Message me or go here

nodochau
Pro Scripter
Posts: 131
Joined: Wed Jan 16, 2019 12:59 pm

Re: Create and show multiple dialogs

Post by nodochau » Wed Sep 07, 2022 2:00 pm

Thanks. It worked now.

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

Re: Create and show multiple dialogs

Post by JRL » Wed Sep 07, 2022 7:17 pm

Glad the previous code sample is working for you.

For a different perspective.
Because I usually use modal dialogs I use the MoveWindow> function to preset dialog positions. Don't need a loop after the dialog calls.

Changed the x position for Dialog3 as I only have one monitor.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 500
  Top = 1000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label1'
  end
end
EndDialog>Dialog1

Dialog>Dialog2
object Dialog2: TForm
  Left = 500
  Top = 2000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label2'
  end
end
EndDialog>Dialog2

Dialog>Dialog3
object Dialog3: TForm
  Left = 500
  Top = 3000
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 162
  ClientWidth = 1170
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -28
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 240
  TextHeight = 32
  object Label1: TLabel
    Left = 392
    Top = 40
    Width = 164
    Height = 64
    Caption = 'Label3'
  end
end
EndDialog>Dialog3
Let>Win_UseHandle=1
  MoveWindow>Dialog1.handle,0,10
  MoveWindow>Dialog2.handle,800,10
  MoveWindow>Dialog3.handle,1720,10
Let>Win_UseHandle=0

show>Dialog1
show>Dialog2
show>Dialog3,

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