Changing the Caption on a Label that's on a Page Control

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

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

Changing the Caption on a Label that's on a Page Control

Post by jpuziano » Sat Jul 23, 2011 5:06 pm

Hi Marcus and all,

Once a dialog is defined, I use SetDialogProperty> to change what I need to change later as the script runs... like this:

SetDialogProperty>Dialog1,Label3,Caption,%my_caption%

However, I have a label on the second pane of a two-pane panel - how do I write the above line to change the caption on that label?

Could someone please post a short example showing how to do this?

Please and thanks...
Last edited by jpuziano on Sun Jul 24, 2011 7:21 pm, edited 1 time in total.
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 - :-)

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun Jul 24, 2011 11:24 am

Hi jpuziano,
Is this what you want?

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = 572
  Top = 176
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 206
  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 Panel1: TPanel
    Left = 8
    Top = 8
    Width = 185
    Height = 65
    Caption = 'Panel1'
    TabOrder = 0
    object Label1: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label1'
    end
  end
  object Panel2: TPanel
    Left = 8
    Top = 80
    Width = 185
    Height = 65
    Caption = 'Panel2'
    TabOrder = 1
    object Label2: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label2'
    end
  end
  object MSButton1: tMSButton
    Left = 8
    Top = 152
    Width = 185
    Height = 25
    Caption = 'Change Label 1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 8
    Top = 184
    Width = 185
    Height = 25
    Caption = 'Change Label 2'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 3
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,msButton1,Onclick,ChangeLabel1
AddDialogHandler>Dialog1,msButton2,Onclick,ChangeLabel2
AddDialogHandler>Dialog1,,Onclose,Exit
Show>Dialog1
Let>Kline1=0
Let>Kline2=0

Label>Loop
Wait>.1
Goto>Loop

SRT>ChangeLabel1
Add>Kline1,1
  SetDialogProperty>Dialog1,Label1,Caption,Counter %Kline1%
END>ChangeLabel1

SRT>ChangeLabel2
Add>Kline2,1
  SetDialogProperty>Dialog1,Label2,Caption,Counter %Kline2%
END>ChangeLabel2


SRT>Exit
  Exit>1
END>Exit

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

Post by jpuziano » Sun Jul 24, 2011 7:19 pm

Hi Rain,

Thanks for posting that... I see your code does what I described but I described it incorrectly. I had said my label was on the "second pane of a two-pane panel" but what I should have said was... my label is on the second page of a three-page "Page Control".

I have added the Page Control to your code and re-posted it below.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 97
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 500
  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 Panel1: TPanel
    Left = 8
    Top = 8
    Width = 185
    Height = 65
    Caption = 'Panel1'
    TabOrder = 0
    object Label1: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label1'
    end
  end
  object Panel2: TPanel
    Left = 8
    Top = 80
    Width = 185
    Height = 65
    Caption = 'Panel2'
    TabOrder = 1
    object Label2: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label2'
    end
  end
  object MSButton1: tMSButton
    Left = 8
    Top = 152
    Width = 185
    Height = 25
    Caption = 'Change Label 1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 8
    Top = 184
    Width = 185
    Height = 25
    Caption = 'Change Label 2'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 3
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object PageControl1: TPageControl
    Left = 205
    Top = 8
    Width = 289
    Height = 137
    TabOrder = 4
    object TTabSheet
      Caption = 'Page1'
    end
    object TTabSheet
      Caption = 'Page2'
      object Label3: TLabel
        Left = 8
        Top = 24
        Width = 201
        Height = 17
        Caption = 'Label3'
      end
    end
    object TTabSheet
      Caption = 'Page3'
    end
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,msButton1,Onclick,ChangeLabel1
AddDialogHandler>Dialog1,msButton2,Onclick,ChangeLabel2
AddDialogHandler>Dialog1,,Onclose,Exit
Show>Dialog1
Let>Kline1=0
Let>Kline2=0
Label>Loop
Wait>.1
Goto>Loop

SRT>ChangeLabel1
Add>Kline1,1
  SetDialogProperty>Dialog1,Label1,Caption,Counter %Kline1%
END>ChangeLabel1

SRT>ChangeLabel2
Add>Kline2,1
  SetDialogProperty>Dialog1,Label2,Caption,Counter %Kline2%
END>ChangeLabel2

SRT>Exit
  Exit>1
END>Exit
If you click on the tab for Page 2, you'll see Label 3. I want to be able to change the caption text for Label 3 using SetDialogProperty>.

If you, Marcus, JRL or anyone out there know how to do this, it would be greatly appreciated...

...thanks all and 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 - :-)

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun Jul 24, 2011 9:17 pm

This works for me. When you click "Change Label 3" Label3 on page 2 updates whether the page is selected or not.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 500
  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 Panel1: TPanel
    Left = 8
    Top = 8
    Width = 185
    Height = 65
    Caption = 'Panel1'
    TabOrder = 0
    object Label1: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label1'
    end
  end
  object Panel2: TPanel
    Left = 8
    Top = 80
    Width = 185
    Height = 65
    Caption = 'Panel2'
    TabOrder = 1
    object Label2: TLabel
      Left = 8
      Top = 8
      Width = 32
      Height = 13
      Caption = 'Label2'
    end
  end
  object MSButton1: tMSButton
    Left = 8
    Top = 152
    Width = 185
    Height = 25
    Caption = 'Change Label 1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 8
    Top = 184
    Width = 185
    Height = 25
    Caption = 'Change Label 2'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 3
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object PageControl1: TPageControl
    Left = 205
    Top = 8
    Width = 289
    Height = 137
    TabOrder = 4
    object TTabSheet
      Caption = 'Page1'
    end
    object TTabSheet
      Caption = 'Page2'
      object Label3: TLabel
        Left = 8
        Top = 24
        Width = 32
        Height = 13
        Caption = 'Label3'
      end
    end
    object TTabSheet
      Caption = 'Page3'
    end
  end
  object MSButton3: tMSButton
    Left = 208
    Top = 152
    Width = 129
    Height = 25
    Caption = 'Change Label 3'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 13
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,msButton1,Onclick,ChangeLabel1
AddDialogHandler>Dialog1,msButton2,Onclick,ChangeLabel2
AddDialogHandler>Dialog1,msButton3,Onclick,ChangeLabel3
AddDialogHandler>Dialog1,,Onclose,Exit
Show>Dialog1
Let>Kline1=0
Let>Kline2=0
Let>Kline3=0
Label>Loop
Wait>.1
Goto>Loop

SRT>ChangeLabel1
Add>Kline1,1
  SetDialogProperty>Dialog1,Label1,Caption,Counter %Kline1%
END>ChangeLabel1

SRT>ChangeLabel2
Add>Kline2,1
  SetDialogProperty>Dialog1,Label2,Caption,Counter %Kline2%
END>ChangeLabel2

SRT>ChangeLabel3
Add>Kline3,1
  SetDialogProperty>Dialog1,Label3,Caption,Counter %Kline3%
END>ChangeLabel3

SRT>Exit
  Exit>1
END>Exit


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

Post by jpuziano » Mon Jul 25, 2011 2:27 am

That's works for me as well Rain, thanks.

It seems that on a dialog, Label3 is Label3 and it does not matter whether the label appears directly on the dialog or on page 2 of a 3-page Page Control... the following just works:

SetDialogProperty>Dialog1,Label3,Caption,%my_value%

Thanks again and 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
cron
Sign up to our newsletter for free automation tips, tricks & discounts