TaskManager
Here's a simple application to function like the Windows Task Manager...
AI
Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Código fuente
Sub cmdExit_Click ()
Unload Me ' Get me out of here!
Set activate = Nothing ' Kill Form reference for good measure
End Sub
Sub cmdRefresh_Click ()
FindAllApps ' Update list of tasks
End Sub
Sub cmdSwitch_Click ()
Dim hWnd As Long ' handle to window
Dim x As Long ' work area
Dim lngWW As Long ' Window Style bits
If lstApp.ListIndex < 0 Then Beep: Exit Sub
' Get window handle from listbox array
hWnd = lstApp.ItemData(lstApp.ListIndex)
' Get style bits for window
lngWW = GetWindowLong(hWnd, GWL_STYLE)
' If minimized do a restore
If lngWW And WS_MINIMIZE Then
x = ShowWindow(hWnd, SW_RESTORE)
End If
' Move window to top of z-order/activate; no move/resize
x = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
End Sub
Sub FindAllApps ()
Dim hwCurr As Long
Dim intLen As Long
Dim strTitle As String
' process all top-level windows in master window list
lstApp.Clear
hwCurr = GetWindow(Me.hWnd, GW_HWNDFIRST) ' get first window
Do While hwCurr ' repeat for all windows
If hwCurr <> Me.hWnd And TaskWindow(hwCurr) Then
intLen = GetWindowTextLength(hwCurr) + 1 ' Get length
strTitle = Space$(intLen) ' Get caption
intLen = GetWindowText(hwCurr, strTitle, intLen)
If intLen > 0 Then ' If we have anything, add it
lstApp.AddItem strTitle
' and let's save the window handle in the itemdata array
lstApp.ItemData(lstApp.NewIndex) = hwCurr
End If
End If
hwCurr = GetWindow(hwCurr, GW_HWNDNEXT)
Loop
End Sub
Sub Form_Load ()
IsTask = WS_VISIBLE Or WS_BORDER ' Define bits for normal task
FindAllApps ' Update list
End Sub
Sub Form_Paint ()
FindAllApps ' Update List
End Sub
Sub Label1_Click ()
FindAllApps ' Update list
End Sub
Sub lstApp_DblClick ()
cmdSwitch.Value = True
End Sub
Function TaskWindow (hwCurr As Long) As Long
Dim lngStyle As Long
lngStyle = GetWindowLong(hwCurr, GWL_STYLE)
If (lngStyle And IsTask) = IsTask Then TaskWindow = True
End Function
Comentarios originales (3)
Recuperado de Wayback Machine