Results 1 to 11 of 11

Thread: Change all windows captions???

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    none
    Posts
    19
    I thought I had this down, but I still need help with it,

    I want to change every windows caption (in the title bar) to a string, EXCEPT the windows explorer caption.

    I have been searching for a while now, I stiil can't get it.

  2. #2
    Guest
    Change text for every application's caption.
    Code:
    Private Declare Function SetWindowText Lib "user32" _
    Alias "SetWindowTextA" (ByVal hwnd As Long, _
    ByVal lpString As String) As Long
    
    Public Sub WindowCaptionChangeAll(NewText As String)
    For nI = 1 To 10000
    Call SetWindowText(nI, NewText)
    Next
    End Sub
    [Edited by Matthew Gates on 07-15-2000 at 10:15 PM]

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    none
    Posts
    19
    thanks, Thats alsmost it, but I do not want to change the windows explorer caption if it is open, that is my problam.

  4. #4
    Guest
    I think I know what to do.
    After changing all the Windows captions...go back and change Windows Explorer's caption back to the original name.

    Code:
    Call SetWindowText(explorerhwnd, NewText)

  5. #5
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    to do it another way, you can get all existing windows and chg it with the setwindowtext command, use getwindowtext to see if the window is explorer
    YC Sim
    Teenage Programmer
    UIN 37903254



  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    none
    Posts
    19
    Once I change windows explorer's Caption, a message box show up telling me that the directory has changed or moved restart your computer.

    I don't want it to change explorers caption at all when this is done, The same message comes up on my other computer also.

  7. #7
    Guest
    When I change all captions to every window..I don't get a problem with having to restart or anything.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    none
    Posts
    19
    Really?? Hmm.. Must be something installed on my computer, and if this problam is on all three of my computers then That means it would be on someone elses computer. I don't want this problam becouse you need to restart your computer every time your done using the program to get into windows explorer

  9. #9
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    This works on my computer:

    Code:
    Option Explicit
    Option Compare Text
    
    Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
    Private Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
    Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    
    Private Arry As String
    
    Public Windows() As String
    Public WindowHandles(0 To 100) As Long
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
      Dim slength As Long, buffer As String
      Dim retval As Long
      Static winnum As Integer
    
      winnum = winnum + 1
      slength = GetWindowTextLength(hwnd) + 1
      If slength > 1 And IsWindowVisible(hwnd) > 0 Then
        buffer = Space(slength)
        retval = GetWindowText(hwnd, buffer, slength)
        If InStr(1, Arry, Left$(buffer, slength - 1), vbTextCompare) = 0 Then
            Arry = Arry & Chr$(216) & Left$(buffer, slength - 1)
        End If
      End If
    
      EnumWindowsProc = 1  ' return value of 1 means continue enumeration
    End Function
    
    Public Sub EWindows()
    Dim i As Integer
    EnumWindows AddressOf EnumWindowsProc, CLng(0)
    Windows = Split(Arry, Chr$(216), , vbTextCompare)
    For i = 0 To UBound(Windows)
        WindowHandles(i) = FindWindow(CLng(0), Trim$(Windows(i)))
    Next:
    End Sub
    
    Sub WhatUWannaDo(NewName() As String)
    'NewName is a zero-based array filled with the new window names
    Dim TopOne As Integer, i As Integer
    'Make sure 2 use the smaller array to prevent an error
    TopOne = IIf(UBound(NewName) >= UBound(Windows), UBound(Windows), UBound(NewName))
    For i = 0 To TopOne
        If Not (Windows(i) Like "*Exploring*-*") Then
            SetWindowText WindowHandles(i), NewName(i)
        End If
    Next:
    End Sub
    Then, when you want to change the window names, create an array, fill it with data, call EWindows, and then pass it to WhatUWannaDo.

    eg:
    Code:
    Private Sub Command1_Click()
    Dim NewWindowNames(10) as String
    NewWindowNames(0) = "Test: 0"
    NewWindowNames(1) = "Test: 1"
    NewWindowNames(2) = "Test: 2"
    NewWindowNames(3) = "Test: 3"
    NewWindowNames(4) = "Test: 4"
    NewWindowNames(5) = "Test: 5"
    NewWindowNames(6) = "Test: 6"
    NewWindowNames(7) = "Test: 7"
    NewWindowNames(8) = "Test: 8"
    NewWindowNames(9) = "Test: 9"
    NewWindowNames(10) = "Test: 10"
    Call EWindows
    Call WhatUWannaDo(NewWindowNames)
    End Sub
    Hope this helps you.

    Ta-ra for now,

    Me
    Courgettes.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    none
    Posts
    19

    Unhappy

    There is a problam with my computer V(ery) Basic, in>>

    Public Sub EWindows()
    Dim i As Integer
    EnumWindows AddressOf EnumWindowsProc, CLng(0)
    Windows = Split(Arry, Chr$(216), , vbTextCompare)
    For i = 0 To UBound(Windows)
    WindowHandles(i) = FindWindow(CLng(0), Trim$(Windows(i)))
    Next:
    End Sub

    <<<<

    The Split(Arry, Chr$(216), , vbTextCompare)is not defined, I'm using vb5 and don't know why it is saying this.

  11. #11
    Guest
    The reason its saying it is because Split was an added feature in VB 6.0.
    VB 5.0 and lower do not support it.
    But here is the link to replacement:

    http://www.planet-source-code.com/vb...txtCodeId=3615

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