|
-
Jun 21st, 2000, 11:52 AM
#1
Thread Starter
Addicted Member
how would i got about doing this?
i searched the forum for some simple code that would put all the window titles in a list box but i couldn't find one, could someone do it for me?
thanks
-
Jun 21st, 2000, 08:00 PM
#2
_______
check this out...passed to me by someone else
'I haven't looked at this yet..it was passed on
'via another Q & A so it may help and it may not.See full sample and code at (and a follow-up):
http://support.microsoft.com/support.../Q187/9/13.ASP
http://support.microsoft.com/support.../Q192/9/86.ASP
There is also a full sample and code of a viewer at:
http://www.codearchive.com/vbasic/WinHack2.zip
If you want just a list of the applications (like WinNT -> Task Manager -> Applications), add three CommandButton and one ListBox to your form, then use this code:
---
Private Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal flgs As Long) As Long
Private Declare Function GetWindow Lib "User32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowWord Lib "User32" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As Long) As Long
Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpSting As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowTextLength Lib "User32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal insaft As Long, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, ByVal flgs As Long) As Long
Const WS_MINIMIZE = &H20000000
Const HWND_TOP = 0
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_SHOWWINDOW = &H40
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Const GWL_STYLE = (-16)
Const SW_RESTORE = 9
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Const WS_CLIPSIBLINGS = &H4000000
Const WS_THICKFRAME = &H40000
Const WS_GROUP = &H20000
Const WS_TABSTOP = &H10000
Dim IsTask As Long
Sub Command3_Click()
Unload Me
End Sub
Sub Command1_Click()
FindAllApps
End Sub
Sub Command2_Click()
Dim hWnd As Long
Dim x As Long
Dim lngWW As Long
If List1.ListIndex < 0 Then Beep: Exit Sub
hWnd = List1.ItemData(List1.ListIndex)
lngWW = GetWindowLong(hWnd, GWL_STYLE)
If lngWW And WS_MINIMIZE Then
x = ShowWindow(hWnd, SW_RESTORE)
End If
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
List1.Clear
hwCurr = GetWindow(Me.hWnd, GW_HWNDFIRST)
Do While hwCurr
If hwCurr <> Me.hWnd And TaskWindow(hwCurr) Then
intLen = GetWindowTextLength(hwCurr) + 1
strTitle = Space$(intLen)
intLen = GetWindowText(hwCurr, strTitle, intLen)
If intLen > 0 Then
List1.AddItem strTitle
List1.ItemData(List1.NewIndex) = hwCurr
End If
End If
hwCurr = GetWindow(hwCurr, GW_HWNDNEXT)
Loop
End Sub
Sub Form_Load()
Command1.Caption = "Refresh"
Command2.Caption = "Switch"
Command3.Caption = "Exit"
IsTask = WS_VISIBLE Or WS_BORDER
FindAllApps
End Sub
Sub Form_Paint()
FindAllApps
End Sub
Sub List1_DblClick()
Command2.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
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|