VB4 Load form in form 
Author Message
 VB4 Load form in form

Are there any way (OCX, Win-API, VB code or whatever) to load a form in a
form? Maybe something like the MS Access subform control?


Sat, 20 Jun 1998 03:00:00 GMT  
 VB4 Load form in form

Quote:

> Are there any way (OCX, Win-API, VB code or whatever) to load a form in a
> form? Maybe something like the MS Access subform control?

SetParent Win-API function will do that.

-=Mike=-
(Jouni Tiainen, Carelcomp Forest, Imatra, Finland)



Sat, 20 Jun 1998 03:00:00 GMT  
 VB4 Load form in form

Upphed) threw this at us:

Quote:
>Are there any way (OCX, Win-API, VB code or whatever) to load a form in a
>form? Maybe something like the MS Access subform control?

I guess you can't use MDI forms?

Try the SetParent API. It might work.

Jens
--
* Everything I said are the opinions of someone else.   *
* I just cut-and-pasted.                                *

Jens Balchen jr.       http://www.sn.no/~balchen



Sat, 20 Jun 1998 03:00:00 GMT  
 VB4 Load form in form

Quote:

>SetParent Win-API function will do that.

The SetParent function did almost do the job. The sub form is now within the main
form, but when I click on a control in the sub form the main form is deactivated.

Any idea?



Mon, 22 Jun 1998 03:00:00 GMT  
 VB4 Load form in form

Quote:


says...

> >SetParent Win-API function will do that.

> The SetParent function did almost do the job. The sub form is now
within the main
> form, but when I click on a control in the sub form the main form is
deactivated.

> Any idea?

You should have done it by using picturebox as a container.
Here is sample code:

-=Mike=-
(Jouni Tiainen, Carelcomp Forest, Imatra, Finland)

frmTest.frm (MAIN FORM)
-------------------------------------------------------
VERSION 4.00
Begin VB.Form frmTest
   Caption         =   "Testing"
   ClientHeight    =   4050
   ClientLeft      =   2655
   ClientTop       =   2010
   ClientWidth     =   5085
   Height          =   4455
   Left            =   2595
   LinkTopic       =   "Form1"
   ScaleHeight     =   4050
   ScaleWidth      =   5085
   Top             =   1665
   Width           =   5205
   Begin VB.CommandButton cmdAdd
      Caption         =   "Add"
      Height          =   435
      Left            =   3720
      TabIndex        =   1
      Top             =   180
      Width           =   1275
   End
   Begin VB.TextBox txtText
      Height          =   375
      Left            =   60
      TabIndex        =   0
      Top             =   180
      Width           =   3555
   End
End
Attribute VB_Name = "frmTest"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdAdd_Click()
    frmSub.lstList.AddItem txtText.Text
End Sub

Private Sub Form_Load()
    Dim RC As Long

    Load frmSub
    RC = SetParent(frmSub.picX.hWnd, hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim RC As Long

    RC = SetParent(frmSub.picX.hWnd, frmSub.hWnd)
    Unload frmSub
End Sub
--------------------------------------------------

frmX.frm (SUBFORM)
--------------------------------------------------
VERSION 4.00
Begin VB.Form frmSub
   Caption         =   "Subform"
   ClientHeight    =   4395
   ClientLeft      =   4740
   ClientTop       =   3810
   ClientWidth     =   6345
   Height          =   4800
   Left            =   4680
   LinkTopic       =   "Form2"
   ScaleHeight     =   4395
   ScaleWidth      =   6345
   Top             =   3465
   Width           =   6465
   Visible         =   0   'False
   Begin VB.PictureBox picX
      Appearance      =   0  'Flat
      BackColor       =   &H00C0C0C0&
      ForeColor       =   &H80000008&
      Height          =   3195
      Left            =   60
      ScaleHeight     =   3165
      ScaleWidth      =   4965
      TabIndex        =   0
      Top             =   840
      Width           =   4995
      Begin VB.ListBox lstList
         Height          =   2790
         Left            =   120
         TabIndex        =   1
         Top             =   180
         Width           =   4695
      End
   End
End
Attribute VB_Name = "frmSub"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
--------------------------------------------

module1.bas
--------------------------------------------
Attribute VB_Name = "Module1"
Option Explicit
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,
ByVal hWndNewParent As Long) As Long
--------------------------------------------



Mon, 22 Jun 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. load another form form one form

2. Trouble loading-unloading forms in VB4.

3. VB4: MDI form hanging on load problem...Help...

4. VB4-Pro Form-Loading Buttons

5. Windows Forms - Loading & Unloading Forms

6. VB Form Designer cannot load a form

7. Changing form-properties while running before loading the form

8. how to load a form from another form

9. Loading MDI Child forms to a parent form from a DLL

10. Loading a form within a form

11. How to load form using form name from field

12. ???????? GURUS - Showing or Loading Forms by use of String variable containing Form Name

 

 
Powered by phpBB® Forum Software