Results 1 to 7 of 7

Thread: VB Windows Shell Question

  1. #1

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    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.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  2. #2
    Guest
    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



  3. #3

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186

    and how

    would i be able to activate the program?
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    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.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  6. #6
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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.
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  7. #7
    Guest
    Matthew Gates: Why do you have all of those constants declare yet not using them?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width