home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / jdsaver / control.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-13  |  4.1 KB  |  117 lines

  1. VERSION 4.00
  2. Begin VB.Form ControlForm 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   0  'None
  6.    Caption         =   "Jim & Don's Screen Saver Demo"
  7.    ClientHeight    =   1812
  8.    ClientLeft      =   1464
  9.    ClientTop       =   4704
  10.    ClientWidth     =   4152
  11.    ControlBox      =   0   'False
  12.    BeginProperty Font 
  13.       name            =   "MS Sans Serif"
  14.       charset         =   0
  15.       weight          =   700
  16.       size            =   9.6
  17.       underline       =   0   'False
  18.       italic          =   0   'False
  19.       strikethrough   =   0   'False
  20.    EndProperty
  21.    ForeColor       =   &H80000008&
  22.    Height          =   2136
  23.    Icon            =   "control.frx":0000
  24.    Left            =   1416
  25.    LinkTopic       =   "Form1"
  26.    MaxButton       =   0   'False
  27.    MinButton       =   0   'False
  28.    ScaleHeight     =   1812
  29.    ScaleWidth      =   4152
  30.    ShowInTaskbar   =   0   'False
  31.    Top             =   4428
  32.    Visible         =   0   'False
  33.    Width           =   4248
  34.    Begin VB.Timer Timer1 
  35.       Interval        =   400
  36.       Left            =   1896
  37.       Top             =   1320
  38.    End
  39.    Begin VB.PictureBox Picture1 
  40.       Appearance      =   0  'Flat
  41.       BackColor       =   &H00FF0000&
  42.       BorderStyle     =   0  'None
  43.       ForeColor       =   &H80000008&
  44.       Height          =   1080
  45.       Left            =   120
  46.       ScaleHeight     =   1080
  47.       ScaleWidth      =   1932
  48.       TabIndex        =   0
  49.       Top             =   0
  50.       Width           =   1932
  51.    End
  52.    Begin MsghookLib.Msghook Msghook1 
  53.       Left            =   516
  54.       Top             =   1332
  55.       _Version        =   65536
  56.       _ExtentX        =   677
  57.       _ExtentY        =   677
  58.       _StockProps     =   0
  59.    End
  60. Attribute VB_Name = "ControlForm"
  61. Attribute VB_Creatable = False
  62. Attribute VB_Exposed = False
  63. 'For information about this program see the declarations
  64. 'section of the JDSaver.BAS module.
  65. 'This form is used to communicate with the Display Properties Dialog,
  66. 'in order to place a demo in the preview window, and is called
  67. 'from Sub Main when the program is started with
  68. 'the /p command parameter
  69. Option Explicit
  70. Private Sub Form_Load()
  71.     'Set up MsgHoo32.OCX to handle a WM_CLOSE message
  72.     'sent to the picture box.
  73.     Msghook1.HwndHook = Picture1.hWnd
  74.     Msghook1.Message(WM_CLOSE) = True
  75.     'Query the size of the client area of the Display
  76.     'Properties output window
  77.     tempLong = GetClientRect(CPWindow, CPRect)
  78.     'Resize the picture box to match
  79.     Picture1.Move 0, 0, (CPRect.Right - CPRect.Left) * xPixel, (CPRect.Bottom - CPRect.Top) * yPixel
  80.     'Copy a clone of the desktop into the picture box, to
  81.     'serve as a background for the preview
  82.     CopyScreen Picture1
  83.     'Move the picture box into place on the Display
  84.     'Properties form
  85.     tempLong = SetParent(Picture1.hWnd, CPWindow)
  86.     'Set a flag so the timer will keep running until the
  87.     'picture is unloaded
  88.     PictureLoaded = True
  89. End Sub
  90. Private Sub Msghook1_Message(ByVal msg As Long, ByVal wp As Long, ByVal lp As Long, result As Long)
  91.     'Respond to the WM_CLOSE message sent to the picture box
  92.     'when the Display Properties dialog has gone on to something
  93.     'else or has gone away.
  94.     Select Case msg
  95.         Case WM_CLOSE
  96.             'Putting the picture box back where it started may not
  97.             'be absolutely necessary, but it is good coding practice
  98.             tempLong = SetParent(Picture1.hWnd, hWnd)
  99.             
  100.             'Unset the flag, so the timer will close the instance
  101.             'rather than writing to the picture box
  102.             PictureLoaded = False
  103.     End Select
  104. End Sub
  105. Private Sub Timer1_Timer()
  106.     If IsWindow(CPWindow) = 0 Or Not PictureLoaded Then
  107.         
  108.         'If we got the WM_CLOSE message, or if the Display
  109.         'Properties dialog somehow went away without our
  110.         'getting the message (GPF or something).
  111.         Unload Me
  112.     Else
  113.         'Continue drawing the Circles
  114.         Draw Picture1
  115.     End If
  116. End Sub
  117.