home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmShell32
- BorderStyle = 3 'Fixed Dialog
- Caption = "Shell32 Demo"
- ClientHeight = 3210
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 6465
- Icon = "Shell32.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 3210
- ScaleWidth = 6465
- ShowInTaskbar = 0 'False
- Begin VB.TextBox Text2
- Height = 285
- Left = 180
- TabIndex = 10
- Text = "Text2"
- Top = 1890
- Width = 1185
- End
- Begin VB.CommandButton Command1
- Cancel = -1 'True
- Caption = "E&xit"
- Height = 375
- Index = 1
- Left = 1530
- TabIndex = 8
- Top = 2610
- Width = 1185
- End
- Begin VB.CommandButton Command1
- Caption = "&Shell"
- Default = -1 'True
- Height = 375
- Index = 0
- Left = 180
- TabIndex = 7
- Top = 2610
- Width = 1185
- End
- Begin VB.Frame Frame1
- Caption = " Routine "
- Height = 2805
- Left = 3690
- TabIndex = 4
- Top = 180
- Width = 2445
- Begin VB.OptionButton Option1
- Caption = "h&WndShell"
- Height = 285
- Index = 3
- Left = 180
- TabIndex = 12
- Top = 1440
- Width = 1995
- End
- Begin VB.OptionButton Option1
- Caption = "ShellAnd&Close"
- Height = 285
- Index = 2
- Left = 180
- TabIndex = 11
- Top = 1080
- Width = 1995
- End
- Begin VB.OptionButton Option1
- Caption = "ShellAnd&Loop"
- Height = 285
- Index = 1
- Left = 180
- TabIndex = 6
- Top = 720
- Width = 1995
- End
- Begin VB.OptionButton Option1
- Caption = "ShellAnd&Wait"
- Height = 285
- Index = 0
- Left = 180
- TabIndex = 5
- Top = 360
- Width = 1995
- End
- End
- Begin VB.TextBox Text1
- Height = 285
- Left = 180
- TabIndex = 1
- Text = "Text1"
- Top = 450
- Width = 3255
- End
- Begin VB.ComboBox Combo1
- Height = 315
- Left = 180
- TabIndex = 3
- Text = "Combo1"
- Top = 1170
- Width = 3255
- End
- Begin VB.Label Label3
- AutoSize = -1 'True
- Caption = "&Timeout (secs):"
- Height = 195
- Left = 180
- TabIndex = 9
- Top = 1620
- Width = 1080
- End
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "Start &Mode:"
- Height = 195
- Left = 180
- TabIndex = 2
- Top = 900
- Width = 825
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "&Application:"
- Height = 195
- Left = 180
- TabIndex = 0
- Top = 180
- Width = 825
- End
- Attribute VB_Name = "frmShell32"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ****************************************************************
- ' Shell32.Frm, Copyright
- 1996-97 Karl E. Peterson
- ' ****************************************************************
- ' You are free to use this code within your own applications, but you
- ' are expressly forbidden from selling or otherwise distributing this
- ' source code without prior written consent.
- ' ****************************************************************
- ' Demonstrates three methods to "Shell and Wait" under Win32.
- ' One deals with the infamous "Finished" behavior of Win95.
- ' Requires: Shell32.Bas
- ' ****************************************************************
- Option Explicit
- Private Const bSpawn = 0
- Private Const bExit = 1
- Private Const oShellAndWait = 0
- Private Const oShellAndLoop = 1
- Private Const oShellAndClose = 2
- Private Const ohWndShell = 3
- Private Sub Command1_Click(Index As Integer)
- Dim TimeOut As Long
- Dim msg As String
- Dim nRet As Long
- msg = "Job has just finished."
- Select Case Index
- Case bSpawn
- Select Case CLng(Frame1.Tag)
- Case oShellAndWait
- TimeOut = Val(Text2.Text) * 1000
- If TimeOut = 0 Then TimeOut = INFINITE
- ShellAndWait Text1.Text, Combo1.ItemData(Combo1.ListIndex), TimeOut
- Case oShellAndLoop
- ShellAndLoop Text1.Text, Combo1.ItemData(Combo1.ListIndex)
- Case oShellAndClose
- ShellAndClose Text1.Text, Combo1.ItemData(Combo1.ListIndex)
- Case ohWndShell
- nRet = hWndShell(Text1.Text, Combo1.ItemData(Combo1.ListIndex))
- msg = Text1.Text & " has been started." & vbCrLf & _
- "Main window handle: " & Hex(nRet)
- End Select
- MsgBox msg
- Case bExit
- Unload Me
- End Select
- End Sub
- Private Sub Form_Load()
- Text1.Text = "Notepad"
- Text1.SelLength = Len(Text1.Text)
- Text2.Text = "10"
- Option1(0).Value = True
- UseVbStartMode Combo1
- Set Me.Icon = Nothing
- End Sub
- Private Sub Option1_Click(Index As Integer)
- Select Case Index
- Case oShellAndWait
- Text2.Visible = True
- Label3.Visible = True
- Case oShellAndLoop, oShellAndClose, ohWndShell
- Text2.Visible = False
- Label3.Visible = False
- End Select
- Frame1.Tag = Index
- End Sub
- Private Sub UseApiStartMode(Combo As ComboBox)
- Dim i As Integer
- Combo.Clear
- Combo.AddItem "(0) SW_HIDE"
- Combo.AddItem "(1) SW_SHOWNORMAL"
- Combo.AddItem "(2) SW_SHOWMINIMIZED"
- Combo.AddItem "(3) SW_SHOWMAXIMIZED"
- Combo.AddItem "(4) SW_SHOWNOACTIVATE"
- Combo.AddItem "(5) SW_SHOW"
- Combo.AddItem "(6) SW_MINIMIZE"
- Combo.AddItem "(7) SW_SHOWMINNOACTIVE"
- Combo.AddItem "(8) SW_SHOWNA"
- Combo.AddItem "(9) SW_RESTORE"
- For i = SW_HIDE To SW_RESTORE
- Combo.ItemData(i) = i
- Next i
- Combo.ListIndex = 1
- End Sub
- Private Sub UseVbStartMode(Combo As ComboBox)
- Combo.Clear
- Combo.AddItem Format(vbHide, "(0)") & " vbHide"
- Combo.ItemData(Combo.NewIndex) = vbHide
- Combo.AddItem Format(vbNormalFocus, "(0)") & " vbNormalFocus"
- Combo.ItemData(Combo.NewIndex) = vbNormalFocus
- Combo.AddItem Format(vbMinimizedFocus, "(0)") & " vbMinimizedFocus"
- Combo.ItemData(Combo.NewIndex) = vbMinimizedFocus
- Combo.AddItem Format(vbMaximizedFocus, "(0)") & " vbMaximizedFocus"
- Combo.ItemData(Combo.NewIndex) = vbMaximizedFocus
- Combo.AddItem Format(vbNormalNoFocus, "(0)") & " vbNormalNoFocus"
- Combo.ItemData(Combo.NewIndex) = vbNormalNoFocus
- Combo.AddItem Format(vbMinimizedNoFocus, "(0)") & " vbMinimizedNoFocus"
- Combo.ItemData(Combo.NewIndex) = vbMinimizedNoFocus
- Combo.ListIndex = 1
- End Sub
-