Dialogue with Multiple Buttons

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
alexmuir
Newbie
Posts: 6
Joined: Wed Jul 22, 2009 10:16 pm

Dialogue with Multiple Buttons

Post by alexmuir » Fri Aug 10, 2018 5:57 am

Hello

OK having been greatly helped by Marcus, I now have a dialogue with one button that calls a program or file.

I have now put a second button on the dialogue.

How and what do I add to the script to get this button to call a program or routine.

Alternatively is there a sample dialogue with 3-4 buttons that I can use to work out it out?

Many thanks

Alex

alexmuir
Newbie
Posts: 6
Joined: Wed Jul 22, 2009 10:16 pm

Re: Dialogue with Multiple Buttons

Post by alexmuir » Fri Aug 10, 2018 6:39 pm

OK getting there. Any help would be appreciated.
Runs button1 ok but not button2?

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

Dialog>Dialog1
object Dialog1: TForm
Left = 517
Top = 259
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'ALEX SHORT CUTS'
ClientHeight = 481
ClientWidth = 476
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 Label1: TLabel
Left = 16
Top = 24
Width = 51
Height = 13
Caption = 'GENERAL'
end
object Label2: TLabel
Left = 144
Top = 24
Width = 54
Height = 13
Caption = 'LYNCHPIN'
end
object Label3: TLabel
Left = 256
Top = 24
Width = 64
Height = 13
Caption = 'PRECISE360'
end
object MSButton1: tMSButton
Left = 12
Top = 46
Width = 75
Height = 25
Caption = 'Hardware'
TabOrder = 8
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 12
Top = 94
Width = 75
Height = 25
Caption = 'Confidential'
TabOrder = 9
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton3: tMSButton
Left = 136
Top = 48
Width = 75
Height = 25
Caption = 'Cover Letter'
TabOrder = 10
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton4: tMSButton
Left = 136
Top = 96
Width = 75
Height = 25
Caption = 'Title'
TabOrder = 11
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton5: tMSButton
Left = 136
Top = 144
Width = 75
Height = 25
Caption = 'Quote'
TabOrder = 12
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton6: tMSButton
Left = 252
Top = 46
Width = 75
Height = 25
Caption = 'Cover Letter'
TabOrder = 13
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton7: tMSButton
Left = 252
Top = 94
Width = 75
Height = 25
Caption = 'Title'
TabOrder = 14
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton8: tMSButton
Left = 252
Top = 142
Width = 75
Height = 25
Caption = 'Quote'
TabOrder = 15
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton9: tMSButton
Left = 136
Top = 192
Width = 75
Height = 25
Caption = 'Autoplay CD'
TabOrder = 16
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton10: tMSButton
Left = 252
Top = 190
Width = 75
Height = 25
Caption = 'Autoplay CD'
TabOrder = 17
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton11: tMSButton
Left = 136
Top = 240
Width = 75
Height = 25
Caption = 'CD Burner'
TabOrder = 18
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton12: tMSButton
Left = 252
Top = 238
Width = 75
Height = 25
Caption = 'CD Burner'
TabOrder = 19
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSButton1,Onclick,DoClick
Show>Dialog1,modalResult
SRT>DoClick
MessageModal>MSButton1
ExecuteFile>C:\Office\HardwareNetworks\HWNET.pdf,
End>DoClick

AddDialogHandler>Dialog1,MSButton2,Onclick,DoClick
Show>Dialog1,modalResult
SRT>DoClick
MessageModal>MSButton2
ExecuteFile>C:\Office\CONFIDENTIALITYUNDERTAKING.docx,
End>DoClick

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Dialogue with Multiple Buttons

Post by Marcus Tettmar » Sat Aug 11, 2018 12:37 pm

You have two subroutines with the same name. The script will find the first one and use that.

Each subroutine should have a different name. Unless you want both dialog handlers to run the same subroutine.

Create two different subroutines with two different names. Have each AddDialogHandler reference each one. So one for button 1 and one for button 2.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: Dialogue with Multiple Buttons

Post by zabros2020 » Thu Aug 30, 2018 1:13 pm

I agree with Marcus...seperate subs
But if you want to use one sub
This code here does one sub for all buttons:

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dialog>Dialog1
object Dialog1: TForm
Left = 517
Top = 259
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'ALEX SHORT CUTS'
ClientHeight = 481
ClientWidth = 476
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 Label1: TLabel
Left = 16
Top = 24
Width = 51
Height = 13
Caption = 'GENERAL'
end
object Label2: TLabel
Left = 144
Top = 24
Width = 54
Height = 13
Caption = 'LYNCHPIN'
end
object Label3: TLabel
Left = 256
Top = 24
Width = 64
Height = 13
Caption = 'PRECISE360'
end
object MSButton1: tMSButton
Left = 12
Top = 46
Width = 75
Height = 25
Caption = 'Hardware'
TabOrder = 8
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 12
Top = 94
Width = 75
Height = 25
Caption = 'Confidential'
TabOrder = 9
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton3: tMSButton
Left = 136
Top = 48
Width = 75
Height = 25
Caption = 'Cover Letter'
TabOrder = 10
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton4: tMSButton
Left = 136
Top = 96
Width = 75
Height = 25
Caption = 'Title'
TabOrder = 11
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton5: tMSButton
Left = 136
Top = 144
Width = 75
Height = 25
Caption = 'Quote'
TabOrder = 12
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton6: tMSButton
Left = 252
Top = 46
Width = 75
Height = 25
Caption = 'Cover Letter'
TabOrder = 13
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton7: tMSButton
Left = 252
Top = 94
Width = 75
Height = 25
Caption = 'Title'
TabOrder = 14
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton8: tMSButton
Left = 252
Top = 142
Width = 75
Height = 25
Caption = 'Quote'
TabOrder = 15
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton9: tMSButton
Left = 136
Top = 192
Width = 75
Height = 25
Caption = 'Autoplay CD'
TabOrder = 16
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton10: tMSButton
Left = 252
Top = 190
Width = 75
Height = 25
Caption = 'Autoplay CD'
TabOrder = 17
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton11: tMSButton
Left = 136
Top = 240
Width = 75
Height = 25
Caption = 'CD Burner'
TabOrder = 18
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton12: tMSButton
Left = 252
Top = 238
Width = 75
Height = 25
Caption = 'CD Burner'
TabOrder = 19
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSButton1,Onclick,DoClick(1)
AddDialogHandler>Dialog1,MSButton2,Onclick,DoClick(2)
Show>Dialog1,modalResult
SRT>DoClick
  If>doClick_var_1=1
    MessageModal>MSButton1
    ExecuteFile>C:\Office\HardwareNetworks\HWNET.pdf,
  EndIf
  
  If>doClick_var_1=2
    MessageModal>MSButton2
    ExecuteFile>C:\Office\CONFIDENTIALITYUNDERTAKING.docx,
  EndIf
End>DoClick
Loving MS's Capabilities!!!

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