View Full Version : dotNet tabControls align vertical?
With AX tabs there were several properties that I'm not finding equivlents of in the dotNet version. One is to align the tabs verticaly? Any one know how that is done now?
Also some of the other properties don't appear to work as well. The tabs.SizeMode=tabs.sizeMode.fillToRight property doesn't appear to be working unless I have .multiLine=true and there are multiple lines. Also the appearence of the buttons doesn't appear to work either. I can set it t buttons or flatButtons and all I get are different spaces between the tabs.
Can any one confirm this?
try(destroyDialog testR)catch()
rollout testR "Test" width:200
(
dotNetControl tabs "system.windows.forms.tabControl" height:100
fn showProps tab=
(
clearListener()
format "Properties:\n"
showProperties tab
format "\nMethods:\n"
showMethods tab
format "\nEvents:\n"
showEvents tab
)
on testR open do
(
showProps tabs
tabs.appearance=tabs.appearance.flatbuttons
tabs.Multiline=true
tabs.RightToLeftLayout=true
-- tabs.SizeMode=tabs.sizeMode.fixed
tabs.SizeMode=tabs.sizeMode.fillToRight
tabs.tabStop=true
labels=#("Main", "Settings", "User", "Misc", "Extras")
for x in labels do tabs.tabPages.add x
-- SelectedIndex
-- SelectedTab
-- Appearance : <System.Windows.Forms.TabAppearance>
-- .ImageList : <System.Windows.Forms.ImageList>
)
)
createDialog testR
|
|
LoneRobot
08-22-2008, 03:23 PM
hi paul, at work right now so cant look at it fully but
tabs.alignment = (dotnetclass "system.Windows.Forms.Tabalignment").left
will make them go vertical.
Interesting, that does work but the text does not align with it:S So I can't read any of the tabs. I might have to set a property in the tab is self for that. Thanks.
LoneRobot
08-22-2008, 03:36 PM
hi paul, without checking I cant be sure but you are probably right - see if the individual tab exposes any properties for that.
It still isn't correct as it is aligned to the left but the tabs are not on their sides they are still up right. So there needs to be some way to rotate them. This isn't just the text it is the tabs them selves.
Well it looks like a lot of work is needed to make this work correctly. The developers don't even understand why it is needed by the sounds of it. AX controls did this automaticaly but the current method of drawing them is "As Designed" Sounds like Max.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=334463&SiteID=1
Looks like there are lots of issues. This is a problem for me as I need to port a UI that I did for a client in AX controls to dotNet and all the tabs are vertical. Suggestions welcome at this point. Maybe I will see if I can some how draw them my self.
On this page.. http://dotnetrix.co.uk/controls.htm there is a tabControlEx and I can load the assembly but when I showProperties on the control when it is created I don't get anything at all. I also don't get anything showing up in a rollout for it.
ypuech
08-22-2008, 04:29 PM
tabControlEx is .NET 1.1 (so it doesn't work with .NET in MAXScript). tabControl 2 below is .NET 2.0 but it seems it doesn't implement complex alignement.
LoneRobot
08-22-2008, 04:43 PM
Well it looks like a lot of work is needed to make this work correctly. The developers don't even understand why it is needed by the sounds of it. AX controls did this automaticaly but the current method of drawing them is "As Designed" Sounds like Max.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=334463&SiteID=1
bummer. Visual Studio obviously does something else as setting this property within a form app rotates them correctly. I will ferret around and see if i can figure anything.
ah I forgot about 1.1 not being supported Yannick, and thanks Pete for having a look at that. What a pain in the ass.
ofer_z
08-23-2008, 02:27 AM
Hi Paul,
TabControlEx works fine for me in max 2008 (what version of max were you trying it in?)
Here's the code I used (based on your code):
dotNet.loadAssembly @"C:\TabControlEX.dll"
try(destroyDialog testR)catch()
rollout testR "Test" width:200
(
dotNetControl tabs "Dotnetrix.Controls.TabControlEx" height:300
fn showProps tab=
(
clearListener()
format "Properties:\n"
showProperties tab
format "\nMethods:\n"
showMethods tab
format "\nEvents:\n"
showEvents tab
)
on testR open do
(
showProps tabs
tabs.Alignment = tabs.Alignment.Left
tabs.Appearance = (dotNetClass "Dotnetrix.Controls.TabAppearanceEx").FlatTab
tabs.BackColor = (dotNetClass "System.Drawing.Color").Transparent
tabs.Multiline=true
tabs.tabStop=true
labels=#("Main", "Settings", "User", "Misc", "Extras")
for x in labels do
tabs.tabPages.add x
)
)
createDialog testR
I downloaded it from the link you gave.
hOpe this helps,
o
martroyx
08-23-2008, 03:00 AM
Work in 2009 ... this tab controls is very nice, thank :buttrock:
Ofer, this is great that you got this running but can you explain how? Here is what I had..
dotNet.loadAssembly ((getDir #scripts)+"\\penProductions\\tabControlEx.dll")
dotNetControl tabs "tabControlEx.dll"
and here is yours..
dotNet.loadAssembly @"C:\TabControlEX.dll"
dotNetControl tabs "Dotnetrix.Controls.TabControlEx" height:300
So where did the ampersand come from, what does it do and where did you get the path string for creating the control?
magicm
08-25-2008, 01:00 PM
Here's how you can get the available "types" of any loaded assembly:
a = dotNet.loadAssembly @"C:\TabControlEX.dll"
dotNetObject:System.Reflection.Assembly
for t in a.GetTypes() do print t
...
...
dotNetObject:System.RuntimeType[Dotnetrix.Controls.TabControlEX]
...
...
OK
c = a.CreateInstance "Dotnetrix.Controls.TabControlEX"
dotNetObject:Dotnetrix.Controls.TabControlEX
The @ character marks the string as verbatim meaning that any escape sequences are ignored. So by prefixing the string with @ you can safely type (for example) @"C:\render". Without the @ the \r would convert to a carriage return character.
Martijn
ofer_z
08-25-2008, 01:16 PM
So where did the ampersand come from, what does it do and where did you get the path string for creating the control?
The ampersand is a new addition in max 2008, and it just allows you to skip the escaping of special characters when typing a string. From the mxs help:
String Literals Verbatim String Literals
NEW in 3ds Max 2008:Verbatim string literals added to MAXScript in 3ds Max 2008 are prefixed by the '@' character and are NOT expanded even if containing backslash escape character sequences like '\t', '\n' or '\r'.
The syntax is
@"{<character>}+"
FOR EXAMPLE,
--the following verbatim string remains unchanged after evaluation:
thePath = @"g:\temp\newfolder\render"
"g:\temp\newfolder\render"
--while the following results in a
--scrambled string with tabs and new lines:
thePath = "g:\temp\newfolder\render"
"g: emp
ewfolder
ender"
So the ampersand is just there to shorten the path, it has nothing to do with the dotNet stuff.
As for the path string for creating the control, since I couldn't find any documentation for the TAbControlEx class, I used a class browser to see the name of the control, and the methods it has. I used the one in SharpDevelop (because that's what I usually use for visual designing of forms and a bit of C#), but I'm sure Visual Studio for C# also has this.
I've recently found this tool (http://www.red-gate.com/products/reflector/) which has a free version and seems very good for class browsing.
hOpe this helps,
o
ofer_z
08-25-2008, 01:18 PM
Here's how you can get the available "types" of any loaded assembly:
a = dotNet.loadAssembly @"C:\TabControlEX.dll"
dotNetObject:System.Reflection.Assembly
for t in a.GetTypes() do print t
...
...
dotNetObject:System.RuntimeType[Dotnetrix.Controls.TabControlEX]
...
...
OK
c = a.CreateInstance "Dotnetrix.Controls.TabControlEX"
dotNetObject:Dotnetrix.Controls.TabControlEX
Martijn
Hey Martijn,
That's a cool tip!
Thanks for sharing!
o
martroyx
08-25-2008, 03:54 PM
Originally Posted by magicm
Here's how you can get the available "types" of any loaded assembly:
Code:
a = dotNet.loadAssembly @"C:\TabControlEX.dll"
dotNetObject:System.Reflection.Assembly
for t in a.GetTypes() do print t
...
...
dotNetObject:System.RuntimeType[Dotnetrix.Controls.TabControlEX]
...
...
OK
c = a.CreateInstance "Dotnetrix.Controls.TabControlEX"
dotNetObject:Dotnetrix.Controls.TabControlEX
Martijn
I was looking for this for so long...how did you figure this out? :banghead:
another think that bug me out is the .anchor property,
I could say : a.anchor = a.anchor.top
but how to make it top and left at the same time ?
Thanks !!
Martin Dufour
ofer_z
08-25-2008, 04:02 PM
another think that bug me out is the .anchor property,
I could say : a.anchor = a.anchor.top
but how to make it top and left at the same time ?
a.anchor = dotNet.combineEnums a.anchor.top a.anchor.left
hOpe this helps,
o
martroyx
08-25-2008, 04:10 PM
That was quick :eek:
Thank it help me a lots !
LoneRobot
08-25-2008, 07:33 PM
Hi Martijn, Ofer,
thanks for the info, i was always cranking up VS to get the assembly types.
Excelent guys, thanks, ofer that is great. I hadn't seen the new addition of the @ for strings, that will simplify things a lot. Great tip on the getTypes, I had seen this in the help but hadn't tried it yet. Time to dig some more into the other dotNet struct methods.
I'm finaly just getting back to using tabControlEX and I'm using it as
tab.alignment=tab.alignment.top
But I'm getting scroll buttons ontop of the last of three tabs. No mater how wide I set it I get them. Is there any way to torun them off?
martroyx
10-10-2008, 10:15 PM
I Paul,
is this what your get ?
try (TestForm.close()) catch ()
(
dotNet.loadAssembly @"C:\TabControlEX.dll"
Global TestForm = (dotNetObject "MaxCustomControls.MaxForm")
Global tabControl1 = (dotnetobject "Dotnetrix.Controls.TabControlEx")
fn cleanup e arg = (TestForm=tabControl1=undefined)
-->tabControl1
tabControl1.Alignment = tabControl1.Alignment.Top
tabControl1.Appearance = tabControl1.Appearance.Bevel
tabControl1.dock = tabControl1.dock.Fill
tabControl1.BackColor = tabControl1.BackColor.DimGray
tabControl1.forecolor = tabControl1.forecolor.white
tabControl1.hotcolor = tabControl1.hotcolor.Gray
tabControl1.selectedtabcolor = tabControl1.selectedtabcolor.OrangeRed
tabControl1.sizemode = tabControl1.sizemode.fixed
tabControl1.hottrack = true
tabControl1.Multiline = true
tabControl1.tabStop = true
labels=#("1", "2", "3", "4", "5")
for x in labels do (tabControl1.tabPages.add x)
-->TestForm
TestForm.ClientSize = dotNetObject "System.Drawing.Size" 300 500
TestForm.Text = "Martroyx Test Form"
TestForm.Controls.Add tabControl1
dotnet.addeventhandler TestForm "closed" cleanup
TestForm.ShowModeless()
)
edit :
Oups, forgot to load the assembly too :
dotNet.loadAssembly "MaxCustomControls.dll"
Martin Dufour
So with three tabs it is wider then the 160 that I'm setting the width to. I would really like the 160 to remain the size but I need to size the width of the tabs, all trys at doing so have failed, I can't get the width properties of the tabs to change anything. They always return a value of 152, or something like that. Any ideas.
martroyx
10-10-2008, 10:38 PM
Sorry Paul, I don't get it :
So with three tabs it is wider then the 160 that I'm setting the width to
What do you mean ?>
martroyx
10-10-2008, 11:14 PM
Ho, I think I get it now , you want to move the scroll button themselves ?
ofer_z
10-10-2008, 11:21 PM
Hi Paul,
If you set the SizeMode property to Fixed:
roll.dncMainTabs.SizeMode = roll.dncMainTabs.SizeMode.Fixed
you can then set the size of the tabs:
roll.dncMainTabs.itemSize = dotNetObject "System.Drawing.Size" 100 18
hOpe this helps,
o
martroyx
10-10-2008, 11:22 PM
tabControl1.ItemSize = dotNetobject "System.Drawing.Size" 160 30
but I don't think you can set them individually.
edit : oup ofer_z (http://forums.cgsociety.org/member.php?u=6402) was faster :-P
Martin Dufour
Thanks guys, I hadn't tried itemSize yet, I'll see if that does it.
Insanto
01-01-2009, 03:00 AM
hi guys i got a small problem with dotNet and the coloring of tabControlls.
i've implemented a dotNet controll into my UI per Include
--Create the dotNet TabControl control
groupBox grpCustom2 "" pos:[10,239] width:244 height:75 align:#left visible:false
dotNetControl MapTabs "system.windows.forms.tabcontrol" height:25 width:240 visible:true pos:[12,225]
--Create a setup function for the DOT Net elements
fn PresTabControll thetc = (
dotnet.loadassembly "System.Data"
color = dotNetClass "System.Drawing.Color"
thetc.BackColor = (dotNetClass "System.Drawing.Color").Transparent
--Create 3 Tab Pages
global t1 = dotNetObject "System.Windows.Forms.TabPage"
t1.text = "Diso."
--t1.backColor = color.fromArgb (100 255 100 200) -- == grey
--t1.backColor = (dotNetClass "System.Drawing.Color").fromArgb (100 255 100 200) -- ==grey
--t1.BackColor = (dotNetClass "System.Drawing.Color").Transparent -- == nothing
t2 = dotNetObject "System.Windows.Forms.TabPage" "Normal"
t3 = dotNetObject "System.Windows.Forms.TabPage" "Specular"
t4 = dotNetObject "System.Windows.Forms.TabPage" "Ambo"
t5 = dotNetObject "System.Windows.Forms.TabPage" "DUDV"
--Add the Tabpages to the TabControl
thetc.controls.add t1
thetc.controls.add t2
thetc.controls.add t3
thetc.controls.add t4
thetc.controls.add t5
)
--try(
on MapTabs mousedown arg do(
......
you can se my trials of giving it a color and the result commented behind it, i also tried
MapTabs.BackColor = (dotNetClass "System.Drawing.Color").Transparent
MapTabs.BackColor = MapTabs.BackColor.white
but none works for me.
i either get a grey bar instead of the TC or no changes at all
. .:wip:
:cry:
does anybody have a clue whats going wrong and how to solve it?
edit: right my goal.. :D
i want to assign a special color or make them transparent. if a background bitmap wouldn't replace the caption i'd also go for that.
ZeBoxx2
01-02-2009, 06:29 AM
the .backColor works fine, but...
1. Your tabcontrol is not tall enough to show any tab content - it only shows the tab headers, so you won't see any of the .backColor changes (which are for the tab content). Make the control taller and you should see the .backColor changes.
2. I'm guessing you want to change the background color of the tab headers, not of the tab content.
The solution for 2 is setting up the tab control for custom drawing, and applying that drawing when the drawing event is called. This is a fair amount of work, but appears to be outlined clearly enough in various internet resources;
http://dotnetrix.co.uk/tabcontrol.htm
It might be easier to load a third party tab control - you'll notice many here referencing TabControlEx, for example.. from the same author - that makes the process much easier.
http://dotnetrix.co.uk/controls.htm
Insanto
01-02-2009, 07:50 AM
yeah i just took the headers to keep the .net as small as possible as i have to maintain compatibility to max8, as i switch between AX and .net and only use the header of the TC.
didn't know you couldn't colorize the header, do you know if you can do that with the other one?
as i'm not that fluent in .net, would i have to install that dll or whatever it's contained in in the system or is it kinda plug n play?
ZeBoxx2
01-02-2009, 01:10 PM
didn't know you couldn't colorize the header, do you know if you can do that with the other one?
Yes - setting the .backColor on TabControlEx will color both the content background as well as the header background. In fact, I'm not sure how one might separate the two (short of the custom drawing, again).. though for your purposes where you're only actually using the tab headers, that might not be a big issue.
( Though if you're only using the tab headers, does that mean you do your own displaying/hiding of controls to simulate the pages? Yikes? .. and if so, you could go all the way and simulate the headers with image buttons or imgtags ;) )
would i have to install that dll
Not really 'install' it, but it does have to be placed somewhere that 3ds Max can access it.
or is it kinda plug n play?
pretty much, you just load it from maxscript from wherever you decide storing it, and then use the classes, objects, etc. inside as you would any standard .NET bits. e.g.
dotNet.loadAssembly "c:\\3dsmax11\\TabControlEX.dll"
rollout roll_test "test" width:400 height:200 (
dotNetControl dnc_tabcontrol "Dotnetrix.Controls.TabControlEX" width:380 height:180
)
createDialog roll_test
dn_color = (dotNetClass "System.Drawing.Color")
roll_test.dnc_tabcontrol.backColor = dn_color.transparent
roll_test.dnc_tabcontrol.appearance = (dotNetClass "Dotnetrix.Controls.TabAppearanceEX").Bevel
roll_test.dnc_tabcontrol.tabPages.add "Hello"
roll_test.dnc_tabcontrol.tabPages.Item[0].backColor = dn_color.red
roll_test.dnc_tabcontrol.tabPages.add "World"
roll_test.dnc_tabcontrol.tabPages.Item[1].backColor = dn_color.blue
roll_test.dnc_tabcontrol.refresh()
martroyx
01-02-2009, 05:41 PM
you can also use the devexpress tabcontrol, it have some cool feature, like header gradient :-P
try (destroydialog roll_test) catch()
(
dotnet.loadAssembly (getdir #maxroot + "\\DevExpress.XtraEditors.v7.1.dll")
--//--
rollout roll_test "test" width:400 height:200 (
dotNetControl dnc_tabcontrol "DevExpress.XtraTab.XtraTabControl" width:380 height:180
)
--//--
createDialog roll_test
--//--
roll_test.dnc_tabcontrol.headerlocation=roll_test.dnc_tabcontrol.headerlocation.left
roll_test.dnc_tabcontrol.lookandfeel.style=roll_test.dnc_tabcontrol.lookandfeel.style.Style3D
roll_test.dnc_tabcontrol.lookandfeel.usedefaultlookandfeel=false
roll_test.dnc_tabcontrol.lookandfeel.usewindowsxptheme=false
roll_test.dnc_tabcontrol.appearancepage.header.backcolor=(dotnetclass "system.drawing.color").SlateGray
roll_test.dnc_tabcontrol.appearancepage.header.backcolor2=(dotnetclass "system.drawing.color").white
roll_test.dnc_tabcontrol.appearancepage.pageclient.backcolor=(dotnetclass "system.drawing.color").SlateGray
roll_test.dnc_tabcontrol.appearancepage.pageclient.backcolor2=(dotnetclass "system.drawing.color").white
roll_test.dnc_tabcontrol.appearancepage.headeractive.backcolor=(dotnetclass "system.drawing.color").gold
roll_test.dnc_tabcontrol.appearancepage.headeractive.backcolor2=(dotnetclass "system.drawing.color").red
roll_test.dnc_tabcontrol.borderstylepage=roll_test.dnc_tabcontrol.borderstylepage.simple
roll_test.dnc_tabcontrol.showheaderfocus=roll_test.dnc_tabcontrol.showheaderfocus.false
roll_test.dnc_tabcontrol.name="roll_test.dnc_tabcontrol"
--//--
NewTab1=roll_test.dnc_tabcontrol.TabPages.Add()
NewTab1.text="World"
NewTab1.name="NewTab1"
--//--
NewTab2=roll_test.dnc_tabcontrol.TabPages.Add()
NewTab2.text="Hello"
NewTab2.name="NewTab2"
)
martin
ZeBoxx2
01-02-2009, 06:37 PM
nice :)
*cringes at all the drawing.colors*
-- yum
fn dotnetcolor r g b = ( (dotNetClass "System.Drawing.Color").fromArgb r g b )
rollout roll_test "test" (
dotNetControl dnc_button1 "Windows.Forms.Button" width:48 height:16
)
createDialog roll_test
roll_test.dnc_button1.backColor = (dotnetcolor 255 128 64)
-- yum!
-- (the parentheses are not required but it means less mental switching of
-- languages when it looks more like a standard maxscript (color r g b) def.
-- then again - why didn't they make (color r g b) translate on the fly? :curious: )
Insanto
01-04-2009, 03:57 AM
oh i'll definately look into this, thx.
do you btw know how to load a custom AX object? like the .net Struct Methods you know, would be great to know.
thx in advance
ZeBoxx2
01-07-2009, 12:57 PM
I don't think you can easily load activex components - they have to be installed/registered to Windows before you can use them. You *might* be able to do that from within 3ds Max, but I wouldn't have the foggiest where to even begin.
Insanto
01-07-2009, 06:31 PM
hmm yeah im afraid i have to register thm in the OS before..
well.. i now made my own little tabcontroll, out of buttons and images ;)
and disintegrated .net and ax, i should've done that from the beginning.
thx for the help guys
ZeBoxx2
01-07-2009, 09:04 PM
haha... yeah, sounded like that'd be the way to go if you were doing your own 'page' behavior anyway :)
CGTalk Moderation
01-07-2009, 09:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.