Page 1 of 1

Change PanelGadget Orientation?

Posted: Thu Dec 09, 2004 9:22 pm
by johnfermor
Hi

Is it possible to change the orientation of a panelgadget in the same way as with a VB Tabstrip? Or is this one for the WishList?

For Example;

Image

Cheers ...

Posted: Fri Dec 10, 2004 4:02 am
by Flype
hello

some infos here ( go to the 'tab styles' lines ) : http://www.autohotkey.com/docs/misc/Styles.htm

and here how to set styles...

Code: Select all

#TCS_SCROLLOPPOSITE = $1
#TCS_BOTTOM         = $2
#TCS_RIGHT          = $2
#TCS_MULTISELECT    = $4
#TCS_FLATBUTTONS    = $8
#TCS_FORCEICONLEFT  = $10
#TCS_FORCELABELLEFT = $20
#TCS_HOTTRACK       = $40
#TCS_VERTICAL       = $80
#TCS_MULTILINE      = $200

Procedure SetStyle(Handle, style.l) 
  SetWindowLong_(Handle, #GWL_STYLE, GetWindowLong_(Handle, #GWL_STYLE) | style) 
EndProcedure 

OpenWindow(0, 300, 300, 300, 300, #PB_Window_SystemMenu, "Tab test", 0)
CreateGadgetList(WindowID()) 
PanelGadget(0, 0, 0, 300, 300) 
For i = 1 To 9
  AddGadgetItem(0, i - 1, "Onglet " + Str(i)) 
Next 
CloseGadgetList() 
  
SetStyle(GadgetID(0),#TCS_MULTILINE) 
SetGadgetState(0,0) 
  
Repeat : Until WaitWindowEvent()=#WM_CLOSE 

Posted: Fri Dec 10, 2004 4:34 pm
by gilles_k
Thanks Flype.

Justement c'est ce que cherchais. :wink:

Posted: Fri Dec 10, 2004 11:27 pm
by PB
Flype, thanks for the flag information, but I can't get a working example of
vertical tab buttons. When I try, only some buttons work and others don't.
Also, the text on the tabs is still horizontal and not vertical. Any ideas?

Posted: Sat Dec 11, 2004 2:07 am
by Sparkie
Be aware that PanelGadget's with tabs on the sides or bottom are not supported with XP skins enabled. msdn info here

I've had some success with the native PanelGadget but for now it seems easier to use Win32 API to create your own. This is what I've come up with so far. This code creates a TabControl (PanelGadget) with tabs on the left side.

Not sure how efficient this would be in a real project, but here it is none the less. ;)

Code: Select all

#TCS_TABS = 0
#TCS_BOTTOM = 2       ; Place tabs on bottom
#TCS_RIGHT = 2        ; Place tabs on right
#TCS_FLATBUTTONS = 8
#TCS_VERTICAL = $80   ; Place tabs on left
#TCS_BUTTONS = $100
#TCS_MULTILINE = $200 ; Required if using #TCS_VERTICAL
#Panel_0 = 100
Enumeration
  #Container_0
  #Container_1
  #Button_0
  #Button_1
  #ExplorerList_0
  #ExplorerTree_0
EndEnumeration
Procedure myWindowCallback(hwnd, msg, wparam, lparam)
  Shared tabToHideID
  result = #PB_ProcessPureBasicEvents
  Select msg
    Case #WM_NOTIFY
      *pnmhdr.NMHDR = lparam
      If *pnmhdr\code = #TCN_SELCHANGING 
        *ptcnmhdr.NMHDR = lparam
        ; --> Get Tab that is losing focus (this ID = #Container_0 or #Container_1)
        tabToHideID = SendMessage_(*ptcnmhdr\hwndFrom, #TCM_GETCURSEL, 0, 0)
      EndIf
      If *pnmhdr\code = #TCN_SELCHANGE 
        *ptcnmhdr.NMHDR = lparam
        ; --> Get Tab that is gaining focus (this ID = #Container_0 or #Container_1)
        tabToShowID = SendMessage_(*ptcnmhdr\hwndFrom, #TCM_GETCURSEL, 0, 0)
        If *ptcnmhdr\idFrom = #Panel_0
          ; --> Show / hide tab contents
          HideGadget(tabToShowID, 0)
          HideGadget(tabToHideID, 1)
        EndIf
      EndIf
  EndSelect
  ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 400, 200,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Sparkies Custom PanelGadget") And CreateGadgetList(WindowID(0)) 
  SetWindowCallback(@myWindowCallback())
  panelX = 10
  panelY = 10
  panelW = WindowWidth() - 20
  panelH = WindowHeight() - 20
  ; --> Define style and create PanelGadget()
  ; --> To use standard tabs
  tcStyle = #TCS_TABS | #TCS_MULTILINE | #TCS_VERTICAL
  ; --> To use buttons
  ;tcStyle = #TCS_BUTTONS | #TCS_MULTILINE | #TCS_VERTICAL
  ; --> To use flat buttons
  ;tcStyle = #TCS_FLATBUTTONS | #TCS_BUTTONS | #TCS_MULTILINE | #TCS_VERTICAL
  hPanel = CreateWindowEx_(#WS_EX_LEFT | #WS_EX_LTRREADING | #WS_EX_RIGHTSCROLLBAR, "SysTabControl32", "PanelGadget1", #WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_CLIPSIBLINGS | #WS_GROUP | #WS_TABSTOP | tcStyle, panelX, panelY, panelW, panelH, WindowID(), #Panel_0, GetModuleHandle_(0) , 0)
  ; --> Load and set font to use for tabs (optional)
  tabFont = LoadFont(0, "Arial", 10, #PB_Font_Bold)
  SendMessage_(hPanel, #WM_SETFONT, tabFont, 1)
  pgadItem.TC_ITEM
  ; --> init Tab #1
  tabText1$ = "Tab #1"
  pgadItem\mask = #TCIF_TEXT
  pgadItem\pszText = @tabText1$
  pgadItem\cchTextMax = Len(tabText1$)
  ; --> Insert tab #1
  SendMessage_(hPanel, #TCM_INSERTITEM, #Container_0, pgadItem) 
  ; Get rect for tab for placement of our ContainerGadgets to follow
  SendMessage_(hPanel, #TCM_GETITEMRECT, #Container_0, @tcRect.RECT)
  ; --> Need to work on a better placement formula, but this seems to work for now
  ContainerGadget(#Container_0, panelX+(tcRect\right-tcRect\left)+3, panelY+tcRect\top, panelW-(tcRect\right-tcRect\left)-6, panelH-6)
  ; --> Add some gadgets to Tab #1 (#Conatiner_0 is parent)
  ButtonGadget(#Button_0, 100, 10, 120, 20, "Hello, we are in Tab #1")
  ExplorerListGadget(#ExplorerList_0, 10, 35, 330, 120, "c:\")
  CloseGadgetList()
  ; --> init Tab #2
  tabText2$ = "Tab #2"
  pgadItem\mask = #TCIF_TEXT
  pgadItem\pszText = @tabText2$
  pgadItem\cchTextMax = Len(tabText2$)
  SendMessage_(hPanel, #TCM_INSERTITEM, #Container_1, pgadItem) 
  ; --> Need to work on a better placement formula, but this seems to work for now
  ContainerGadget(#Container_1, panelX+(tcRect\right-tcRect\left)+3, panelY+tcRect\top, panelW-(tcRect\right-tcRect\left)-6, panelH-6)
  ; --> Add some gadgets to Tab #1 (#Conatiner_1 is parent)
  ButtonGadget(#Button_1, 100, 10, 120, 20, "Hello, we are in Tab #2")
  ExplorerTreeGadget(#ExplorerTree_0, 10, 35, 330, 120, "c:\")
  CloseGadgetList()
  ; --> We start off in Tab #1 so we hide Tab #2 contents (#Container_1)
  HideGadget(#Container_1, 1)
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_Event_CloseWindow 
EndIf 
End

Posted: Sat Dec 11, 2004 7:46 am
by johnfermor
Thanks guys. Just what I needed!

Posted: Thu Jul 28, 2005 1:36 pm
by Dr. Dri
Sparkie wrote:I've had some success with the native PanelGadget but for now it seems easier to use Win32 API to create your own.
Do you have an example with a native PB PanelGadget working with bottom tabs ??
I would like to choose between native and api Panel please.

Dri

Posted: Thu Jul 28, 2005 8:53 pm
by TerryHough
@Sparkie

As usual you have great solutions.

However, I tried working with your example to make the tabs appear
on the right and on the bottom without success.

Any suggestions?

Terry

Posted: Sun Jul 31, 2005 4:20 am
by Sparkie
@Dr. Dri: Still looking for the old code. I may have to re-do it. If I remember correctly, the PanelGadget has hidden static controls and it was blocking the tab clicks when they were on the bottom.

@TerryHough: Thank you. :)

I'll have a closer look and see what I can come up with.

Posted: Sun Jul 31, 2005 2:26 pm
by TerryHough
@Sparkie
On closer examination, tabs on the bottom or right is working. They are
just getting covered up by the ContainerGadget and/or its contents.

Posted: Wed Aug 10, 2005 2:15 am
by Sparkie
@Dr. Dri: Here's the non-working code I had laying around. There was more to it, but I cut it out because it wasn't helping things work. :(

Code: Select all

#TCS_BOTTOM = 2
#TCS_RIGHT = 2
#TCS_VERTICAL = $80
If OpenWindow(0,0,0,322,220,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"PanelGadget") And CreateGadgetList(WindowID(0)) 
  hPgad = PanelGadget(0,8,8,306,203) 
  AddGadgetItem (0,-1,"Panel 1") 
  AddGadgetItem (0,-1,"Panel 2") 
  ButtonGadget(2, 10, 15, 80, 24,"Button 1") 
  ButtonGadget(3, 95, 15, 80, 24,"Button 2") 
  CloseGadgetList() 
  SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) | #TCS_BOTTOM)
  pgStatic1 = FindWindowEx_(hPgad, 0, "Static", 0)
  MoveWindow_(pgStatic1, 0, 0, 260, 180, 1)
  pgStatic2 = FindWindowEx_(hPgad, pgStatic1, "Static", 0)
  MoveWindow_(pgStatic2, 0, 0, 260, 180, 1)
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 
@Dr. Dri and TerryHough: Sorry I haven't had time to take a closer at this. I hope to be able to be around here a little more some time next month. :)

Posted: Wed Aug 10, 2005 3:09 am
by freak
You should note that these different orientations do not work with ComCtl32.dll version 6 (which comes with XP)
and will therefore not display correctly on a XP system with skins enabled.
(it looks quite ugly actually)

You should use the OSVersion() command to check for XP systems and
use the normal orientation in that case to be save.

Posted: Wed Aug 17, 2005 7:36 pm
by Dr. Dri
interesting code (i don't understand everything...) but changing tab only works once... and after reading freak's reply i think i won't use this kinda panels...

Dri

Posted: Wed Aug 17, 2005 7:45 pm
by Dr. Dri
I've looked closer to your snippet. And now i understand why it only works once. I moved a part of the code and it's okay... Still they was a problem after adding tabs... But i was easy too understand why... Here is my working code thanks to your... (i think it's easy to handle it with a loop...)

Code: Select all

#TCS_BOTTOM = 2
#TCS_RIGHT = 2
#TCS_VERTICAL = $80
If OpenWindow(0,0,0,322,220,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"PanelGadget") And CreateGadgetList(WindowID(0))
  hPgad = PanelGadget(0,8,8,306,203)
  AddGadgetItem (0,-1,"Panel 1")
  AddGadgetItem (0,-1,"Panel 2")
  AddGadgetItem (0,-1,"Panel 3")
  AddGadgetItem (0,-1,"Panel 4")
  ButtonGadget(2, 10, 15, 80, 24,"Button 1")
  ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
  SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) | #TCS_BOTTOM)
  Repeat
    pgStatic1 = FindWindowEx_(hPgad, 0, "Static", 0)
    MoveWindow_(pgStatic1, 0, 0, 260, 180, 1)
    pgStatic2 = FindWindowEx_(hPgad, pgStatic1, "Static", 0)
    MoveWindow_(pgStatic2, 0, 0, 260, 180, 1)
    pgStatic3 = FindWindowEx_(hPgad, pgStatic2, "Static", 0)
    MoveWindow_(pgStatic3, 0, 0, 260, 180, 1)
    pgStatic4 = FindWindowEx_(hPgad, pgStatic3, "Static", 0)
    MoveWindow_(pgStatic4, 0, 0, 260, 180, 1)
  Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Dri ;)

Posted: Wed Aug 17, 2005 7:48 pm
by Dr. Dri
with the loop (for/next)

Code: Select all

#TCS_BOTTOM = 2
#TCS_RIGHT = 2
#TCS_VERTICAL = $80
If OpenWindow(0,0,0,322,220,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"PanelGadget") And CreateGadgetList(WindowID(0))
  hPgad = PanelGadget(0,8,8,306,203)
  AddGadgetItem (0,-1,"Panel 1")
  AddGadgetItem (0,-1,"Panel 2")
  AddGadgetItem (0,-1,"Panel 3")
  AddGadgetItem (0,-1,"Panel 4")
  ButtonGadget(2, 10, 15, 80, 24,"Button 1")
  ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
  SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) | #TCS_BOTTOM)
  Repeat
    pgStatic = 0
    For i = 1 To CountGadgetItems(0)
      pgStatic = FindWindowEx_(hPgad, pgStatic, "Static", 0)
      MoveWindow_(pgStatic, 0, 0, 260, 180, 1)
    Next i
  Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Dri ^^