TOPIC: Adding tabs to tabcontrol
#1897
Adding tabs to tabcontrol 5 Months, 2 Weeks 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!
 
 
#1898
Re:Adding tabs to tabcontrol 5 Months, 2 Weeks 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)
    ))

 
 
andrew
 
#1899
Re:Adding tabs to tabcontrol 5 Months, 2 Weeks 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.
 
 
#1900
Re:Adding tabs to tabcontrol 5 Months, 2 Weeks 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
 
 
Last Edit: 2010/03/09 22:46 By andrew. Reason: fixed indenting of code (need spaces, not tabs)
 
#1901
Re:Adding tabs to tabcontrol 5 Months, 2 Weeks ago
Good additions.

Dragging would be very nice :-)

Thanks!
 
 
andrew
 
#1902
Re:Adding tabs to tabcontrol 5 Months, 1 Week 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.
 
 
Last Edit: 2010/03/16 13:44 By Peter.
 
#1903
Re:Adding tabs to tabcontrol 5 Months, 1 Week ago
Nice addition! Thanks!

One place we could use this is in LibraryView to allow renaming from the tab as well as the tree.
 
 
andrew
 
#1904
Re:Adding tabs to tabcontrol 5 Months, 1 Week 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.
 
 
#1905
Re:Adding tabs to tabcontrol 5 Months, 1 Week 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).
 
 
andrew
 
#1906
Re:Adding tabs to tabcontrol 5 Months, 1 Week 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.
 
 
#1907
Re:Adding tabs to tabcontrol 4 Months, 2 Weeks ago
OK I tried to make some drag-n-drop tab. It works but is a but rough need some more improvement. Any idea how make nice drag-n-drop cursor? I attach 2 files, for tabcontrol and tabscontrol.
 
 
Last Edit: 2010/04/08 13:54 By Peter.
 
#1908
Re:Adding tabs to tabcontrol 4 Months, 2 Weeks ago
File Attachment:
File Name: tabsControl-8259ccf7ae61f8432a5e9d7fe04bb5a3.txt
File Size: 6366

File Attachment:
File Name: tabsControl-8259ccf7ae61f8432a5e9d7fe04bb5a3.txt
File Size: 6366




having some issues with attaching files...
 
 
#1909
Re:Adding tabs to tabcontrol 4 Months, 2 Weeks ago
File Attachment:
File Name: tabControl.txt
File Size: 7092

and the other file...
 
 
#1910
Re:Adding tabs to tabcontrol 4 Months, 2 Weeks ago
Great, thanks!

I will take a look.
 
 
andrew
 
#1911
Re:Adding tabs to tabcontrol 4 Months, 2 Weeks ago
Looks reasonable. I am away for the next two weeks but when I get back I will add this to stdlib and post a new snapshot. (We have a few other nice new things.)

I think there are ways to get drag images but I do not remember how it is done. We have dragging in the tree (e.g. in LibraryView) but I am not sure if that is helpful.
 
 
andrew