Naming Tabsheets

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Naming Tabsheets

Post by Phil Pendlebury » Tue Apr 19, 2022 7:11 am

Imagine you have a dialog with Page control and 4 Tabsheets.

Each tabsheet looks like this:

Code: Select all

object TTabSheet
      Caption = 'My Caption'
      ...
In my dialog all 4 Tabsheets are simply named object TTabSheet so there seems no way to refer to the individual caption.

I thought maybe just leave the caption '' and add a label on the tab that I can rename but labels will not move on to the tab area of the tabsheet.

Does anyone have a way to rename the caption?
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Naming Tabsheets

Post by Phil Pendlebury » Tue Apr 19, 2022 7:16 am

Also I have found an odd issue.

(My dialog is named "OBSChecklist1" obv).

If I add (although useless - see above):

Code: Select all

SetDialogProperty>OBSChecklist1,TTabsheet,Caption,'YOYOYO'
When I run it, the tabs remain unchanged but I get a folder on my Desktop named "Removable Storage Devices" which disappears when the script is stopped. :?
Phil Pendlebury - Linktree

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

Re: Naming Tabsheets

Post by Dorian (MJT support) » Tue Apr 19, 2022 10:31 am

JRL posted a tabsheet example here, and the tabs are named.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Naming Tabsheets

Post by Phil Pendlebury » Tue Apr 19, 2022 11:28 am

Dorian (MJT support) wrote:
Tue Apr 19, 2022 10:31 am
JRL posted a tabsheet example here, and the tabs are named.
Hi Dorian, Thanks but sorry they are not named. They are exactly as my example above:

JRL's code:

Code: Select all

object TTabSheet
      Caption = 'Tab 4'
My code:

Code: Select all

object TTabSheet
      Caption = 'My Caption'
Both are all simply named "TTabsheet." so there seems no way to refer to them in SetDialogProperties.

My question is how to set the Caption after initially starting the dialog. For example using SetDiloagProperty.

Also if you can please check the issue I submitted in the second post. Very odd.
Phil Pendlebury - Linktree

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

Re: Naming Tabsheets

Post by Dorian (MJT support) » Tue Apr 19, 2022 12:16 pm

I see.. so.... you can use the same method you would with other objects..

Code: Select all

    object TTabSheet2: TTabSheet
      Caption = 'Tab 2'
      object Label2: TLabel
        Left = 112
        Top = 104
        Width = 32
        Height = 13
        Caption = 'Tab 2'
      end
    end
    object TTabSheet3: TTabSheet
      Caption = 'Tab 3'
      object Label3: TLabel
        Left = 216
        Top = 72
        Width = 32
        Height = 13
        Caption = 'Tab 3'
      end

Code: Select all

SetDialogProperty>Dialog1,TTabSheet2,Caption,something
SetDialogProperty>Dialog1,TTabSheet3,Caption,something else
JRL's Dialog, adapted :

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  BorderIcons = [biSystemMenu]
  Caption = 'Tabs Sample'
  ClientHeight = 300
  ClientWidth = 500
  object msTabBook1: TPageControl
    Left = 0
    Top = 0
    Width = 500
    Height = 300
    TabOrder = 0
    object TTabSheet1: TTabSheet
      Caption = 'Tab 1'
      object Label1: TLabel
        Left = 46
        Top = 88
        Width = 32
        Height = 13
        Caption = 'Tab 1'
      end
    end
    object TTabSheet2: TTabSheet
      Caption = 'Tab 2'
      object Label2: TLabel
        Left = 112
        Top = 104
        Width = 32
        Height = 13
        Caption = 'Tab 2'
      end
    end
    object TTabSheet3: TTabSheet
      Caption = 'Tab 3'
      object Label3: TLabel
        Left = 216
        Top = 72
        Width = 32
        Height = 13
        Caption = 'Tab 3'
      end
    end
    object TTabSheet4: TTabSheet
      Caption = 'Tab 4'
      object Label4: TLabel
        Left = 96
        Top = 120
        Width = 32
        Height = 13
        Caption = 'Tab 4'
      end
    end
  end
end
EndDialog>Dialog1

