home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / set_par / setparnt.frm < prev    next >
Text File  |  1994-04-23  |  2KB  |  71 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2805
  5.    ClientLeft      =   405
  6.    ClientTop       =   885
  7.    ClientWidth     =   4035
  8.    Height          =   3270
  9.    Left            =   315
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2805
  12.    ScaleWidth      =   4035
  13.    Top             =   510
  14.    Width           =   4215
  15.    Begin Frame Frame1 
  16.       Caption         =   "Frame1"
  17.       Height          =   1935
  18.       Left            =   60
  19.       TabIndex        =   0
  20.       Top             =   120
  21.       Width           =   2415
  22.       Begin CommandButton BtnOne 
  23.          Caption         =   "Click Me!"
  24.          Height          =   375
  25.          Left            =   360
  26.          TabIndex        =   1
  27.          Top             =   1500
  28.          Width           =   1635
  29.       End
  30.       Begin Shape Shape1 
  31.          BackColor       =   &H0000FFFF&
  32.          BackStyle       =   1  'Opaque
  33.          Height          =   975
  34.          Left            =   360
  35.          Shape           =   1  'Square
  36.          Top             =   420
  37.          Width           =   975
  38.       End
  39.    End
  40. End
  41. Option Explicit
  42.  
  43. Sub BtnOne_Click ()
  44. Dim x As Integer
  45. '  Where is the frame when button pressed?
  46. If FrameLoc = InForm2 Then
  47.  ' Move it to Form1
  48.    x = SetParent(Ctrl_hWnd, Form1.hWnd)
  49.    FrameLoc = InForm1
  50.  ' Adjust its position, just for effect.
  51.    Frame1.Top = 50: Frame1.Left = 100
  52.  ' Show how to act on diff. form from this one Sub
  53.    Form2.Label1 = "Frame's in Form1"
  54. Else
  55.  ' Move it to Form2
  56.    x = SetParent(Ctrl_hWnd, Form2.hWnd)
  57.    FrameLoc = InForm2
  58.  ' Restore its original position
  59.    Frame1.Top = 750: Frame1.Left = 1500
  60.  ' Modify a control that _stays_ on Form2 -- just for show.
  61.    Form2.Label1 = "Frame's down here now!"
  62. End If
  63. End Sub
  64.  
  65. Sub Form_Load ()
  66.    Form2.Show
  67.    Ctrl_hWnd = Frame1.hWnd
  68.    FrameLoc = InForm1
  69. End Sub
  70.  
  71.