-
This is not an ad for a program.
I'm new here, so if this is a question you get a lot, I appologize. I looked through the last few days worth of posts but didn't find anything.
How, in VB4, would I put the task bar on a menu? I saw some post just down the list a bit related, except that Addressof isn't a keyword in 4. I then tried Me.href, but that crashes VB as soon as it hits that line. I just need to yank the name via GetWindowsText, add it to the menu, and then let it activate if the user hits it. I figure that I can just stick the routine inside of a timer and query the system every 2 or 3 seconds, unless someone can recomend a better way.
-
Well, if you look at this thread, it is a good way to add the taskbar items, but unfortunately, it is for VB5+. But here is another way:
Code:
'Code from HeSaidJoe
Private Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long) As Long
'
Private Declare Function GetWindowTextLength Lib _
"user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
lpString As String, ByVal cch As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Public Sub LoadTaskList()
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
Form1.List1.Clear
CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST)
While CurrWnd <> 0
Parent = GetParent(CurrWnd)
Length = GetWindowTextLength(CurrWnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(CurrWnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then
If TaskName <> Form1.Caption Then
Form1.List1.AddItem TaskName
End If
End If
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Wend
End Sub
Private Sub Command1_Click()
LoadTaskList
End Sub
-
and how
would i be able to activate the program?
-
I suppose you could.
Since List1 is the list that will be added, we'll start from there:
Code:
Private Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" (ByVal lpClassName As Any, ByVal _
lpWindowName As Any) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As _
Long, ByVal nCmdShow As Long) As Long
Const SW_HIDE = 0
Const SW_MAXIMIZE = 3
Const SW_MINIMIZE = 6
Const SW_RESTORE = 9
Const SW_SHOW = 5
Const SW_SHOWMAXIMIZED = 3
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMINNOACTIVE = 7
Const SW_SHOWNA = 8
Const SW_SHOWNOACTIVATE = 4
Const SW_SHOWNORMAL = 1
Usage
Private Sub Command1_Click()
hApp = FindWindow(vbNullString, List1)
If hApp <> 0 Then
ShowWindow hApp, SW_HIDE
ShowWindow hApp, SW_SHOW
Else
Msgbox "Window not found!", vbCritical, "Error:"
End If
End Sub
-
What do I need to do to recieve notice of new windows or closed windows? I can just used a timer that checks it, but that causes flickering, because I'm using a combo box.
somewhat unrelated, the Combo_Change event's not working for some reason. i suspect it is related to the fact my windows are borderless, but can anyone give me a sugestion? It's not a big deal, but an annoyance.
-
I think you have to SubClass, but VB can't do that outside of it's own thread. you'll have to make a C++ DLL to do it, and then declare it in your module.
I don't know that much C++, so i can't give you the code.
-
Matthew Gates: Why do you have all of those constants declare yet not using them?