Home All Groups Group Topic Archive Search About
Author
28 Mar 2005 5:57 PM
gv
Please help

using vb.net 2003, on XP sp2 machine

the length in the panel of the statusbar seams to be correct, but having
problems
returning text using "SB_GETTEXT"

please help


  Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, _
                 ByVal lpWindowName As String) As Int32

    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"
(ByVal hWnd1 As Int32, _
                 ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As
String) As Int32

    Private Declare Function SendMessageGetChild Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Int32, _
                     ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As String) As Int32



    Private Const WM_USER = &H400&
    Private Const SB_GETTEXTLENGTH = (WM_USER + 3)
    Private Const SB_GETPARTS = (WM_USER + 6)
    Private Const SB_GETTEXT = (WM_USER + 2)

    Private Const WM_SETTEXT = &HC
    Private Const WM_GETTEXT = &HD
    Private Const WM_GETTEXTLENGTH = &HE
    Public Function GetchildText()
        Try

            Dim WindowStatusbar As Int32
            Dim ChildStatusbar As Int32
            Dim getstring As Int32
            Dim StatusbarParts As Int32
            Dim childtxtLen As Int32
            Dim buffer As String

            WindowStatusbar = FindWindow("BioViewAnalysis", vbNullString)

            If WindowStatusbar <> 0 Then
                ChildStatusbar = FindWindowEx(WindowStatusbar, 0&,
"msctls_statusbar32", vbNullString)
                StatusbarParts = SendMessageGetChild(ChildStatusbar,
SB_GETPARTS, 0, 0)

                'Panel 1
                childtxtLen = SendMessageGetChild(ChildStatusbar,
SB_GETTEXTLENGTH, 1, 0)
                childtxtLen = childtxtLen And &HFFFF&
                buffer = New String(Chr(0), childtxtLen)

                SendMessageGetChild(ChildStatusbar, SB_GETTEXT, 1, buffer)

                MessageBox.Show("Length of Statusbar Panel text is: " &
childtxtLen & vbCrLf & _
                                "The text = " & buffer)


            End If

        Catch ex As Exception

        End Try

    End Function

Author
28 Mar 2005 6:11 PM
Roger
Are you sure there is not an easier way to do
that?
There should be a Text property.
Roger

Show quoteHide quote
> the length in the panel of the statusbar seams to be correct, but having
> problems
> returning text using "SB_GETTEXT"
>
> please help
>
>
>   Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
> (ByVal lpClassName As String, _
>                  ByVal lpWindowName As String) As Int32
>
>     Private Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA"
> (ByVal hWnd1 As Int32, _
>                  ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2
As
> String) As Int32
>
>     Private Declare Function SendMessageGetChild Lib "user32" Alias
> "SendMessageA" (ByVal hwnd As Int32, _
>                      ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
> lParam As String) As Int32
>
>
>
>     Private Const WM_USER = &H400&
>     Private Const SB_GETTEXTLENGTH = (WM_USER + 3)
>     Private Const SB_GETPARTS = (WM_USER + 6)
>     Private Const SB_GETTEXT = (WM_USER + 2)
>
>     Private Const WM_SETTEXT = &HC
>     Private Const WM_GETTEXT = &HD
>     Private Const WM_GETTEXTLENGTH = &HE
>     Public Function GetchildText()
>         Try
>
>             Dim WindowStatusbar As Int32
>             Dim ChildStatusbar As Int32
>             Dim getstring As Int32
>             Dim StatusbarParts As Int32
>             Dim childtxtLen As Int32
>             Dim buffer As String
>
>             WindowStatusbar = FindWindow("BioViewAnalysis", vbNullString)
>
>             If WindowStatusbar <> 0 Then
>                 ChildStatusbar = FindWindowEx(WindowStatusbar, 0&,
> "msctls_statusbar32", vbNullString)
>                 StatusbarParts = SendMessageGetChild(ChildStatusbar,
> SB_GETPARTS, 0, 0)
>
>                 'Panel 1
>                 childtxtLen = SendMessageGetChild(ChildStatusbar,
> SB_GETTEXTLENGTH, 1, 0)
>                 childtxtLen = childtxtLen And &HFFFF&
>                 buffer = New String(Chr(0), childtxtLen)
>
>                 SendMessageGetChild(ChildStatusbar, SB_GETTEXT, 1, buffer)
>
>                 MessageBox.Show("Length of Statusbar Panel text is: " &
> childtxtLen & vbCrLf & _
>                                 "The text = " & buffer)
>
>
>             End If
>
>         Catch ex As Exception
>
>         End Try
>
>     End Function
>
>
Author
28 Mar 2005 6:48 PM
Chris Dunaway
Wouldn't it be simpler to use a line like this:

