Page 1 of 2
Mirc tabs
Posted: Mon Mar 15, 2004 3:18 pm
by Pantcho!!
how can i implent a TABS like Mirc program and control multi windows??
havnet seen that yet...
seems delphi programmers are doing it allot
hi
Posted: Mon Mar 15, 2004 5:37 pm
by thefool
maybe creating tabs and other controls runtime?
Posted: Mon Mar 15, 2004 5:42 pm
by GedB
Any chance of an english translation?
What is a TABS style mirc program? Any example links?
Posted: Mon Mar 15, 2004 5:48 pm
by thefool
I think he means like Opera for an example. When you open more than one window it just put a "tab" in the top of the window(or it can be configured to). Also netscape has that funktionality.
Posted: Mon Mar 15, 2004 6:42 pm
by GedB
You mean like the PureBasic editor?
I thought TABS was the name of some software

Posted: Mon Mar 15, 2004 6:44 pm
by Kris_a
This?

Posted: Mon Mar 15, 2004 9:52 pm
by GedB
Tabbed panels are particularly easy in PureBasic.
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()
Posted: Mon Mar 15, 2004 11:45 pm
by Pantcho!!
Kris_a wrote:This?

yes!! like that extecly!!
and GedB thanks for your example its also a usefull tool!
but my question is like Kris Visualised it

Posted: Wed Mar 17, 2004 12:44 am
by Pantcho!!
anyone?
kris?
8O
Posted: Wed Mar 17, 2004 7:28 am
by Paul
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...

Posted: Wed Mar 17, 2004 10:37 am
by GedB
It seems like extra work for what appears to be an inferior solution.
Functionality is the same, but you've lost the visual metaphor.
Is there any real advantage to make the effort worth it?
Posted: Wed Mar 17, 2004 5:31 pm
by Kris_a
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

)
Posted: Wed Mar 17, 2004 5:38 pm
by Paul
GedB wrote:It seems like extra work for what appears to be an inferior solution.
Extra work?
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!
Posted: Sun Aug 15, 2004 9:39 pm
by Shannara
Anybody have a link to paul's FlatPanel.zip file?
Posted: Sun Aug 15, 2004 10:23 pm
by thefool
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