Seite 1 von 1

Panelgadget - Problem/Teibreiter auf der Linken Seite

Verfasst: 09.10.2008 10:40
von smateja
Hallo zusammen,

ich hab mal wieder ein kleiens Problem und hoffe auf eure Mithilfe bei der Lösung.

Ich möchte ein Tab erstellen, welches die Buttons bzw. die Tabreiter auf der linken Seite darstellt. Bin hier im Forum auch schon bisschen fündig geworden: (Nachfolgend mein modifizierter Code)

Code: Alles auswählen

Enumeration

#Main_Window
#Main_Panel

EndEnumeration

#TCS_BOTTOM = 2
#TCS_RIGHT = 2
#TCS_VERTICAL = $80 


Global PanelWidth=800 
Global PanelHeight=600 



OpenWindow(#Main_Window,0,0,800,600,"Test",#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Main_Window))

PanelGadget(#Main_Panel,0,0,PanelWidth,PanelHeight)
        AddGadgetItem(#Main_Panel,1,"Panel 1")
        AddGadgetItem(#Main_Panel,2,"Panel 2")
        AddGadgetItem(#Main_Panel,3,"Panel 2")

        
SetWindowLong_(GadgetID(#Main_Panel), #GWL_STYLE, GetWindowLong_(GadgetID(#Main_Panel), #GWL_STYLE) | #TCS_VERTICAL) 


Repeat

pgStatic = 0 
For i = 1 To CountGadgetItems(#Main_Panel)
      pgStatic = FindWindowEx_(#Main_Panel, pgStatic, "Static", 0)
      MoveWindow_(pgStatic, 0, 0, 260, 180, 1) 
    Next i 


Until WaitWindowEvent()=#PB_Event_CloseWindow
Problem ist nun, dass es mir nicht gelingt die Reiter von der Breite her anzupassen und dass diese überhaupt gehen !?

Hat hier jemand einen Tipp für mich?

Re: Panelgadget - Problem/Teibreiter auf der Linken Seite

Verfasst: 09.10.2008 11:01
von Kiffi
hier vielleicht schon mal ein Ansatz:

Breite und Höhe eines Tabs ändern:
http://www.purebasic.fr/english/viewtop ... 666#166666
(denk daran, dass bei #TCS_VERTICAL Breite und Höhe zu vertauschen sind)

Allerdings klebt der Text am unteren Rand des Tabs. Weiß nicht, wie man
das umgehen kann...

Grüße ... Kiffi

RE:

Verfasst: 09.10.2008 11:07
von smateja
Schaut sich schon ein Stückchen besser aus - nur die Tabs gehen immer noch nciht G* - und die höhe bekomme ich auch nicht in den Griff

Code: Alles auswählen

Enumeration

#Main_Window
#Main_Panel

EndEnumeration

#TCS_BOTTOM = 2
#TCS_RIGHT = 2
#TCS_VERTICAL = $80 


Global PanelWidth=800 
Global PanelHeight=600 
Global ReiterBreite=200


OpenWindow(#Main_Window,0,0,800,600,"Test",#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Main_Window))

PanelGadget(#Main_Panel,0,0,PanelWidth,PanelHeight)
        AddGadgetItem(#Main_Panel,1,"Panel 1")
        AddGadgetItem(#Main_Panel,2,"Panel 2")
        AddGadgetItem(#Main_Panel,3,"Panel 2")

        
SetWindowLong_(GadgetID(#Main_Panel), #GWL_STYLE, GetWindowLong_(GadgetID(#Main_Panel), #GWL_STYLE) | #TCS_VERTICAL) 

PokeW(@lparam,0)   ;width
PokeW(@lparam+2,ReiterBreite) ;height
SendMessage_(GadgetID(#Main_Panel),#TCM_SETITEMSIZE,0,lparam) 


Repeat

pgStatic = 0 
For i = 1 To CountGadgetItems(#Main_Panel)
      pgStatic = FindWindowEx_(#Main_Panel, pgStatic, "Static", 0)
      MoveWindow_(pgStatic, 0, 0, 260, 180, 1) 
    Next i 


Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: RE:

Verfasst: 09.10.2008 11:10
von Kiffi
smateja hat geschrieben:nur die Tabs gehen immer noch nciht
oh, das habe ich gar nicht getestet.

Mhh, dann musste wohl warten, bis die API-Eggsbärden im Board vorbeischauen. ;-)

Grüße ... Kiffi

Verfasst: 09.10.2008 23:39
von scholly
Guck dir mal den thread an.
Der ist zwar von 2004, aber Sparkies Code tuts nach 4.2 konvertiert bei mir:

Code: Alles auswählen

#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,"Sparkies Custom PanelGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  SetWindowCallback(@myWindowCallback())
  panelX = 10
  panelY = 10
  panelW = WindowWidth(0) - 20
  panelH = WindowHeight(0) - 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(0), #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
hdhew... :lol: