Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > API > text of Statusbar panels


Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2003, 02:39 PM
Kat-olade's Avatar
Kat-olade Kat-olade is offline
Regular
 
Join Date: Aug 2003
Location: Cambs, UK
Posts: 71
Default text of Statusbar panels


ive tried ever possible way i can think of from usingthe sendmessage to the getwindowtext but stilldont seem to get the text i want from a Statusbar.

I retrieve the statusbar hWnd from the designated window (statusbar class : msctls_statusbar32)

anyone know how to retrieve the text from the control (seems to be only one "panel" on the control
Reply With Quote
  #2  
Old 08-26-2003, 03:27 PM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

Was this StatusBar created with API or are you using the StatusBar control included in the Microsoft Windows Common Controls component library?

Panels is a 1-based index so, if the status bar has one panel, then:
Code:
MsgBox StatusBar1.Panels(1).Text
__________________
The only stupid question is the one that goes un-asked.
Reply With Quote
  #3  
Old 08-26-2003, 05:34 PM
Kat-olade's Avatar
Kat-olade Kat-olade is offline
Regular
 
Join Date: Aug 2003
Location: Cambs, UK
Posts: 71
Default statusbar

The Status Bar is not in my application. it is a child of another program that im intending to interact with.

i use findwindow to get hwnd of the window that the status bar is a child of, then use findwindowEX to ghet the hwnd of the status bar

now all i need to do is retrieve the text from it... which seems almost impossible
Reply With Quote
  #4  
Old 08-27-2003, 05:39 AM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

The StatusBar may be one of those controls that in fact contains constituent controls (much like a ComboBox contains an edit class and a list class).

You may need to use the GetWindow API call to iterate through its children. The GetWindow call using GW_CHILD will provide the handle of the first constituent control and GW_HWNDNEXT will provide the handle for each subsequent constituent control. Once you have obtained the handle of the constituent control, then you should be able to use the GetWindowText API call to retrieve what it is displaying.

Note: You may need to use the GetClassName API call to identify any specifics about the constituent control that may help in making sure that you have the right one.
__________________
The only stupid question is the one that goes un-asked.
Reply With Quote
  #5  
Old 08-27-2003, 06:24 AM
Merrion's Avatar
Merrion Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default

According to the file COMMCTRL.H the special messages related to status bar controls are:
Code:
Public Enum StatusBarControlMessages SB_SETTEXTA = &H401 SB_SETTEXTW = &H411 SB_GETTEXTA = &H402 SB_GETTEXTW = &H413 SB_GETTEXTLENGTHA = &H403 SB_GETTEXTLENGTHW = &H412 SB_SETPARTS = &H404 SB_GETPARTS = &H406 SB_GETBORDERS = &H407 SB_SETMINHEIGHT = &H408 SB_SIMPLE = &H409 SB_GETRECT = &H410 SB_ISSIMPLE = &H414 SB_SETICON = &H415 SB_SETTIPTEXTA = &H416 SB_SETTIPTEXTW = &H417 SB_GETTIPTEXTA = &H418 SB_GETTIPTEXTW = &H419 SB_GETICON = &H420 End Enum

Presumably sending some combination of these to the hwnd of the status bar should get the result you want...?
Reply With Quote
  #6  
Old 08-27-2003, 07:30 PM
Kat-olade's Avatar
Kat-olade Kat-olade is offline
Regular
 
Join Date: Aug 2003
Location: Cambs, UK
Posts: 71
Default

ok ive created two calls based around merrion's enum and called them
Code:
Public Declare Function SendStatusBarMessage Lib "user32" _ Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As enmStatusBarControlMessages, _ ByVal wParam As Long, lParam As Any) As Long Public Declare Function SendStatusBarMessageByString Lib "user32" _ Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As enmStatusBarControlMessages, _ ByVal wParam As Long, ByVal lParam As String) As Long
i then created a function
Code:
Function cGetText3(ByVal TheWnd As Long) As String Dim WndLength As Long, cTxt As String WndLength = SendStatusBarMessage(TheWnd&, SB_GETTEXTLENGTHA, 0&, 0&) cTxt$ = String(WndLength&, 0&) Call SendStatusBarMessageByString(TheWnd&, SB_GETTEXTA, WndLength& + 1, cTxt$) cGetText3$ = cTxt$ End Function
and call it like so
Code:
statusWnd = FindWindowEx(TheWindowsHwnd&, 0&, "msctls_statusbar32", vbNullString) statusText = cGetText3(statusWnd)

in the call it does get the right length of the text in the status bar (yes i did count them lol) but it doesnt seem to want to pull back the text..
where am i going wrong?
Reply With Quote
  #7  
Old 09-08-2003, 07:07 PM
WilliamIE WilliamIE is offline
Newcomer
 
Join Date: Sep 2003
Posts: 2
Default

I had a similar problem a while ago. The status bar can be a bit tricky. I haven't tested this code, but It should work in theory. Hope it does the trick.

W.EZ

Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any _ ) As Long Public Declare Function SendMessageString Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String _ ) As Long Function cGetText3(ByVal TheWnd As Long) As String Dim tBuffer As String Dim tLength As Long tLength = SendMessage(TheWnd, SB_GETTEXTLENGTHA, 0, 0) tBuffer = String(tLength, " ") tBuffer = tBuffer & Chr$(0) Call SendMessageString(TheWnd, SB_GETTEXTA, 0, tBuffer) cGetText3 = tBuffer End Function
Reply With Quote
  #8  
Old 10-30-2003, 10:10 PM
MrArcticus MrArcticus is offline
Newcomer
 
Join Date: Oct 2003
Posts: 1
Default any working solution???

Hello,

does anyone has a working solution for this problem. I have no problem with the above mentioned solutions as long as the statusbar is created by the same application that performs reading of the statusbar's contents.
As soon as the statusbar is located in a different application, they are not working. No problem to get the length of the texts of the different sections of the statusbar but the SB_GETTEXTA is not returning the text itself.

kind regards
MrArcticus
Reply With Quote
  #9  
Old 10-31-2003, 05:35 AM
WilliamIE WilliamIE is offline
Newcomer
 
Join Date: Sep 2003
Posts: 2
Default

[QUOTEPOST]

Hmm. Have you tried playing around with different combinations of SendMessageW/SendMessageA and SB_GETTEXTW/SB_GETTEXTA. I think the 'W' suffixed methods and constants are for unicode apps. Maybe your target app is one of these?

[/QUOTEPOST]
Reply With Quote
  #10  
Old 03-15-2004, 08:00 AM
Kat-olade's Avatar
Kat-olade Kat-olade is offline
Regular
 
Join Date: Aug 2003
Location: Cambs, UK
Posts: 71
Talking Thanks

Thanks to Dr. Memory.. He has release a small piece of code that clears this up. and Does it very well (as usual hehehe ).

Still not 100% sure how it does it.. but have the gist of it.

Thanks again Dr. Memory (MathImagics)

You can find the Post here:
http://www.xtremevbtalk.com/showthread.php?t=122191
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the number of panels of StatusBar in VB6? xiaoDD General 2 06-30-2003 06:08 AM
Forecolor in StatusBar Panels Zana Maseluta General 3 03-24-2003 06:14 AM
Logging keys to edit text Wise_Reeper General 5 12-09-2002 08:01 PM
changing text color in statusbar falcore20 General 2 07-22-2002 03:46 AM
Wraping text around an image? Serevinus Web Programming 7 06-20-2002 01:46 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->