setting the active page on a v12 Dialog PageControl object

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

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

setting the active page on a v12 Dialog PageControl object

Post by jpuziano » Sat Jan 15, 2011 3:54 am

Hi Marcus,

We have the following command which works well with a simple object like this...

SetDialogObjectFocus>Dialog1,MSButton1

...but I'd like to use that with a PageControl that has multiple tabs (pages) on it.

How do I write the above line to set focus to Page 1 of PageControl1 of the following example Dialog?

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 97
  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 PageControl1: TPageControl
    Left = 46
    Top = 22
    Width = 289
    Height = 193
    TabOrder = 0
    object TTabSheet
      Caption = 'Page1'
    end
    object TTabSheet
      Caption = 'Page2'
      ExplicitLeft = 0
      ExplicitTop = 0
      ExplicitWidth = 0
      ExplicitHeight = 0
    end
    object TTabSheet
      Caption = 'Page3'
      ExplicitLeft = 0
      ExplicitTop = 0
      ExplicitWidth = 0
      ExplicitHeight = 0
    end
  end
end
EndDialog>Dialog1
Thanks and take care
Last edited by jpuziano on Sat Jan 15, 2011 8:45 am, edited 3 times 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
JRL
Automation Wizard
Posts: 3460
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Jan 15, 2011 4:41 am

There might be a better way but the prior to version 12 method still works.

page1 is 0
page2 is 1
page3 is 2

Add the lines

Code: Select all

Let>Dialog1.PageControl1=0
ResetDialogAction>Dialog1

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

Post by jpuziano » Sat Jan 15, 2011 8:32 am

JRL wrote:There might be a better way but the prior to version 12 method still works.

page1 is 0
page2 is 1
page3 is 2

Add the lines

Code: Select all

Let>Dialog1.PageControl1=0
ResetDialogAction>Dialog1
Thanks for the above JRL... however check out what the Help File says...
Help File wrote:ResetDialogAction>DialogName

Not supported in Macro Scheduler Lite.

Deprecated. Supported only for backward compatibility. Works only with old-style Dialog Blocks (v11 and earlier).
I am using a V12 Dialog... and while the Help File clearly states this command "Works only with old-style Dialog Blocks (v11 and earlier)"... I find that it actually does work with the new v12 style Dialog blocks... at least... it did just now on the v12 dialog I created (running on Win 7).

Edit: Tue Jan 18, 2011 - After seeing in this post how mixing v12 dialogs with depricated commands meant to work only with v11 and earlier dialogs can cause odd results... even though ResetDialogAction> as used above with a v12 dialog does seem to work in this case , I wouldn't recommend it for various reasons.

After some poking about in the Properties of the PageControl object, I believe I found out how to do it the new v12 way:

Code: Select all

//page1 is 0
//page2 is 1
//page3 is 2

SetDialogProperty>Dialog1,PageControl1,TabIndex,0
The interesting thing here is, this does not really "setfocus" to that page so trying to use SetDialogObjectFocus> was leading me astray. The above line just makes page1 (the first tab on PageControl1) the active (visible) page on PageControl1 which was really what I was after anyway.

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 - :-)

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

Re: setting the active page on a v12 Dialog PageControl object

Post by Phil Pendlebury » Sat Jul 09, 2022 8:03 pm

Interestingly:

Code: Select all

Let>Dialog1.PageControl1=4
ResetDialogAction>Dialog1
Still works with V14

Whereas any amount of:

Code: Select all

SetDialogProperty>Dialog1,PageControl1,ActivePage,Name
etc. Does not seem to work at all.
Phil Pendlebury - Linktree

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

Re: setting the active page on a v12 Dialog PageControl object

Post by JRL » Mon Jul 11, 2022 8:27 pm

Hi Phil,
Not sure what your expectations are. This seems to work to set the opening tab to tab2 in the following example.

Code: Select all

SetDialogProperty>Dialog1,msTabBook1,TabIndex,1
Here's a full example.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 661
  Top = 207
  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
    TabStop = False
    object TTabSheet
      Caption = 'Tab 1'
      object Label1: TLabel
        Left = 46
        Top = 88
        Width = 28
        Height = 13
        Caption = 'Tab 1'
      end
    end
    object TTabSheet
      Caption = 'Tab 2'
      object Label2: TLabel
        Left = 112
        Top = 104
        Width = 28
        Height = 13
        Caption = 'Tab 2'
      end
      object MSButton1: tMSButton
        Left = 105
        Top = 203
        Width = 75
        Height = 25
        Caption = 'Goto Tab4'
        TabOrder = 0
        DoBrowse = False
        BrowseStyle = fbOpen
      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

SetDialogProperty>Dialog1,msTabBook1,TabIndex,1
AddDialogHandler>Dialog1,MSButton1,OnClick,srtTabFour

show>dialog1,res1

SRT>srtTabFour
  SetDialogProperty>Dialog1,msTabBook1,TabIndex,3
END>srtTabFour

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

Re: setting the active page on a v12 Dialog PageControl object

Post by Phil Pendlebury » Tue Jul 12, 2022 4:49 am

Hi JRL,

That was the key:

Code: Select all

TabIndex
I was using ActivePage and some other things but did not find any documentation about TabIndex. I did search the forums.

Thank you, as always, for enlightening me. :-)
Phil Pendlebury - Linktree

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