AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tab control in another tab control?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Areilius



Joined: 16 Feb 2006
Posts: 42

PostPosted: Thu Mar 30, 2006 11:14 am    Post subject: Tab control in another tab control? Reply with quote

This is my first time using the tab control, so sorry if this is a stupid question.

Say I have a tab control with 3 tabs.
Is it possible to have a second tab control as part of one of the tabs in the first set?

All my attempts have resulted in the second tab control being created behind the first tab control, or beside it.

Is this impossible or am I stupid Razz
Back to top
View user's profile Send private message Send e-mail
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Mar 30, 2006 1:17 pm    Post subject: Reply with quote

No, I recall having seen that it is a limitation of Gui Tab, but I can't find it back in the manual, so perhaps I saw this in the forum.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Grendel



Joined: 18 Nov 2005
Posts: 25
Location: Germany

PostPosted: Thu Mar 30, 2006 4:28 pm    Post subject: Reply with quote

hmm, maybe not with GUI,Tab...

but he can do a workaround emulating the main tab with some radiobuttons.
So each radiobutton-selection can produce their own dialog elements (incl. tabs) inside the main dialog dynamically.
I know, this is much harder to code, but it should be possible.
_________________
greets Grendel
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Mar 30, 2006 4:49 pm    Post subject: Reply with quote

Having subtabs may create a confusing GUI...
Perhaps the GUI should be rethinked to something simplier.
Otherwise, as Grendel stated, this can be emulated with other controls, even active Picture controls showing tabs...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
shimanov



Joined: 25 Sep 2005
Posts: 612

PostPosted: Thu Mar 30, 2006 5:34 pm    Post subject: Reply with quote

The only known disadvantage of embedding a tab control within another, seems to be a side effect altering the behavior of relative positioning. Otherwise, it is the best method for selectively displaying a set of controls, since it capitalizes on existing AHk mechanisms.

Try this:

Code:
Gui, +LastFound
hw_gui := WinExist()

Gui, Add, Tab, x5 y5 w200 h200 vTabControl1, Tab 1|Tab 2
hw_gui_tab1 := DllCall( "FindWindowEx", "uint", hw_gui, "uint", 0, "str", "SysTabControl32", "uint", 0 )

   Gui, Tab, Tab 1
      Gui, Add, Edit, x10 y30 w190 h170

Gui, Tab, Tab 2
   Gui, Add, Tab, x5 y25 w190 h170 Hidden vTabControl2, Tab 2.1|Tab 2.2
   hw_gui_tab2 := DllCall( "FindWindowEx", "uint", hw_gui, "uint", hw_gui_tab1, "str", "SysTabControl32", "uint", 0 )
   
   DllCall( "SetParent", "uint", hw_gui_tab2, "uint", hw_gui_tab1 )

   Gui, Tab, Tab 2.1
      Gui, Add, Text, x15 y55, This is Tab 2.1
      Gui, Add, Edit, x15 y75 w180 h120
   
   Gui, Tab, Tab 2.2
      Gui, Add, Text, x15 y55, This is Tab 2.2
      Gui, Add, Button, x15 y75 w50 h20, button

Gui, Show, w210 h210

OnMessage( 0x4E, "WM_NOTIFY" )
return

WM_NOTIFY( p_w, p_l )
{
   global   hw_gui_tab1
   
   if ( DecodeInteger( "uint4", p_l, 0 ) = hw_gui_tab1
         and DecodeInteger( "int4", p_l, 8, false ) = -550-1 )            ; TCN_SELCHANGE
   {
      GuiControlGet, tab,, TabControl1
      
      if ( tab = "Tab 2" )
         GuiControl, Show, TabControl2
      else
         GuiControl, Hide, TabControl2
   }
}

GuiClose:
ExitApp

DecodeInteger( p_type, p_address, p_offset, p_hex=true )
{
   old_FormatInteger := A_FormatInteger

   ifEqual, p_hex, 1, SetFormat, Integer, hex
   else, SetFormat, Integer, dec

   StringRight, size, p_type, 1
   loop, %size%
      value += *( ( p_address+p_offset )+( A_Index-1 ) ) << ( 8*( A_Index-1 ) )
      
   if ( size <= 4 and InStr( p_type, "u" ) != 1 and *( p_address+p_offset+( size-1 ) ) & 0x80 )
      value := -( ( ~value+1 ) & ( ( 2**( 8*size ) )-1 ) )
      
   SetFormat, Integer, %old_FormatInteger%

   return, value
}
Back to top
View user's profile Send private message
Areilius



