Login






Lost Password?
No account yet? Register
Home arrow Forum
Suneido User Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Adding tabs to tabcontrol (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: Adding tabs to tabcontrol
#1897
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Adding tabs to tabcontrol 6 Months ago  
I am trying to add a tabb+control to already build tabbook but get only extra tab, no control added. Does someone have example? Thanks!
 
Logged Logged  
  The administrator has disabled public write access.
#1898
andrew (Admin)
Admin
Posts: 694
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 6 Months ago  
Sorry, I am not sure what you are asking.

Are you adding another top level tab in a book?

Or you want to put tabs within a book page?

Can you explain what you tried?

You can experiment from the WorkSpace, for example:

Code:

Window(#(Tabs
    (Field Tab: One)
    (Field Tab: Two)
    ))

 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1899
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 6 Months ago  
Sorry for not being clear. What I meaning is I already have tabbook open but need to add tabs/pages during runtime. For exampe I have 3 tabs and click tabmenu, selecting open new tab. I can add the tab, but don't know how to add page (control) that belongs to that new tab.
 
Logged Logged  
  The administrator has disabled public write access.
#1900
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 6 Months ago  
Hi,

Sorry, study some more and see there is no standard way of add/remove tabs/pages. Add some methods in tabscontrol:

Code:

AddTab(i, control, text, data = #(tooltip: ""), image = -1)
    {
    .Tab.Insert(i, text, data, image)
    .controls.Add(control, at:i)
    .construct(i)
    .ctrls[i].SetVisible(false)
    }

RemoveTab(i)
    {
    .Tab.Remove(i)
    .controls.Delete(i)
    .ctrls.Delete(i)
    }



Trying to add tabdragging to finish it all :-D
 
Logged Logged  
 
Last Edit: 2010/03/09 22:46 By andrew. Reason: fixed indenting of code (need spaces, not tabs)
  The administrator has disabled public write access.
#1901
andrew (Admin)
Admin
Posts: 694
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 6 Months ago  
Good additions.

Dragging would be very nice :-)

Thanks!
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1902
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 5 Months, 4 Weeks ago  
Dragging is hard but see some good info on the net. Did some other addition that may nice: edit tab label like excel style.

Some code for in Tabcontrol:
Code:


LBUTTONDBLCLK()
 {
 editLable = FieldControl
  {
  New(text, width) { super(width:width set:text); .SubClass() }
  GETDLGCODE(lParam)
   {
   if MSG(lParam) is false
    return 0
   if MSG(lParam).wParam is VK.RETURN
    .Window.Result(.Get())
   return 'callsuper'
   }
  }
 SendMessageRect(.Hwnd, TCM.GETITEMRECT, .GetSelected(), rc = Object())
 ClientToScreen(.Hwnd, pt = Object(x:rc.left y:rc.top))
 w = ((rc.right - rc.left) / .AveCharWidth) / 2
 textOld = .GetText(.GetSelected())
 textNew = Dialog(.Hwnd, Object(editLable, textOld, w) x:pt.x + 3 y:pt.y + 1 border:0 style: WS.POPUP)
 .SetText(.GetSelected(), textNew is false ? textOld : textNew)
 return 0
 } }



Of course need to .SubClass() in New() and needing some argument to enable/disable label editing.
ESC will exit editing, RETURN will confirm editing.

Width w is based on trial/error, work fine for labels that are not too wide.
 
Logged Logged  
 
Last Edit: 2010/03/16 13:44 By Peter.
  The administrator has disabled public write access.
#1903
andrew (Admin)
Admin
Posts: 694
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 5 Months, 3 Weeks ago  
Nice addition! Thanks!

One place we could use this is in LibraryView to allow renaming from the tab as well as the tree.
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1904
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 5 Months, 3 Weeks ago  
One question: can coordinates of tab rect (rc object) be used to set rect of the dialog? I remember something like that. Then its easier to place dialog and make it line up nicer with tab.
 
Logged Logged  
  The administrator has disabled public write access.
#1905
andrew (Admin)
Admin
Posts: 694
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 5 Months, 3 Weeks ago  
ListControl does something similar to this. Run:

BrowseControl("tables")

and double click on a field.

This code is complicated, but it might help. Look at the "edit" method in ListControl (the base for BrowseControl).
 
Logged Logged  
 
andrew
  The administrator has disabled public write access.
#1906
Peter (User)
Posts: 76
User Offline Click here to see the profile of this user
Re:Adding tabs to tabcontrol 5 Months, 3 Weeks ago  
That is how I started but it is complex. I thought that trick in Browse can only be used in listcontrol, not some place else. I will study again to improve code a bit. Thanks for the info.
 
Logged Logged  
  The administrator has disabled public write access.
Go to top