How Can I change the Caption on a button after it is clicked

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
byrne86
Newbie
Posts: 7
Joined: Fri Oct 15, 2010 7:56 pm

How Can I change the Caption on a button after it is clicked

Post by byrne86 » Sat Oct 16, 2010 2:59 pm

I changed this topic because I sorted the code out myself.

As the topic says, how can I change the caption of the button once it has been pressed.

Thanks

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

Post by JRL » Sun Oct 17, 2010 1:07 am

I wasn't sure if you still wanted this or not but for the sake of posterity here is an answer.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 299
  Top = 212
  HelpContext = 5000
  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 MSButton1: tMSButton
    Left = 80
    Top = 37
    Width = 265
    Height = 124
    Caption = 'Please Press Button 1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1


//The Dialog handler tells the script to go to a specified 
//subroutine when an event occurs.  In this case it is the
//click of button 1.
AddDialogHandler>Dialog1,msButton1,OnClick,Button1WasPressed

Show>dialog1,res1

SRT>Button1WasPressed
  //SetDialogProperties is used to dynamically change the properties
  //of dialog objects.  In this case we're changing the value of the
  //"Caption" property of Button 1.
  SetDialogProperty>Dialog1,msButton1,Caption,Button 1 Was Pressed
  Wait>3
  Exit>0
END>Button1WasPressed

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Oct 19, 2010 3:44 am

Thanks for posting this example JRL.

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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