Joined: 16 Feb 2006
Posts: 42

PostPosted: Fri Mar 31, 2006 6:40 am    Post subject: Reply with quote

Wow, shimanov's got a working solution, but it will be a while before I understand what the hell 90% of that script does! **looks at DllCall and OnMessage** Wink

But I think you're probably right PhiLho, if I need to go as far as putting in sub tabs then it's time to re-think my layout.

If I do decide i need sub tabs i'll use the button\radio idea.
I just realised you could make "toggle" buttons by adding the "BS_PUSHLIKE" style to a radio... That could be handy.

Anyway thanks again for the help guys Very Happy
Back to top
View user's profile Send private message Send e-mail
Thalon



Joined: 12 Jul 2005
Posts: 640

PostPosted: Fri Mar 31, 2006 7:35 am    Post subject: Reply with quote

This was my solution as I had the problem here
Code:
Gui, Add, Tab, vTab2 x30 y65, Test3|Test4
Gui, Tab, 1
Gui, Add, Edit, , First on Second Tab-Control
Gui, Tab, 2
Gui, Add, Edit, , Second on Second Tab-Control
Gui, Add, Tab, vTab1 gTab1 x5 y5, Test1|Test2
Gui, Tab, 1
Gui, Add, Edit, , First on First Tab-Control
Gui, Tab, 2
Gui, Add, Edit, , Second on First Tab-Control

Gui, Show
return

Tab1:
Gui, Submit, NoHide
if Tab1 = Test2
   GuiControl, Hide, Tab2
else
   GuiControl, Show, Tab2
WinSet, Redraw, , A
return
Maybe it is good enough for you and a bit simplier to understand Wink

Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
SacredVault
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri Mar 31, 2006 10:51 am    Post subject: Reply with quote

I tried SetParent too, without success. I though that the tab control managed automatically the swapping of its content, but reading MSDN it seems we have to do the hard job ourselves. Well, actually, AHK does most of this job, relieving the pain... (GuiType::ControlUpdateCurrentTab)

So Thalon's solution works well, once the respective sizes of the tabs are ajusted to make the second looks being inside the first:
Gui, Add, Tab, vTab2 x30 y65 w200 h75, Test3|Test4
Gui, Tab, 1
Gui, Add, Edit, , First on Second Tab-Control
Gui, Tab, 2
Gui, Add, Edit, , Second on Second Tab-Control

Gui, Add, Tab, vTab1 gTab1 x5 y5 w250 h150, Test1|Test2
Gui, Tab, 1, 2
Gui, Add, Edit, , First on First Tab-Control
Gui, Tab, 2, 2
Gui, Add, Edit, , Second on First Tab-Control

I added the , 2 part just to see if it works, it isn't necessary as Gui Tab seems to apply to the latest created tab.

A way to make it needed:
Gui, Add, Tab, vTab2 x30 y65 w200 h75, Test3|Test4
Gui, Add, Tab, vTab1 gTab1 x5 y5 w250 h150, Test1|Test2

Gui, Tab, 1, 1
Gui, Add, Edit, , First on Second Tab-Control
Gui, Tab, 2, 1
Gui, Add, Edit, , Second on Second Tab-Control

Gui, Tab, 1, 2
Gui, Add, Edit, , First on First Tab-Control
Gui, Tab, 2, 2
Gui, Add, Edit, , Second on First Tab-Control

The z-order makes that we must define Tab2 before Tab1, so Tab2 is referred as , 1. It's a bit confusing... I don't recall if we can change the default z-order of GUI controls.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Thalon



Joined: 12 Jul 2005
Posts: 640

PostPosted: Fri Mar 31, 2006 11:05 am    Post subject: Reply with quote

Yes, I didn't spend some time to adjust the size...
But it's only a sample to show the way.

Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
SacredVault
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group