Solved

Put A Form Into A TabSheet

Posted on 1999-01-22
7
277 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
Comment Utility
You will need to use a UserControl instead of a form. Forms are not embeddable.
0
 

Author Comment

by:MichaelB3
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:MichaelB3
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

743 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

17 Experts available now in Live!

Get 1:1 Help Now