home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1999 April / CD_Shareware_Magazine_31.iso / Free / Prg / Shell32.exe / Shell32.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-11-24  |  7.8 KB  |  235 lines

  1. VERSION 5.00
  2. Begin VB.Form frmShell32
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Shell32 Demo"
  5.    ClientHeight    =   3210
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1515
  8.    ClientWidth     =   6465
  9.    Icon            =   "Shell32.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   3210
  15.    ScaleWidth      =   6465
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.TextBox Text2
  18.       Height          =   285
  19.       Left            =   180
  20.       TabIndex        =   10
  21.       Text            =   "Text2"
  22.       Top             =   1890
  23.       Width           =   1185
  24.    End
  25.    Begin VB.CommandButton Command1
  26.       Cancel          =   -1  'True
  27.       Caption         =   "E&xit"
  28.       Height          =   375
  29.       Index           =   1
  30.       Left            =   1530
  31.       TabIndex        =   8
  32.       Top             =   2610
  33.       Width           =   1185
  34.    End
  35.    Begin VB.CommandButton Command1
  36.       Caption         =   "&Shell"
  37.       Default         =   -1  'True
  38.       Height          =   375
  39.       Index           =   0
  40.       Left            =   180
  41.       TabIndex        =   7
  42.       Top             =   2610
  43.       Width           =   1185
  44.    End
  45.    Begin VB.Frame Frame1
  46.       Caption         =   " Routine "
  47.       Height          =   2805
  48.       Left            =   3690
  49.       TabIndex        =   4
  50.       Top             =   180
  51.       Width           =   2445
  52.       Begin VB.OptionButton Option1
  53.          Caption         =   "h&WndShell"
  54.          Height          =   285
  55.          Index           =   3
  56.          Left            =   180
  57.          TabIndex        =   12
  58.          Top             =   1440
  59.          Width           =   1995
  60.       End
  61.       Begin VB.OptionButton Option1
  62.          Caption         =   "ShellAnd&Close"
  63.          Height          =   285
  64.          Index           =   2
  65.          Left            =   180
  66.          TabIndex        =   11
  67.          Top             =   1080
  68.          Width           =   1995
  69.       End
  70.       Begin VB.OptionButton Option1
  71.          Caption         =   "ShellAnd&Loop"
  72.          Height          =   285
  73.          Index           =   1
  74.          Left            =   180
  75.          TabIndex        =   6
  76.          Top             =   720
  77.          Width           =   1995
  78.       End
  79.       Begin VB.OptionButton Option1
  80.          Caption         =   "ShellAnd&Wait"
  81.          Height          =   285
  82.          Index           =   0
  83.          Left            =   180
  84.          TabIndex        =   5
  85.          Top             =   360
  86.          Width           =   1995
  87.       End
  88.    End
  89.    Begin VB.TextBox Text1
  90.       Height          =   285
  91.       Left            =   180
  92.       TabIndex        =   1
  93.       Text            =   "Text1"
  94.       Top             =   450
  95.       Width           =   3255
  96.    End
  97.    Begin VB.ComboBox Combo1
  98.       Height          =   315
  99.       Left            =   180
  100.       TabIndex        =   3
  101.       Text            =   "Combo1"
  102.       Top             =   1170
  103.       Width           =   3255
  104.    End
  105.    Begin VB.Label Label3
  106.       AutoSize        =   -1  'True
  107.       Caption         =   "&Timeout (secs):"
  108.       Height          =   195
  109.       Left            =   180
  110.       TabIndex        =   9
  111.       Top             =   1620
  112.       Width           =   1080
  113.    End
  114.    Begin VB.Label Label2
  115.       AutoSize        =   -1  'True
  116.       Caption         =   "Start &Mode:"
  117.       Height          =   195
  118.       Left            =   180
  119.       TabIndex        =   2
  120.       Top             =   900
  121.       Width           =   825
  122.    End
  123.    Begin VB.Label Label1
  124.       AutoSize        =   -1  'True
  125.       Caption         =   "&Application:"
  126.       Height          =   195
  127.       Left            =   180
  128.       TabIndex        =   0
  129.       Top             =   180
  130.       Width           =   825
  131.    End
  132. Attribute VB_Name = "frmShell32"
  133. Attribute VB_GlobalNameSpace = False
  134. Attribute VB_Creatable = False
  135. Attribute VB_PredeclaredId = True
  136. Attribute VB_Exposed = False
  137. ' ****************************************************************
  138. ' Shell32.Frm, Copyright 
  139. 1996-97 Karl E. Peterson
  140. ' ****************************************************************
  141. ' You are free to use this code within your own applications, but you
  142. ' are expressly forbidden from selling or otherwise distributing this
  143. ' source code without prior written consent.
  144. ' ****************************************************************
  145. ' Demonstrates three methods to "Shell and Wait" under Win32.
  146. ' One deals with the infamous "Finished" behavior of Win95.
  147. ' Requires: Shell32.Bas
  148. ' ****************************************************************
  149. Option Explicit
  150. Private Const bSpawn = 0
  151. Private Const bExit = 1
  152. Private Const oShellAndWait = 0
  153. Private Const oShellAndLoop = 1
  154. Private Const oShellAndClose = 2
  155. Private Const ohWndShell = 3
  156. Private Sub Command1_Click(Index As Integer)
  157.    Dim TimeOut As Long
  158.    Dim msg As String
  159.    Dim nRet As Long
  160.    msg = "Job has just finished."
  161.    Select Case Index
  162.       Case bSpawn
  163.          Select Case CLng(Frame1.Tag)
  164.             Case oShellAndWait
  165.                TimeOut = Val(Text2.Text) * 1000
  166.                If TimeOut = 0 Then TimeOut = INFINITE
  167.                ShellAndWait Text1.Text, Combo1.ItemData(Combo1.ListIndex), TimeOut
  168.             Case oShellAndLoop
  169.                ShellAndLoop Text1.Text, Combo1.ItemData(Combo1.ListIndex)
  170.             Case oShellAndClose
  171.                ShellAndClose Text1.Text, Combo1.ItemData(Combo1.ListIndex)
  172.             Case ohWndShell
  173.                nRet = hWndShell(Text1.Text, Combo1.ItemData(Combo1.ListIndex))
  174.                msg = Text1.Text & " has been started." & vbCrLf & _
  175.                      "Main window handle: " & Hex(nRet)
  176.          End Select
  177.          MsgBox msg
  178.       Case bExit
  179.          Unload Me
  180.    End Select
  181. End Sub
  182. Private Sub Form_Load()
  183.    Text1.Text = "Notepad"
  184.    Text1.SelLength = Len(Text1.Text)
  185.    Text2.Text = "10"
  186.    Option1(0).Value = True
  187.    UseVbStartMode Combo1
  188.    Set Me.Icon = Nothing
  189. End Sub
  190. Private Sub Option1_Click(Index As Integer)
  191.    Select Case Index
  192.       Case oShellAndWait
  193.          Text2.Visible = True
  194.          Label3.Visible = True
  195.       Case oShellAndLoop, oShellAndClose, ohWndShell
  196.          Text2.Visible = False
  197.          Label3.Visible = False
  198.    End Select
  199.    Frame1.Tag = Index
  200. End Sub
  201. Private Sub UseApiStartMode(Combo As ComboBox)
  202.    Dim i As Integer
  203.    Combo.Clear
  204.    Combo.AddItem "(0) SW_HIDE"
  205.    Combo.AddItem "(1) SW_SHOWNORMAL"
  206.    Combo.AddItem "(2) SW_SHOWMINIMIZED"
  207.    Combo.AddItem "(3) SW_SHOWMAXIMIZED"
  208.    Combo.AddItem "(4) SW_SHOWNOACTIVATE"
  209.    Combo.AddItem "(5) SW_SHOW"
  210.    Combo.AddItem "(6) SW_MINIMIZE"
  211.    Combo.AddItem "(7) SW_SHOWMINNOACTIVE"
  212.    Combo.AddItem "(8) SW_SHOWNA"
  213.    Combo.AddItem "(9) SW_RESTORE"
  214.    For i = SW_HIDE To SW_RESTORE
  215.       Combo.ItemData(i) = i
  216.    Next i
  217.    Combo.ListIndex = 1
  218. End Sub
  219. Private Sub UseVbStartMode(Combo As ComboBox)
  220.    Combo.Clear
  221.    Combo.AddItem Format(vbHide, "(0)") & " vbHide"
  222.    Combo.ItemData(Combo.NewIndex) = vbHide
  223.    Combo.AddItem Format(vbNormalFocus, "(0)") & " vbNormalFocus"
  224.    Combo.ItemData(Combo.NewIndex) = vbNormalFocus
  225.    Combo.AddItem Format(vbMinimizedFocus, "(0)") & " vbMinimizedFocus"
  226.    Combo.ItemData(Combo.NewIndex) = vbMinimizedFocus
  227.    Combo.AddItem Format(vbMaximizedFocus, "(0)") & " vbMaximizedFocus"
  228.    Combo.ItemData(Combo.NewIndex) = vbMaximizedFocus
  229.    Combo.AddItem Format(vbNormalNoFocus, "(0)") & " vbNormalNoFocus"
  230.    Combo.ItemData(Combo.NewIndex) = vbNormalNoFocus
  231.    Combo.AddItem Format(vbMinimizedNoFocus, "(0)") & " vbMinimizedNoFocus"
  232.    Combo.ItemData(Combo.NewIndex) = vbMinimizedNoFocus
  233.    Combo.ListIndex = 1
  234. End Sub
  235.