home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbtbox / parent.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  1.7 KB  |  58 lines

  1. VERSION 2.00
  2. Begin Form Parent 
  3.    Caption         =   "Parent"
  4.    ClientHeight    =   1965
  5.    ClientLeft      =   1305
  6.    ClientTop       =   1740
  7.    ClientWidth     =   4095
  8.    Height          =   2655
  9.    Left            =   1245
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   1965
  12.    ScaleWidth      =   4095
  13.    Top             =   1110
  14.    Width           =   4215
  15.    WindowState     =   2  'Maximized
  16.    Begin Menu Showtbox 
  17.       Caption         =   "&Show Toolbox"
  18.    End
  19.    Begin Menu Exit 
  20.       Caption         =   "&Exit"
  21.    End
  22. Option Explicit
  23. 'This is a simple demo of how to do a
  24. 'floating toolbox in VB as requested
  25. 'by a few people on the VISBAS-L
  26. 'mailing list.
  27. 'Hope this is of use to someone
  28. 'Matthew Dexter (ch01md@surrey.ac.uk)
  29. 'Declare SetParent API function
  30. Declare Function SetParent% Lib "User" (ByVal hWndChild%, ByVal hWndNewParent%)
  31. Dim doshow As Integer 'Boolean to decide if toolbox is hidden or shown
  32. Sub Exit_Click ()
  33. 'quit program
  34. Unload Me
  35. End Sub
  36. Sub Form_Load ()
  37. doshow = False  'initially toolbox is not shown
  38. Load tbox 'toolbox is loaded but not yet shown
  39. End Sub
  40. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  41. Unload tbox 'essential or else VB will crash!!!
  42. End Sub
  43. Sub ShowTbox_Click ()
  44. Dim ret As Integer
  45. If doshow = False Then 'toolbox not visible
  46.     ret = SetParent(tbox.hWnd, parent.hWnd) 'this makes the toolbox float
  47.     tbox.Left = 0 'sets position to top left corner of parent
  48.     tbox.Top = 0
  49.     tbox.Show 'makes toolbox visible
  50. 'try tbox.show 1 i.e. modal to see what happens
  51.     doshow = True
  52.     Showtbox.Caption = "&Hide Toolbox"
  53.     tbox.Hide
  54.     doshow = False
  55.     Showtbox.Caption = "&Show Toolbox"
  56. End If
  57. End Sub
  58.