|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
using SB_GETTEXTusing 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 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 > > Wouldn't it be simpler to use a line like this:
MessageBox.Show(StatusBar1.Panels(0).Text) ?? Chris,
"Chris Dunaway" <dunaw***@gmail.com> schrieb: For the application currently executing yes, but not for other > Wouldn't it be simpler to use a line like this: > > MessageBox.Show(StatusBar1.Panels(0).Text) applications... -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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 >
FindWindow API
compression of a string , but must be interoptable someone an idea ?? FileSystemObject vs System.IO.File Array of Hash Tables Query database in VB.NET VB to C# Problems with the PrintPreviewControl, PrintPreviewDialog controls the project location is not fully trusted by .net runtime Got to be an easier way... [String] |
|||||||||||||||||||||||