Solved

Put A Form Into A TabSheet

Posted on 1999-01-22
7
287 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Object Property from VBA Module in Excel 2010 2 41
Add and format columns in vb6 7 73
Excel Automation VBA 19 104
RUNRMTCMD from AS/400 13 101
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

730 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