Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - TabControl.InsertItem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

TabControl.InsertItem

 Post Reply Post Reply
Author
Message
Jean View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 December 2006
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jean Quote  Post ReplyReply Direct Link To This Post Topic: TabControl.InsertItem
    Posted: 30 May 2008 at 3:54am
I like to dynamiccally fill a TabControl with items and TabPages.
On the pages I like to load Controls.
I use WinApi SetParent for this.

This is the Gui of my test application:


I can create the Items, Pages and Controls. If you switch the TabPages, everything looks fine
But if you click on a TextBox and then on the underlaying tabPage the TabControl is confused and doesen't show the page content proper.

Test:
1.) click the AddPage button twice
2.) select the second TabPage (new 1)
3.) click AddControl
4.) click inside the new control (the textbox)
5.) click below on the TabPage

I guess using SetParent causes the problem. Is there another way to create and draw the TabControl + Child-Controls dynamically?

uploads/20080530_035238_Sample.zip
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2008 at 4:53am
Hello,
 
You can try avoid using  TabControlPage, just add new controls to form/tabcontol and show/hide them if user change selected tab
 
tabControl.InsertItem tabControl.ItemCount, "New " & tabControl.ItemCount, 0, 0
...
 
Call SetParent(dynTxt(dynTxt.Count - 1).hWnd, tabControl.hWnd)
 
 
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Jean View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 December 2006
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jean Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2008 at 5:47am
This seems to work. Thank you!
Now I have to write code to do what I thought the TabControl is doing.
But I guess the TabControl+TabControlPages have not been developped for my "special case".
Back to Top
Krog View Drop Down
Groupie
Groupie


Joined: 06 February 2008
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote Krog Quote  Post ReplyReply Direct Link To This Post Posted: 04 November 2009 at 12:04am
Hi!

I would like to use the TabControlPage for the same purpose and I am getting the same problem.

I am using the following line instead of SetParent:

Set Text1(TxtCount).Container = TabControlPage1(TabCount)

How can I solve it?

Note: I don't want to do the TabControlPage work and also I want the TabControlPage background that we don't get using a frame or picturebox... And the TabControlPages may be created at runtime.

Can someone help me?
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2
Language: Visual Basic 6 SP6
Back to Top
Krog View Drop Down
Groupie
Groupie


Joined: 06 February 2008
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote Krog Quote  Post ReplyReply Direct Link To This Post Posted: 04 November 2009 at 12:48am
I was testing a workaround using an array of TabControlPages using the Index property at design time but a bug occurs and no one control is displayed, and only one TabControlPage is displayed, empty.

The solution was:
-not to use the Index property at design time to create the array;
-use an array in the code and assign it at run-time, like this:

Dim TabCtlPage() As TabControlPage

Private Sub Form_Load()
Dim i As Integer

ReDim TabCtlPage(0 To 5)
Set TabCtlPage(0) = TabControlPage1
Set TabCtlPage(1) = TabControlPage2
Set TabCtlPage(2) = TabControlPage3
Set TabCtlPage(3) = TabControlPage4
Set TabCtlPage(4) = TabControlPage5
Set TabCtlPage(5) = TabControlPage6

' The tabs that are not being used, we hide:

TabControl1.Item(3).Visible = False
TabControl1.Item(4).Visible = False
TabControl1.Item(5).Visible = False

End Sub


But I am still preferring to create the TabControlPages at run-time and use an array. So the solution is welcome.
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2
Language: Visual Basic 6 SP6
Back to Top
Xander75 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 April 2007
Status: Offline
Points: 353
Post Options Post Options   Thanks (0) Thanks(0)   Quote Xander75 Quote  Post ReplyReply Direct Link To This Post Posted: 09 May 2010 at 4:08am
Hi Jean & Krog,

I stumbled across this post recently as I looked for an answer here in the forums, I know this is a bit late in the day from when you originally posted but I have found a solution and thought I should share it.

I too faced the issue with using the TabControlPage but I manged to find a solution that allows you to add new Tabs dynamically and any controls, in my case I was using the ReportControl.

The solution is to avoid using the TabControlPage and instead use a PictureBox as the container, I also avoid using the SetParent API. Please see the code below and the attached sample project for the solution.

Code Preview:

Dim lIndex As Long

Private Sub Command1_Click()
    ' Increment the lIndex variable
    lIndex = lIndex + 1
  
    ' Load a new picReport Container and rpcReport ReportControl
    Load picReport(lIndex)
    Load rpcReport(lIndex)
   
    ' Insert the picReport Container into a new tab
    tabReport.InsertItem lIndex, "New " & lIndex, picReport(lIndex).hWnd, 0
    tabReport.SelectedItem = lIndex
   
    ' Set the rpcReport ReportControl container to be the picReport Container
    Set rpcReport(lIndex).Container = picReport(lIndex)
   
    ' Resize the rpcReport ReportControl to fit the picReport Container
    rpcReport(lIndex).Move 0, 0, picReport(lIndex).Width, picReport(lIndex).Height
    rpcReport(lIndex).Visible = True
   
    ' Add Column Configs
    Dim Column As ReportColumn
    Set Column = rpcReport(lIndex).Columns.Add(0, "Name", 200, True)
   
    ' Add Data to Grid
    Dim Record As ReportRecord
    Set Record = rpcReport(lIndex).Records.Add
    Record.AddItem "Grid " & CStr(lIndex)
   
    ' Refresh the rpcReport ReportControl
    rpcReport(lIndex).Populate
End Sub

I hope this helps someone...

uploads/20100509_041040_DynamicTabs_.zip
Back to Top
Krog View Drop Down
Groupie
Groupie


Joined: 06 February 2008
Status: Offline
Points: 100
Post Options Post Options   Thanks (1) Thanks(1)   Quote Krog Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2016 at 3:49pm
Years later I was with the same problem and I found this thread with my own comments! I didn't even remember of them.

Well, I solved it using a Codejock GroupBox with Transparent=True (and removing the Caption and with no borders) on top of the TabControlPage

It works like a charm
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2
Language: Visual Basic 6 SP6
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.