Mirc tabs

Just starting out? Need help? Post your questions and find answers here.
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Mirc tabs

Post 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
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

hi

Post by thefool »

maybe creating tabs and other controls runtime?
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Any chance of an english translation?

What is a TABS style mirc program? Any example links?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

You mean like the PureBasic editor?

I thought TABS was the name of some software :oops:
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

Post by Kris_a »

This?

Image
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post 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() 

Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

Kris_a wrote:This?

Image
yes!! like that extecly!! :)

and GedB thanks for your example its also a usefull tool!

but my question is like Kris Visualised it :)
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

anyone?
kris?
8O
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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...
Image
Last edited by Paul on Sun Aug 15, 2004 10:26 pm, edited 1 time in total.
Image Image
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post 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?
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

Post 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 :D)
Last edited by Kris_a on Wed Mar 17, 2004 5:38 pm, edited 1 time in total.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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!
Image Image
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Anybody have a link to paul's FlatPanel.zip file?
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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
Post Reply