home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / saveme / saveme2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  4.8 KB  |  123 lines

  1. VERSION 2.00
  2. Begin Form SaveMe 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "VB Save Me"
  5.    ClientHeight    =   360
  6.    ClientLeft      =   1110
  7.    ClientTop       =   1515
  8.    ClientWidth     =   5760
  9.    Height          =   765
  10.    Icon            =   SAVEME2.FRX:0000
  11.    Left            =   1050
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   360
  17.    ScaleWidth      =   5760
  18.    Top             =   1170
  19.    Width           =   5880
  20.    Begin CommandButton btnSave 
  21.       Caption         =   "Sav&e Project As..."
  22.       Height          =   375
  23.       Index           =   3
  24.       Left            =   3960
  25.       TabIndex        =   3
  26.       Top             =   0
  27.       Width           =   1815
  28.    End
  29.    Begin CommandButton btnSave 
  30.       Caption         =   "Sa&ve Project"
  31.       Height          =   375
  32.       Index           =   2
  33.       Left            =   2580
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   1395
  37.    End
  38.    Begin CommandButton btnSave 
  39.       Caption         =   "Save File &As..."
  40.       Height          =   375
  41.       Index           =   1
  42.       Left            =   1080
  43.       TabIndex        =   2
  44.       Top             =   0
  45.       Width           =   1515
  46.    End
  47.    Begin CommandButton btnSave 
  48.       Caption         =   "&Save File"
  49.       Height          =   375
  50.       Index           =   0
  51.       Left            =   0
  52.       TabIndex        =   0
  53.       Top             =   0
  54.       Width           =   1095
  55.    End
  56. '**********************************************************'
  57. '*                                                        *'
  58. '*                       SAVE ME!                         *'
  59. '*                                                        *'
  60. '*   This is just a little program that I threw together  *'
  61. '*   to help remind me to save my Forms, Files, and       *'
  62. '*   Projects while I work in VB.  I have a tendency to   *'
  63. '*   make changes and run the program without saving my   *'
  64. '*   latest changes, and, if it bombs, I kick myself      *'
  65. '*   repeatedly.  SAVE ME! uses SendKeys to save the      *'
  66. '*   currrent file or project in VB when in design mode.  *'
  67. '*   Obviously it is not as reliable as using the VB      *'
  68. '*   menus directly, and I use it mainly as a visual      *'
  69. '*   reminder.  You can make the form even less obtrusive *'
  70. '*   by placing it on your screen and then turning off    *'
  71. '*   Control Box and making the Form caption "".  You     *'
  72. '*   won't be able to drag it around but, by putting a    *'
  73. '*   Timer on the form that looks to see if VB is still   *'
  74. '*   active, you could have it shut down automatically    *'
  75. '*   when VB is closed.                                   *'
  76. '*                                                        *'
  77. '*   Let me know if you find it useful, or not.           *'
  78. '*                                                        *'
  79. '*   Gregg Irwin CIS:ID 72450,676                         *'
  80. '*                                                        *'
  81. '**********************************************************'
  82. DefInt A-Z
  83. Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
  84. Declare Function GetActiveWindow Lib "User" () As Integer
  85. Declare Function SetActiveWindow Lib "User" (ByVal hWnd As Integer) As Integer
  86. Const FALSE = 0
  87. Const TRUE = Not FALSE
  88. 'Const NULL = 0&       '--If you want to pass NULL to FindWindow
  89. Sub btnSave_Click (Index As Integer)
  90.      
  91.      '-- Class name for VB = "wndclass_desked_gsk"
  92.      '-- Caption for VB    = "Microsoft Visual Basic [design]"
  93.      '** NOTE: Looks for VB in DESIGN mode only **'
  94.     VBhWnd = FindWindow("wndclass_desked_gsk", "Microsoft Visual Basic [design]")
  95.      
  96.      '-- Make sure VB is running before we do anything
  97.     If Len(VBhWnd) Then
  98.          '-- if VB isn't active then activate it.
  99.         ActivehWnd = GetActiveWindow()
  100.         If VBhWnd <> ActivehWnd Then
  101.              '-- Save the handle of the currently active window
  102.             PrevhWnd = SetActiveWindow(VBhWnd)
  103.         End If
  104.          
  105.          '-- Command it to do our bidding
  106.         Select Case Index
  107.             Case 0 '-- Save File
  108.                 SendKeys "%FS", True
  109.             Case 1 '-- Save File As...
  110.                 SendKeys "%FA", True
  111.             Case 2 '-- Save Project
  112.                 SendKeys "%FV", True
  113.             Case 3 '-- Save Project As...
  114.                 SendKeys "%FE", True
  115.         End Select
  116.     Else
  117.         MsgBox "Visual Basic is not running", MB_OK, "Save Me...Didn't"
  118.     End If 'Len(VBhWnd)
  119.      '-- Un-REM this to re-activate the window that was
  120.      '   active when we started.
  121.     'dummy = SetActiveWindow(PrevhWnd)
  122. End Sub
  123.