Notifications
Clear all

[Closed] Dotnet style TabControl color/sytle question

Hi all,
I am looking a way to make a dotnet style TabControl with maxscript like this:

The default style in 3ds max looks like this:

try(destroyDialog ControllingTheTabControlSample)catch()
rollout ControllingTheTabControlSample"ControllingTheTabControlSample" width:300
(
   dotNetControl tabs "system.windows.forms.tabControl" width:(ControllingTheTabControlSample.width-30) height:25 
   subRollout subRoll "Sub" width:(ControllingTheTabControlSample.width-30) height:200 offset:[0,-5]
   fn initTabs tab labels:#() =
   (
      tab.tabPages.clear()
      tab.sizeMode=tab.sizeMode.fixed
      tab.itemSize=dotnetObject "System.Drawing.Size" ((tab.width/labels.count)-2) 25      
       for x in labels do tab.tabPages.add x
   )
   on ControllingTheTabControlSample open do
   (
      initTabs tabs labels:#("General", "Security", "Details")
   )
)
createDialog ControllingTheTabControlSample  

I still do not find a solution,any one help?Thanks in advance:

5 Replies

You should create it inside a “MaxCustomControls.MaxForm”, not inside a standar Max rollout.

For example, in a structured way:


   ----------------------------------------------------
   -- DOTNET TAB PAGE INSIDE A 'MaxForm'
   ----------------------------------------------------

   -- creation of the Global 'P3D_TABCONTROL' to hold the struct elements
   (
      struct P3D_PCStruct 
      (
         -- Components
         theForm,
         theTabControl,
         theTabPages = #(),
         -- Properties
         theForm_DialogLocation,
         theTabPagesTitles = #("General", "Security", "Details"),
         lastTAB = 0,
         --   Events Handlers
         fn onCloseTheForm s e =
         (
            if s.WindowState == s.WindowState.Normal do 
               (
                  ::P3D_TABCONTROL.theForm_DialogLocation = s.Location
                  ::P3D_TABCONTROL.lastTAB = ::P3D_TABCONTROL.theTabControl.SelectedIndex
               )
         ),
         
         -- Initialization functions 
         fn initializeForm =
         (
            theForm_DialogLocation = if ::P3D_TABCONTROL == undefined then (dotnetobject "System.Drawing.Point" 800 200) else ::P3D_TABCONTROL.theForm_DialogLocation
            theForm = dotNetObject "MaxCustomControls.MaxForm"
            theForm.showInTaskbar = false
            theForm.text = "ControllingTheTabControlSample"
            theForm.StartPosition = theForm.StartPosition.Manual
            theForm.Location = theForm_DialogLocation
            theForm.width = 800
            theForm.height = 600    
            
            theForm.controls.Add theTabControl
            dotNet.addEventHandler theForm "Closing" onCloseTheForm
            
            local sysPointer = dotNetObject "System.IntPtr" (windows.getMaxHWND())
            local maxHandle = dotNetObject "maxCustomControls.win32HandleWrapper" sysPointer
            theForm.show maxHandle
         ),
         
         fn initializeTabControl =
         (
            theTabControl = dotNetObject "System.Windows.Forms.TabControl"
            theTabControl.Location = dotNetObject "System.Drawing.Point" 16 16
            theTabControl.Size = dotNetObject "System.Drawing.Size" 780 590
            theTabControl.SelectedIndex = if ::P3D_TABCONTROL == undefined then 0 else ::P3D_TABCONTROL.lastTAB
            tabSizeMode = dotnetclass "System.Windows.Forms.TabSizeMode"
            theTabControl.sizeMode = tabSizeMode.Fixed
            theTabControl.itemSize = dotNetObject "System.Drawing.Size" 100 20
            theTabControl.dock = theTabControl.dock.Fill      
            
            theTabControl.Controls.AddRAnge theTabPages
         ),
         
         fn TextBoxCreation np =
         (
            txtTextBox = dotNetObject "System.Windows.Forms.TextBox"
            txtTextBox.MultiLine = True
            txtTextBox.WordWrap = False
            txtTextBox.Size = dotNetObject "System.Drawing.Size" 500 500
            txtTextBox.Location = dotNetObject "System.Drawing.Point" 150 10
            txtTextBox.ScrollBars = txtTextBox.ScrollBars.Both
            txtTextBox.dock = txtTextBox.dock.Fill      
            txtTextBox.Text = "

************"+ "

This is the text for
 '" + np + "' Page

************"
            txtTextBox
         ),
         
         fn initializeTabPages =
         (
            theTabPages = for tt in theTabPagesTitles collect
            (
               local ctr = dotNetObject "System.Windows.Forms.TabPage"
               ctr.Text = tt
               ctr.Size = dotNetObject "System.Drawing.Size" 700 500
               ctr.dock = ctr.dock.Fill
               
               -- Insert a TextBox in each page (for example) --
               textBox = TextBoxCreation tt
               ctr.Controls.Add textBox
               -------------------------------------------------------
               
               ctr
            )
         ),
            
         fn initializeAll =
         (
            initializeTabPages()
            initializeTabControl()
            initializeForm()
         ),
         on create do
         (
            initializeAll()
         )      
      )
      
   ::P3D_TABCONTROL = P3D_PCStruct()
   ok
   )


1 Reply
(@momo2012)
Joined: 10 months ago

Posts: 0

Thanks for great help,I just tested the codes,it seems still looks like a max style,is it possible let the tab part background color and style changes to dotnet style?

sometimes it doesn’t matter what you do max will always format things as it see’s fit, even when using the sdk and custom controls.

You can use a DotNet Form instead of Max Form.


form=dotNetObject "system.windows.forms.form"

here is really good info to get you started
http://www.paulneale.com/tutorials/dotNet/dotNet.htm

 MZ1

I prefer to use WPF because is highly customizeable.