show>dialog1
wait>2
SetDialogProperty>Dialog1,TTabSheet1,Caption,1
SetDialogProperty>Dialog1,TTabSheet2,Caption,2
SetDialogProperty>Dialog1,TTabSheet3,Caption,3
SetDialogProperty>Dialog1,TTabSheet4,Caption,4
wait>2
SetDialogProperty>Dialog1,TTabSheet1,Caption,5
SetDialogProperty>Dialog1,TTabSheet2,Caption,6
SetDialogProperty>Dialog1,TTabSheet3,Caption,7
SetDialogProperty>Dialog1,TTabSheet4,Caption,8
wait>2

I'm not able to replicate that other odd issue at all.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Naming Tabsheets

Post by Phil Pendlebury » Tue Apr 19, 2022 1:25 pm

Hi Dorian,

Did you try this? (Sorry I am away from computer). I did previously try renaming TTabsheet1 etc. but I thought it failed.

I will test again. Thank you.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Naming Tabsheets

Post by Phil Pendlebury » Tue Apr 19, 2022 1:28 pm

Yup as I thought, if you name a TTabsheet anything other than TTabsheet the tabs simply disappear. :)
Phil Pendlebury - Linktree

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

Re: Naming Tabsheets

Post by Dorian (MJT support) » Tue Apr 19, 2022 6:47 pm

Phil Pendlebury wrote:
Tue Apr 19, 2022 1:28 pm
Yup as I thought, if you name a TTabsheet anything other than TTabsheet the tabs simply disappear. :)
I did test it, yes.

Can you provide the code so I can replicate any issues?
Yes, we have a Custom Scripting Service. Message me or go here

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

Re: Naming Tabsheets

Post by JRL » Tue Apr 19, 2022 6:53 pm

Good news is using SetControlText> and SetObjectText> both work to change the name of the tab. Bad news is that changing the name doesn't cause the displayed name to change. You can run this, use the edit field and button to change the name of "Tab 2". Leave the dialog open and use "View System Windows" to look at the tabs and you'll see that it reports the name to be what you entered.

I tried multiple things trying to get the tab name to refresh but found nothing that works
SetDialogObjectVisible>

CloseDialog>Dialog1
Show>Dialog1

LibFunc>user32,UpdateWindow,UWRes,TabHndl (Where Tabhndl is the handle of the dialog or the tabsheet or the tab...) none worked.

Perhaps Marcus has a solution?

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 590
  Top = 128
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Tabs Sample'
  ClientHeight = 300
  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 msTabBook1: TPageControl
    Left = 0
    Top = 0
    Width = 500
    Height = 300
    TabOrder = 0
    object TTabSheet
      Caption = 'Tab 1'
      object Label1: TLabel
        Left = 46
        Top = 88
        Width = 28
        Height = 13
        Caption = 'Tab 1'
      end
      object Label5: TLabel
        Left = 48
        Top = 112
        Width = 75
        Height = 13
        Caption = 'New Tab Name'
      end
      object MSButton1: tMSButton
        Left = 33
        Top = 186
        Width = 120
        Height = 25
        Caption = 'Rename this tab'
        TabOrder = 0
        DoBrowse = False
        BrowseStyle = fbOpen
      end
      object Edit1: TEdit
        Left = 50
        Top = 138
        Width = 121
        Height = 21
        TabOrder = 1
        Text = ''
      end
    end
    object TTabSheet
      Caption = 'Tab 2'
      object Label2: TLabel
        Left = 112
        Top = 104
        Width = 28
        Height = 13
        Caption = 'Tab 2'
      end
    end
    object TTabSheet
      Caption = 'Tab 3'
      object Label3: TLabel
        Left = 216
        Top = 72
        Width = 28
        Height = 13
        Caption = 'Tab 3'
      end
    end
    object TTabSheet
      Caption = 'Tab 4'
      object Label4: TLabel
        Left = 96
        Top = 120
        Width = 28
        Height = 13
        Caption = 'Tab 4'
      end
    end
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,srtRename
show>dialog1,

SRT>srtRename
  GetDialogProperty>Dialog1,Edit1,Text,vNewName
  FindObject>Dialog1.handle,TTabSheet,Tab 2,3,TabHndl,Xpos,Ypos,RPos,Bpos,vTxt
  SetObjectText>TabHndl,vNewName
  SetDialogProperty>Dialog1,Label2,Caption,vNewName
  SetControlText>Tabs Sample,TTabSheet,3,vNewName
END>srtRename
About ten years ago I wrote a script for jpusiano called "Panels as Tabs". A little more overhead but perhaps it could be adapted to suit your needs.

Straight out of the old email

Code: Select all

ExportData>SPIDER.PNG_DATA,%temp_dir%spider.png

