By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Reading the text in a panel of a statusbar in another program

P: n/a
gv
Hi all,

I'm trying to just read the text in one of the panels of a statusbar in a
different program. I have
tried the code below which works fine with notepad.
Can someone 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 GetMessageSTRING Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As
Int32, ByVal lParam As String) As Int32
Private Declare Function SendMessageSTRING 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_SETTEXT = &HC
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE

Private Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd
As Int32, ByVal _WM_USER As Integer, ByVal wParam As Integer, ByVal
windowText As StringBuilder) As Integer
Public Function GetText()
Try

Dim WindowStart As Integer
Dim ChildWindowTxt As Integer
Dim getstring As String

WindowStart = FindWindow("NewProg", vbNullString)
ChildWindowTxt = FindWindowEx(WindowStart, 0&, "statusbar5",
vbNullString)

Dim textSize As Integer = 1024
Dim buffer As New StringBuilder(textSize)
SendMessage(ChildWindowTxt, WM_GETTEXT, textSize, buffer)
MessageBox.Show(buffer.ToString())
Catch ex As Exception

End Try

End Function

thanks
gv
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.