using SB_GETTEXT

G

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
 
R

Roger

Are you sure there is not an easier way to do
that?
There should be a Text property.
Roger
 
C

Chris Dunaway

Wouldn't it be simpler to use a line like this:

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

??
 
G

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
 
H

Herfried K. Wagner [MVP]

Chris,

Chris Dunaway said:
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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top