Disable PanelGadget tabs?
Posted: Sat Jun 18, 2005 3:07 pm
Anyone know how to disable a PanelGadget tab? (I did a search here for
"disable tab" and nothing relevant was found).
"disable tab" and nothing relevant was found).
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
#WinMain = 0
#MyPanel = 0
Global oldCallback
; --> SubClass procedure for PanelGadget
Procedure PanelCallback(hwnd, msg, wparam, lparam)
Shared previousTab
result = CallWindowProc_(oldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_NOTIFY
*pNMHDR.NMHDR = lparam
Select *pNMHDR\code
Case #TCN_SELCHANGING
; --> Get the index of the Tab that is about to lose focus
previousTab = GetGadgetState(#MyPanel)
Case #TCN_SELCHANGE
; --> Get the index of the selected Tab
currentTab = GetGadgetState(#MyPanel)
; --> If it's Tab index 2, our disabled tab,
; --> SetGadgetState to the previousTab index
If currentTab = 2
SetGadgetState(0, previousTab)
EndIf
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(#WinMain, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "PanelGadget") And CreateGadgetList(WindowID(#WinMain))
PanelGadget(#MyPanel, 10, 10, 280, 180)
AddGadgetItem (#MyPanel, -1, "Panel 1")
AddGadgetItem (#MyPanel, -1, "Panel 2")
AddGadgetItem (#MyPanel, -1, "Disabled")
CloseGadgetList()
; --> We need the parent of PanelGadget so we can subclass and recieve messages
hPanelParent = GetParent_(GadgetID(#MyPanel))
oldCallback = SetWindowLong_(hPanelParent, #GWL_WNDPROC, @PanelCallback())
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Code: Select all
; prevtab is global.
Case #WM_NOTIFY
*pNMHDR.NMHDR=lParam
If *pNMHDR\code=#TCN_SELCHANGING
prevtab=GetGadgetState(#panel)
ElseIf *pNMHDR\code=#TCN_SELCHANGE
If GetGadgetState(#panel)<>2 : SetGadgetState(#panel,prevtab) : EndIf
EndIf
Code: Select all
Procedure PanelCallback(hWnd,msg,wparam,lParam)
Result=CallWindowProc_(MainCallback,hWnd,msg,wparam,lParam)
If msg=#WM_NOTIFY
*pNMHDR.NMHDR=lParam
Select *pNMHDR\code
Case #TCN_SELCHANGING : prevtab=GetGadgetState(#panel)
Case #TCN_SELCHANGE : If GetGadgetState(#panel)<>2 : SetGadgetState(#panel,prevtab) : EndIf
EndSelect
EndIf
ProcedureReturn Result
EndProcedure
Code: Select all
SetWindowCallback(@Callback())
MainCallback=SetWindowLong_(GetParent_(GadgetID(#panel)),#GWL_WNDPROC,@PanelCallback())
i dont think that will be an option since there is no associated MESSAGE in win32.hlp about disabling a paneltab.PB wrote: @Fred: New command request -- DisablePanelGadgetTab(#gadget,index)
Code: Select all
Procedure showPanel()
AddGadgetItem(1, 2, "New Hidden Panel")
EndProcedure
Procedure hidePanel()
RemoveGadgetItem(1, 2)
EndProcedure
OpenWindow(1, 0,0,300, 300, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "")
If CreateMenu(0, WindowID())
MenuTitle("Panel")
MenuItem( 1, "Create New Panel")
MenuItem( 2, "Remove New Panel")
EndIf
CreateGadgetList(WindowID())
PanelGadget(1, 10, 10, 250, 250)
AddGadgetItem(1, 0, "Test Panel 1")
AddGadgetItem(1, 1, "Test Panel 2")
; ClosePanelGadget()
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventMenu
Select EventMenuID()
Case 1
showPanel()
Case 2
hidePanel()
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
EndSelect
EndSelect
Until quit
ManoloOpenWindow( 0,0,0,300,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"Test" )
CreateGadgetList( WindowID( 0 ) )
OptionGadget ( 0, 10, 10, 150, 20, "Show Secret Gadget" )
OptionGadget ( 1, 10, 30, 150, 20, "Hide Secret Gadget" )
SetGadgetState( 1, 1 )
PanelGadget( 2, 10, 60, 270, 230 )
AddGadgetItem( 2,-1,"Secret" )
StringGadget( 3,10,10,100,20,"" )
;ClosePanelGadget()
HideGadget ( 2,1 )
HideWindow ( 0, 0 )
Repeat
EW = WaitWindowEvent()
If EW = #PB_Event_Gadget
Select EventGadgetID()
Case 0 : HideGadget( 2, 0 )
Case 1 : HideGadget( 2, 1 )
EndSelect
EndIf
Until EW = #PB_EventCloseWindow
End