home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch13 / singlapp / singlapp.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-04-26  |  1.6 KB  |  50 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2130
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4620
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2130
  10.    ScaleWidth      =   4620
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Label Label1 
  13.       Caption         =   "Only one instance of this program can run."
  14.       Height          =   375
  15.       Left            =   360
  16.       TabIndex        =   0
  17.       Top             =   720
  18.       Width           =   3615
  19.    End
  20. Attribute VB_Name = "Form1"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. '  ******************************
  26. '  ******************************
  27. '  ** MASTERING VB6            **
  28. '  ** by Evangelos Petroutos   **
  29. '  ** SYBEX, 1998              **
  30. '  ******************************
  31. '  ******************************
  32. Option Explicit
  33. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  34.     (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  35. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
  36.     ByVal nCmdShow As Long) As Long
  37. Const SW_SHOWNORMAL = 1
  38. Private Sub Form_Load()
  39.     Dim retValue As Long
  40.     Dim otherWnd As Long
  41.     Dim oldCaption As String
  42.     If App.PrevInstance Then
  43.         MsgBox "Cannot start more than one copy."
  44.         Unload Me
  45.         
  46.         otherWnd = FindWindow(0&, oldCaption)
  47.         retValue = ShowWindow(App.hInstance, SW_SHOWNORMAL)
  48.     End If
  49. End Sub
  50.