Solved

Put A Form Into A TabSheet

Posted on 1999-01-22
7
279 Views
Last Modified: 2013-12-26
I want to be able to put a form onto a tabsheet.  I am a Delphi programmer and know it can be done there, so I am figuring that VB can do it also.  I am working with VB6.  The big picture is I want to be able to pull in a form from a dll and put it inside of a tabcontrol...

Examples please :)
0
Comment
Question by:MichaelB3
7 Comments
 
LVL 4

Expert Comment

by:tomook
ID: 1489880
You will need to use a UserControl instead of a form. Forms are not embeddable.
0
 

Author Comment

by:MichaelB3
ID: 1489881
Well a form is nothing more than an object, correct?  You can not embed objects inside of objects?
0
 
LVL 3

Expert Comment

by:rmichels
ID: 1489882
In VB a form is a top level windows object. You  can create them, but not embed them (except for MDI forms in a container).  Tomook is correct, you do a user control, which gives you the same effect, except a user control MUST live inside a container.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:MichaelB3
ID: 1489883
Damm.  I knew I used Delphi for some reason :)  Just kidding, VB has some good points that Delphi is missing...

Anyway, thanks...
0
 
LVL 15

Expert Comment

by:ameba
ID: 1489884
You can use SetParent to do what you want. You will need 2 forms

'Form1, add 1 PictureBox
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Form_Load()
    Dim x As Form2, ret As Long
    Set x = New Form2
    x.Show
    ret = SetParent(x.hWnd, Picture1.hWnd)
    x.Move 0, 0
End Sub

But it is better to create user controls, isn't it?
0
 
LVL 15

Accepted Solution

by:
ameba earned 250 total points
ID: 1489885
If your OCX's title is 'PV', and your UserControl is 'PVTabSheet', in VB6 use this:
Private oControl As Control
    Set oControl = frm.Controls.Add("PV.PVTabSheet", "Sheet1")
    oControl.Move 0, sumy
    oControl.Visible = True

To remove control
    Set oControl = frm.Controls("Sheet1")
    frm.Controls.Remove oControl
    Set oControl = Nothing

By using this technique, I reduced memory requirements for my app dramatically.
Before I had 8 tabs with over 200 controls on my main form.
Now, I am dinamicaly loading/unloading 'pages' - my UserControls
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1489886
I have a control that allows you to make a composite control out of any form at run-time. It works in both VB5 & VB6.
I can give you the source code if you want.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 83
message box in access 4 41
Access Object Property from VBA Module in Excel 2010 2 27
IF ELSE Statement in Excel Macro VBA 16 34
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now