MessageBox.Show(StatusBar1.Panels(0).Text)

??
Author
28 Mar 2005 7:13 PM
Herfried K. Wagner [MVP]
Chris,

"Chris Dunaway" <dunaw***@gmail.com> schrieb:
> Wouldn't it be simpler to use a line like this:
>
> MessageBox.Show(StatusBar1.Panels(0).Text)

For the application currently executing yes, but not for other
applications...

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
28 Mar 2005 7:04 PM
gv
thanks for your help,

I guess I didn't make it clear, this is for my program to get the text in a
statusbar from
another program.

thanks
GV




Show quoteHide quote
"gv" <viat***@musc.edu> wrote in message
news:eYvMe%237MFHA.3336@TK2MSFTNGP10.phx.gbl...
> Please help
>
> using vb.net 2003, on XP sp2 machine
>
> the length in the panel of the statusbar seams to be correct, but having
> problems
> returning text using "SB_GETTEXT"
>
> please help
>
>
>  Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
> (ByVal lpClassName As String, _
>                 ByVal lpWindowName As String) As Int32
>
>    Private Declare Function FindWindowEx Lib "user32" Alias
> "FindWindowExA" (ByVal hWnd1 As Int32, _
>                 ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2
> As String) As Int32
>
>    Private Declare Function SendMessageGetChild Lib "user32" Alias
> "SendMessageA" (ByVal hwnd As Int32, _
>                     ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
> lParam As String) As Int32
>
>
>
>    Private Const WM_USER = &H400&
>    Private Const SB_GETTEXTLENGTH = (WM_USER + 3)
>    Private Const SB_GETPARTS = (WM_USER + 6)
>    Private Const SB_GETTEXT = (WM_USER + 2)
>
>    Private Const WM_SETTEXT = &HC
>    Private Const WM_GETTEXT = &HD
>    Private Const WM_GETTEXTLENGTH = &HE
>    Public Function GetchildText()
>        Try
>
>            Dim WindowStatusbar As Int32
>            Dim ChildStatusbar As Int32
>            Dim getstring As Int32
>            Dim StatusbarParts As Int32
>            Dim childtxtLen As Int32
>            Dim buffer As String
>
>            WindowStatusbar = FindWindow("BioViewAnalysis", vbNullString)
>
>            If WindowStatusbar <> 0 Then
>                ChildStatusbar = FindWindowEx(WindowStatusbar, 0&,
> "msctls_statusbar32", vbNullString)
>                StatusbarParts = SendMessageGetChild(ChildStatusbar,
> SB_GETPARTS, 0, 0)
>
>                'Panel 1
>                childtxtLen = SendMessageGetChild(ChildStatusbar,
> SB_GETTEXTLENGTH, 1, 0)
>                childtxtLen = childtxtLen And &HFFFF&
>                buffer = New String(Chr(0), childtxtLen)
>
>                SendMessageGetChild(ChildStatusbar, SB_GETTEXT, 1, buffer)
>
>                MessageBox.Show("Length of Statusbar Panel text is: " &
> childtxtLen & vbCrLf & _
>                                "The text = " & buffer)
>
>
>            End If
>
>        Catch ex As Exception
>
>        End Try
>
>    End Function
>