Dialog>Dialog1
object Dialog1: TForm
  Left = 533
  Top = 236
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Panels as Tabs'
  ClientHeight = 239
  ClientWidth = 270
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel101: TPanel
    Left = 10
    Top = 26
    Width = 250
    Height = 150
    BevelOuter = bvLowered
    TabOrder = 0
    Color = 16777200
    ParentBackground = False
    object Label1: TLabel
      Left = 90
      Top = 135
      Width = 54
      Height = 13
      Caption = 'Bug Report'
    end
    object MSImage1: tMSImage
      Left = 10
      Top = 88
      Width = 51
      Height = 55
    end
    object CheckBox1: TCheckBox
      Left = 19
      Top = 19
      Width = 200
      Height = 17
      Caption = 'Do something if checked'
      TabOrder = 0
    end
    object Edit1: TEdit
      Left = 20
      Top = 42
      Width = 121
      Height = 21
      TabOrder = 1
    end
  end
  object Panel102: TPanel
    Left = 10
    Top = 26
    Width = 250
    Height = 150
    BevelOuter = bvLowered
    TabOrder = 1
    Visible = False
    Color = 14679551
    ParentBackground = False
    object MSMemo1: tMSMemo
      Left = 17
      Top = 13
      Width = 185
      Height = 89
      TabOrder = 0
    end
  end
  object Panel103: TPanel
    Left = 10
    Top = 26
    Width = 250
    Height = 150
    BevelOuter = bvLowered
    Color = 12698019
    ParentBackground = False
    TabOrder = 2
    Visible = False
    object MSListBox1: tMSListBox
      Left = 17
      Top = 18
      Width = 112
      Height = 97
      ItemHeight = 13
      TabOrder = 0
      SelectedIndex = -1
    end
    object MSRadioGroup1: tMSRadioGroup
      Left = 140
      Top = 20
      Width = 101
      Height = 101
      Caption = 'Things'
      Items.Strings = (
        'Item 1'
        'Item 2'
        'Item 3')
      TabOrder = 1
      Text = 'Item 1'#13#10'Item 2'#13#10'Item 3'#13#10
    end
  end
  object MSButton1: tMSButton
    Left = 91
    Top = 200
    Width = 75
    Height = 25
    Caption = 'Close'
    TabOrder = 6
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object Panel1: TPanel
    Left = 20
    Top = 2
    Width = 50
    Height = 25
    BevelEdges = [beLeft, beTop, beRight]
    BevelOuter = bvNone
    Caption = 'Tab 1'
    TabOrder = 3
  end
  object Panel2: TPanel
    Left = 69
    Top = 2
    Width = 50
    Height = 25
    Caption = 'Tab 2'
    TabOrder = 4
  end
  object Panel3: TPanel
    Left = 118
    Top = 2
    Width = 50
    Height = 25
    Caption = 'Tab 3'
    TabOrder = 5
  end
end
EndDialog>Dialog1

  Let>kk=0
  Repeat>kk
    Add>kk,1
    AddDialogHandler>Dialog1,Panel%kk%,OnClick,Setup(%kk%)
    SetDialogProperty>Dialog1,Panel%kk%,BevelOuter,bvNone
    SetDialogProperty>Dialog1,Panel%kk%,BevelEdges,[beLeft, beTop, beRight, beBottom]
    SetDialogProperty>Dialog1,Panel%kk%,BevelKind,bkFlat
    SetDialogProperty>Dialog1,Panel%kk%,ParentBackground,False
  Until>kk=5
  AddDialogHandler>Dialog1,msButton1,OnClick,Quit
  SetDialogProperty>Dialog1,Panel1,BevelEdges,[beLeft, beTop, beRight]
  SetDialogProperty>Dialog1,MSImage1,LoadImage,%temp_dir%\spider.png
  GetDialogProperty>Dialog1,Panel1,Color,DefaultTabColor
  GetDialogProperty>Dialog1,Panel101,Color,CurrentDisplayColor
  SetDialogProperty>Dialog1,Panel1,Color,CurrentDisplayColor
  DeleteFile>%temp_dir%spider.png


Show>dialog1,res1

