Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Put A Form Into A TabSheet

Posted on 1999-01-22
7
Medium Priority
?
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 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