Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Tabbed Dialog .Net Form Tab Control System.Windows.Forms.TabControl System.Windows.Forms.TabPage System.Windows.Forms.RadioButton System.Windows.Forms.CheckBox
;*************************************************************************** ;** Use a Windows .Net Form with a Tab Control ;** ;** Purpose: Creates a TabControl with three tab pages. Each tab page contains several controls. ;** Inputs: ;** Outputs: Results written to screen ;** Reference: ;** REQUIRES WinBatch 2013A or newer ;** http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol(v=vs.110).aspx ;** ;** Developer: Deana Falk 2014.03.06 ;*************************************************************************** If Version( )< '2013A' Pause('Notice', 'Need 2013A or Newer Version of WinBatch') Exit EndIf _True = ObjectType( 'BOOL', -1 ) _False = ObjectType( 'BOOL', 0 ) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ObjectClrOption - Load assembly into the WinBatch process ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ObjectClrOption( 'use', 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ) ObjectClrOption( 'use', 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ObjectClrNew - Create a class implemented by a managed assembly. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Form1 = ObjectClrNew('System.Windows.Forms.Form') ; Buttons ;Button1 = ObjectClrNew('System.Windows.Forms.Button') tab1Button1 = ObjectClrNew('System.Windows.Forms.Button') tab1Button2 = ObjectClrNew('System.Windows.Forms.Button') ; Tabs tabControl = ObjectClrNew('System.Windows.Forms.TabControl') TabPage1 = ObjectClrNew('System.Windows.Forms.TabPage') TabPage2 = ObjectClrNew('System.Windows.Forms.TabPage') TabPage3 = ObjectClrNew('System.Windows.Forms.TabPage') ; Other Controls components = ObjectClrNew('System.ComponentModel.Container') tab2CheckBox3 = ObjectClrNew('System.Windows.Forms.CheckBox') tab3RadioButton2 = ObjectClrNew('System.Windows.Forms.RadioButton') tabControl1 = ObjectClrNew('System.Windows.Forms.TabControl') tab2CheckBox2 = ObjectClrNew('System.Windows.Forms.CheckBox') tab2CheckBox1 = ObjectClrNew('System.Windows.Forms.CheckBox') tab3RadioButton1 = ObjectClrNew('System.Windows.Forms.RadioButton') tab1Label1 = ObjectClrNew('System.Windows.Forms.Label') dialogResult = ObjectClrNew('System.Windows.Forms.DialogResult') ; Enumerations enumStartPos = ObjectClrNew('System.Windows.Forms.FormStartPosition') enumDialogResult = ObjectClrNew( 'System.Windows.Forms.DialogResult') ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Define Form1 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Set the caption bar text of the form. Form1.Text = 'Tabbed Dialog' ; Set the start position of the form to the center of the screen. Form1.StartPosition = ObjectClrType( 'System.Windows.Forms.FormStartPosition', enumStartPos.CenterScreen ) ;CenterScreen ; Set the accept button of the form to button1. Form1.AcceptButton = tab1Button1 Form1.CancelButton = tab1Button2 ; Obtain the Width of the form for later use with controls formwidth = Form1.Width-20 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Define Controls ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tabPage1.Text = "tabPage1"; tabPage1.Size = ObjectClrNew('System.Drawing.Size', 256, 214) tabPage1.TabIndex = 0; tab2CheckBox3.Location = ObjectClrNew('System.Drawing.Point', 32, 136) tab2CheckBox3.Text = "checkBox3"; tab2CheckBox3.Size = ObjectClrNew('System.Drawing.Size', 176, 32) tab2CheckBox3.TabIndex = 2; tab2CheckBox3.Visible = _True; tab3RadioButton2.Location = ObjectClrNew('System.Drawing.Point', 40, 72) tab3RadioButton2.Text = "radioButton2"; tab3RadioButton2.Size = ObjectClrNew('System.Drawing.Size', 152, 24) tab3RadioButton2.TabIndex = 1; tab3RadioButton2.Visible = _True; tabControl1.Location = ObjectClrNew('System.Drawing.Point', 16, 16) tabControl1.Size = ObjectClrNew('System.Drawing.Size', 264, 240) tabControl1.SelectedIndex = 0; tabControl1.TabIndex = 0; tab2CheckBox2.Location = ObjectClrNew('System.Drawing.Point', 32, 80) tab2CheckBox2.Text = "checkBox2"; tab2CheckBox2.Size = ObjectClrNew('System.Drawing.Size', 176, 32) tab2CheckBox2.TabIndex = 1; tab2CheckBox2.Visible = _True; tab2CheckBox1.Location = ObjectClrNew('System.Drawing.Point', 32, 24) tab2CheckBox1.Text = "checkBox1"; tab2CheckBox1.Size = ObjectClrNew('System.Drawing.Size', 176, 32); tab2CheckBox1.TabIndex = 0; tab3RadioButton1.Location = ObjectClrNew('System.Drawing.Point', 40, 32) tab3RadioButton1.Text = "radioButton1"; tab3RadioButton1.Size = ObjectClrNew('System.Drawing.Size', 152, 24) tab3RadioButton1.TabIndex = 0; tab1Label1.Location = ObjectClrNew('System.Drawing.Point', 16, 24) tab1Label1.Text = "label1"; tab1Label1.Size = ObjectClrNew('System.Drawing.Size', 224, 96) tab1Label1.TabIndex = 1; tabPage3.Text = "tabPage3"; tabPage3.Size = ObjectClrNew('System.Drawing.Size', 256, 214) tabPage3.TabIndex = 2; tabPage2.Text = "tabPage2"; tabPage2.Size = ObjectClrNew('System.Drawing.Size', 256, 214) tabPage2.TabIndex = 1; tab1Button1.Location = ObjectClrNew('System.Drawing.Point', 28, 144) tab1Button1.Size = ObjectClrNew('System.Drawing.Size', 80, 40) tab1Button1.TabIndex = 0; tab1Button1.Text = "Ok"; tab1Button2.Location = ObjectClrNew('System.Drawing.Point', 118, 144) tab1Button2.Size = ObjectClrNew('System.Drawing.Size', 80, 40) tab1Button2.TabIndex = 1 tab1Button2.Text = "Cancel" ; IMPORTANT: The dialog box can be assigned one of the values of the DialogResult enumeration by assigning it to the DialogResult property of a Button on the form. tab1Button1.DialogResult = ObjectClrType( 'System.Windows.Forms.DialogResult', enumDialogResult.OK ) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Add Controls ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Adds buttons to form tabPage1.Controls.Add(tab1Button1) tabPage1.Controls.Add(tab1Button2) ; Adds the TabControl to the form. Form1.Controls.Add(tabControl1) ; Adds controls to the first tab page. tabPage1.Controls.Add(tab1Label1) ; Adds the tab pages to the TabControl. tabControl1.Controls.Add(tabPage1) tabControl1.Controls.Add(tabPage2) tabControl1.Controls.Add(tabPage3) ; Adds controls to the second tab page. tabPage2.Controls.Add(tab2CheckBox3) tabPage2.Controls.Add(tab2CheckBox2) tabPage2.Controls.Add(tab2CheckBox1) ; Adds controls to the third tab page. tabPage3.Controls.Add(tab3RadioButton2) tabPage3.Controls.Add(tab3RadioButton1) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Display the form as a modal dialog box. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ret = Form1.ShowDialog() ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Get Results ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Result = form1.DialogResult If Result == DialogResult.OK Pause('Notice','The OK button on the form was clicked.') ElseIf Result == DialogResult.Cancel Pause('Notice','The Cancel button on the form was clicked.') EndIf If tab2CheckBox1.CheckState Then Pause( 'Notice','tab2CheckBox1 was Checked.' ) If tab2CheckBox2.CheckState Then Pause( 'Notice','tab2CheckBox1 was Checked.' ) If tab2CheckBox3.CheckState Then Pause( 'Notice','tab2CheckBox1 was Checked.' ) If tab3RadioButton1.Checked Then Pause( 'Notice','tab3RadioButton1 was Checked.' ) If tab3RadioButton2.Checked Then Pause( 'Notice','tab3RadioButton2 was Checked.' ) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Clean up ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ components.Finalize() tab1Button1.Dispose() ; Tabs tabControl.Dispose() TabPage1.Dispose() TabPage2.Dispose() TabPage3.Dispose() ; Other Controls tab2CheckBox3.Dispose() tab3RadioButton2.Dispose() tabControl1.Dispose() tab2CheckBox2.Dispose() tab2CheckBox1.Dispose() tab3RadioButton1.Dispose() tab1Label1.Dispose() Exit
Article ID: W17849
Filename: TabControl.txt
File Created: 2014:03:07:14:32:02
Last Updated: 2014:03:07:14:32:02