SRT>Setup
  Let>Display_kk=100
  Let>Tab_kk=0
  Let>VisPanelNum={%Setup_var_1%+%Display_kk%}
  Repeat>Display_kk
    Add>Display_kk,1
    Add>Tab_kk,1
    SetDialogProperty>Dialog1,Panel%Display_kk%,Visible,False
    SetDialogProperty>Dialog1,Panel%Tab_kk%,BevelEdges,[beLeft, beTop, beRight, beBottom]
    SetDialogProperty>Dialog1,Panel%Tab_kk%,Color,DefaultTabColor
  Until>Display_kk=150
  SetDialogProperty>Dialog1,Panel%VisPanelNum%,Visible,True
  SetDialogProperty>Dialog1,Panel%Setup_var_1%,BevelOuter,bvNone
  SetDialogProperty>Dialog1,Panel%Setup_var_1%,BevelEdges,[beLeft, beTop, beRight]
  GetDialogProperty>Dialog1,Panel%VisPanelNum%,Color,CurrentDisplayColor
  SetDialogProperty>Dialog1,Panel%Setup_var_1%,Color,CurrentDisplayColor
END>Setup

SRT>Quit
  Exit>0
END>Quit







/*
SPIDER.PNG_DATA:
89504E470D0A1A0A0000000D49484452000000330000003708020000002E52E56B0000074249444154789CCD995B6C1C5719C7BF73CEDC6767EFF6DA094D0950F100E28D071042A2A205A4AA41D026355292BA8A73214D7C4D7C491C3BB16327B11BC77642132769C0A8B49050784208E80B0F0889275EA248AD8A90BBF67AE
DDDD9FBDC6778703061BDB677772688FFD3CE77CEF73F3F1DCDB9CCB728E338F07F29EC89CBFCECC4FBB7A63DB15A17E5894B3A9D46087962B52E6FE6AC6368BC582C7A62B52E6FC800C0F1FA7DF58C2C9FCFCF8E9EAD356BA2B773A4F3CD8A4D9E91499294CF646B4A991B1BB62C4B92A48AADA88E5DE3675363B66DB77697
CFD0645F1700F45CBA5A8DC9E8C9A336C0B9999B9B75A867CE0E760E2C2D2DCD9EEF2B8BF75CBA6AEAFADCC8703526F1787C0BAC3AC9006060F286AE69B3C3BD65F1BEABD7E554FACEC8F9ADD307DB5EE7386EEB3EF5BF67DD63538AA2CC9CED298BF75E9BF9C7279F6C9D4B51D4D4BBF79F1619009CBE3C831CB8D6D7596EE
AC0D01BAD9B655D1FE81145715B73B76BF3C4C549DBB67BF7B7CC0DFF674144A361C3D0364BD1348D90ED0F0C0F768DAE2BD3977FFE9E9CCDF41F6C598BB44F4E216C6ED67F71E9D3CECBD7FE17646BEA9DBA4E08597F44D869DFFB52C59E8A52AAC6D0333200688844065B1F4FDBE8BDFB5939B5B1CFF091FD559E635E92B5
4F4C8BA2B0FE58F1F66159D6DBBFFD43356E5E920100CF31FD2D7B0060E4D0AB155F7355D3ABB47A7C3FBB7CFA78A150F0F97C1CC799A61994FC8490D74F0FD7CE665BB6010089C452D01F286B3BB5FF954C2653A551E573F3DCD103082184C1B22CCBB26CDB06804B777FB9ADDDF9375E5555359D5EB52DF3F61FFF56D6DAB
6E73B84909B1FFCAE1AB2CA77DA0B37E7D77FDF1AED9365399D4E1FDFFB5D862608218C288AA22EDD7BF064CAF88F0F2E2F2E154BF94040824AD7B5432FBF08000D0D0DD56041AD778D73C75A689A4EAFCAD96C5655759665630D8D8490E452C2B20D81E34D5367696218463E9FDBB96B976A61C91F28954A9AA6D11C3F35BF
CD89543FD99A8EFEF005E480A268A954CAD0745555694C028140AC31AA2845CBB27896B62C33100E4FBEFFFB5ACD5D91ADE947DFFEFAC3870FE55456D38120884484E65843B1984708EDFEECAE703874EDC1877563819B5D63259D4AA7B3AA0E1401D3817CBEB492921545334DDB018C0975ECE56FBA21AB67CE7EF0ADAF168
BC5E5C4CA627C1563A031108238868E4422A2C0974A05841D8EE34AA592204AA2E46FDAB1F3E6FDAAD6E393AA79CE0E7CFFF9A5E5E57F2E2CC8B20C0830024507BFDF1F8A44252920FA2445D33FFA78E5E38F160A858220088A524CC41747BB8FD43A50CD5FC2D95C7E352D67B305CB00C70186C2C4B1230DB160C84F63C230
94CF2F39F18CCFCF7DEEF35F88C562995CD6B69065594F9D0C03A13021080C1B0080A669496200D91445210758968D8623A16042E0789EE5344DE3189613C4703054FB40358AC6B456D210C208014541B821ACE80A60C73034C3D06CCBB44D2BE813639128721CA558A230696A8C9D189EA875A09AE78C63D8DDBB776732E95
5396DDB763E9FCD664D555544516009954824F2D94C28148A46A3B66DBFFBE15F6BF5AF9F2CB1BC8890D3DCDC2C0503C96462753547D38031C198C462B1344999BA110E4519865335ADEDA5E731451886A128CA342CCBB145510C04026767EE6C3B503DBBC6BE17BE41D13857282493C98585786363341A0EF32CF7E7BFFC7D
A0EB487A35851DD0551D3028A68E2942D3B4E338BA661886C1308C288A0CC3218428861B9ABDE5251900EC7BF16BB22C0B82904CAE4892C431AC699A5FF9D297C7EFBE574DFA445FBB699AC8461863C771745DD775DDB4EDA61D3B4BA512CFF31D17C66B26EB6A7D4555D5783C2E49525353D3E2E2122184A168C7710496E37
9FE333B9E691FAFAA80505117BB4FB22CDB3336511BD9D089039FC6E3AAAA8AA2F8DC735F3C35360B00BD875ED375636AFED7670F1FC8E5727E5F20180CF64CBA2D416EB302DEEA3A9CCBE58AC5A2A669BA690A21FFDD0FCACF69499292C91500189D9B1F3D79389F2D3C7AF468E4F8E1C11B736EC850C671C63BDA14452184
608C09C2344D6B9AC6B22CCFB0B66D2B8A0200BDB39BAEA681B6968C9CFDC983FF3A19DBF67CEF99679FDDBAA6B2B52800E8BF76BBEE7C00C0185354F9DCFB7CBE4CAEB6725AB9AD9BE435F10C0F76F9CB4A18E2B272EB0199AEEB344D974711E27DBC1B5BB76433FD1DF95CAEB9B9B92C8EB0138D46DD38BB252B168B8220F
44CDE288BEB96E1F3091553AA945B3284D0E8DD5F6C8C2B4AB163A8E6FBC593724B66D9F6C6E0D8A9A3A6B66995AA4AB9223BB16F4F385AFE653B7DA6534EC9EFFCE64F6E9CC10DD9E09183E170F8D8D0F893C13B63E754559F7867FB3AC3B6AAE71FB19F5EB9B0B2B2C271DC99E9F23BCCF2F2B2CFE7738F057590DDBE38A8
69DAA989D98D4DD367BA054168BFF8961760757C3B65F33D572A57590DC3DAACA90ED540F6F6D00027F0A1D0A65F411B4F4F37AAD6EBDEF8050068ED1DDCA20FCBB21E10FD5BD5AE4DD3340561AB3DFDC6503FC3305E203D56B577DA5F5DBFBAF7CD2E0F07DE56F557A99EB6FE05903E0BAE6FC55AC20000000049454E44AE4
26082719EC39AAAA2A2104634C10665956D␲

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

Re: Naming Tabsheets

Post by Dorian (MJT support) » Tue Apr 19, 2022 7:07 pm

Many thanks. I've already passed this on to him but thought I'd figured out a workaround. I'll make sure he knows it needs more attention.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Phil Pendlebury
Automation Wizard
Posts: 518
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Naming Tabsheets

Post by Phil Pendlebury » Wed Apr 20, 2022 3:14 am

Hi guys. Thanks for your attention and care.

Please don’t worry about “fixing” this on my behalf, or bothering Marcus with it. I’m sure it’s out of scope and if it was possible, Marcus would have set it up originally.

It’s honestly not a huge thing. If it was, the forum would be littered with questions about it. But as it is, there is not one.

I’ll forward you my very long and in inefficient code later on. Perhaps we can have a bit of fun with it.

:-)
Phil Pendlebury - Linktree

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

Re: Naming Tabsheets

Post by Dorian (MJT support) » Wed Apr 20, 2022 8:05 am

Message received and understood. :)
Yes, we have a Custom Scripting Service. Message me or go here

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