Mirc tabs
Mirc tabs
how can i implent a TABS like Mirc program and control multi windows??
havnet seen that yet...
seems delphi programmers are doing it allot
havnet seen that yet...
seems delphi programmers are doing it allot
Tabbed panels are particularly easy in PureBasic.
Here are the beginnings of a tabbed notebook:
Here are the beginnings of a tabbed notebook:
Code: Select all
; PureBasic Visual Designer v3.80 build 1249
;- Standard Procedures
Procedure Die(Message.s)
MessageRequester("Fatal Error", Message)
End
EndProcedure
;- Window Constants
;
Enumeration
#Window_Main
EndEnumeration
;- MenuBar Constants
;
Enumeration
#MenuBar_2
EndEnumeration
Enumeration
#MENU_New
#MENU_Open
#MENU_Close
#MENU_Exit
#MENU_Nothing
#MENU_About
EndEnumeration
;- Gadget Constants
;
#Maximum_Number_Of_Tabs = 10
Enumeration
#TabbedPanel
#EditorGadget
#NextGadget = #EditorGadget + #Maximum_Number_Of_Tabs
EndEnumeration
;-Files
Enumeration
#TextFile
EndEnumeration
;-Structures
Structure NotebookTab
File_Path.s
EndStructure
;-Global Variables
Global Tabbed_Panel_Handle
Global Current_Tab
Global Last_Tab
Last_Tab = -1
Current_Tab = -1
Dim Tabs.NotebookTab(#Maximum_Number_Of_Tabs)
Procedure Open_Window_Main()
If OpenWindow(#Window_Main, 0, 0, 600, 431, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_WindowCentered , "Tabbed Notedbook") = 0
Die("Unable to Create Main Window")
EndIf
If CreateMenu(#MenuBar_2, WindowID()) = 0
Die("Unable to Create Menubar for Main Window")
EndIf
MenuTitle("File")
MenuItem(#MENU_New, "New")
MenuItem(#MENU_Open, "Open")
MenuItem(#MENU_Close, "Close")
MenuItem(#MENU_Exit, "Exit")
MenuTitle("Edit")
MenuItem(#MENU_Nothing, "Nothing here yet")
MenuTitle("Help")
MenuItem(#MENU_About, "About")
If CreateGadgetList(WindowID()) = 0
Die("Unable to Create GadgetList for Main Window")
EndIf
Tabbed_Panel_Handle = PanelGadget(#TabbedPanel, 0, 10, 600, 420)
CloseGadgetList()
DisableMenuItem(#MENU_Nothing, 1)
EndProcedure
;-Procedures
Procedure Change_Tab(TabID.l)
If TabID < 0 Or TabID > Last_Tab
MessageRequester("Cannot Change Tab", Str(TabID) + " is not a valid tab")
Else
SetGadgetState(#TabbedPanel, TabID)
EndIf
EndProcedure
Procedure Add_Tab(Label.s)
If Last_Tab >= #Maximum_Number_Of_Tabs
MessageRequester("Cannot Add Tab", "You will have To close a tab before opening any more")
Else
Last_Tab = Last_Tab + 1
Current_Tab = Last_Tab
;Add our new tab to the array
Tabs(Current_Tab)\File_Path = ""
;Add the new tab to the panel gadget
If UseGadgetList(Tabbed_Panel_Handle) = 0
Die("Unable to Use GadgetList for new tab")
EndIf
AddGadgetItem(#TabbedPanel, -1, Label)
EditorGadget(#EditorGadget + Current_Tab, 8, 8, 580, 360)
Change_Tab(Current_Tab)
EndIf
EndProcedure
Procedure Create_New_File()
Add_Tab("<New>")
EndProcedure
Procedure Open_Existing_File()
File_Path.s = OpenFileRequester("Open Text File", "", "*.*", 0)
If OpenFile(#TextFile, File_Path) = 0
MessageRequester("Cannot Load File", File_Path + " is not a valid file.")
Else
Add_Tab(GetFilePart(File_Path))
Tabs(Current_Tab)\File_Path = File_Path
ClearGadgetItemList(#EditorGadget + Current_Tab)
While Eof(#TextFile) = 0
File_Line.s = ReadString()
AddGadgetItem(#EditorGadget+Current_Tab, -1, File_Line)
Wend
CloseFile(#TextFile)
EndIf
Change_Tab(Current_Tab)
EndProcedure
Procedure Remove_Tab(TabID)
If TabID < 0 Or TabID > Last_Tab
MessageRequester("Cannot Remove Tab", Str(TabID) + " is not a valid tab")
Else
If TabID < Last_Tab
For i = TabID To Last_Tab - 1
Tabs(i)\File_Path = Tabs(i + 1)\File_Path
SetGadgetItemText(#TabbedPanel, i, GetGadgetItemText(#TabbedPanel, i + 1, 0), 0)
SetGadgetText(#EditorGadget + i, GetGadgetText(#EditorGadget + i + 1))
Next
EndIf
RemoveGadgetItem(#TabbedPanel, Last_Tab)
Last_Tab = Last_Tab - 1
If Last_Tab < 0
Create_New_File()
ElseIf Current_Tab < Last_Tab
Change_Tab(Current_Tab)
Else
Change_Tab(Last_Tab)
EndIf
EndIf
EndProcedure
Procedure Close_Current_Tab()
Remove_Tab(Current_Tab)
EndProcedure
;-Event Loop
Procedure Event_Loop()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenuID()
;File Menu
Case #MENU_New
Create_New_File()
Case #MENU_Open
Open_Existing_File()
Case #MENU_Close
Close_Current_Tab()
Case #MENU_Exit
Event = #PB_Event_CloseWindow
;Edit Menu (nothing here yet)
;Help Menu
Case #MENU_About
MessageRequester("Feel the PuRe Power", "Tabbed Notebook example")
EndSelect
Case #PB_Event_Gadget
Select EventGadgetID()
Case #TabbedPanel
Current_Tab = GetGadgetState(#TabbedPanel)
Case #EditorGadget + Current_Tab
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndProcedure
;-Initialisation
Open_Window_Main()
Create_New_File()
Event_Loop()
Hi Pantcho,
Maybe you could modify a PanelGadget to make it look similar to what you want? This example makes the Tabs of a Panel flat...
http://www.reelmedia.org/~paul/flatpanel.zip
Making it look like this...

Maybe you could modify a PanelGadget to make it look similar to what you want? This example makes the Tabs of a Panel flat...
http://www.reelmedia.org/~paul/flatpanel.zip
Making it look like this...

Last edited by Paul on Sun Aug 15, 2004 10:26 pm, edited 1 time in total.
maybe the mIRC one is hand-made? I've never been too sure how it works
Edit: I just ran Spy++ and found out that the switchbar's class is "mIRC_Switchbar" - as this isn't a regular control class (button, edit, static, etc) then it must be a custom window [gadget] (Or custom class at least, not sure if they're related)
Edit 2: the class of the tabber in Paul's example is "SysTabControl32", in case you were wondering. (Nice example Paul, btw
)
Edit: I just ran Spy++ and found out that the switchbar's class is "mIRC_Switchbar" - as this isn't a regular control class (button, edit, static, etc) then it must be a custom window [gadget] (Or custom class at least, not sure if they're related)
Edit 2: the class of the tabber in Paul's example is "SysTabControl32", in case you were wondering. (Nice example Paul, btw

Last edited by Kris_a on Wed Mar 17, 2004 5:38 pm, edited 1 time in total.
Extra work?GedB wrote:It seems like extra work for what appears to be an inferior solution.
It's only 2 lines of code to make a Panel Tab flat

Anyway, this is obviously not what is used in the mIRC program but it a different type of "look" for those that are interested in using it in their own apps.
Enjoy!
he posted it himself. i can get it, just look a few posts up..
Well if you are to lazy, heres the link: http://pureproject.net/users/Paul/flatpanel.zip
Well if you are to lazy, heres the link: http://pureproject.net/users/Paul/flatpanel.zip