Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Put A Form Into A TabSheet

Posted on 1999-01-22
7
Medium Priority
?
296 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

886 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