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

Reading value of a StatusBar (wx) control

P: n/a
Hi to everybody

I hope this is the right place to post this question.

I have a problem I can't solve by myself. Maybe someone here can help me...

I need to access the content of a status bar field of a running Windows
application (which makes use of wxWidgets). I've just the executable,
not the source code of it.

I'm parsing the HWNDs until I found one of class msctls_statusbar32
(STATUSCLASSNAME).

For this HWND (which corresponds to the statusbar):
- SB_GETUNICODEFORMAT returns TRUE
- SB_ISSIMPLE returns FALSE

Then I call
rc=SendMessage(hWnd, SB_GETPARTS, 0, 0)
which returns correclty the number of parts of the statusbar control.

Th problem araises when I want to retrieve the content of one of these
parts. Here's the steps I follow:

1) I determine the length of the part text:
nChars=SendMessageW(hWnd, SB_GETTEXTLENGTHW, 0, 0) & 0xFFFF;
(this is correct: it's the length of the text of the first statusbar part)

2) I allocate a buffer to hold the text
lChars=(WCHAR *)malloc((nChars+1)*sizeof(WCHAR));

3) And finally, I retrieve the text:
nChars=SendMessageW(hWnd, SB_GETTEXTW, 0, lChars) & 0xFFFF;
Here it comes the error. Windows says that the error "unhandled
exception" is in comctl32.dll (v5.82.2900.2180), at offset 00006600.
After showing up the message, the running application owning the status
bar ends. To verify it's not an error of buffer overflow, I tried to
allocate a bigger buffer than the one specified by SB_GETTEXTLENGTHW
(30,000 bytes), but the error is still there.
I've trie to do use the SendMessageA with GETTEXTLENGTHA and
SB_GETTEXTA, but the error happened again.

I'm using Windows XP Pro with SP2.

Anyone?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Michele Locati ha scritto:
Hi to everybody

I hope this is the right place to post this question.

I have a problem I can't solve by myself. Maybe someone here can help me...

I need to access the content of a status bar field of a running Windows
application (which makes use of wxWidgets). I've just the executable,
not the source code of it.

I'm parsing the HWNDs until I found one of class msctls_statusbar32
(STATUSCLASSNAME).

For this HWND (which corresponds to the statusbar):
- SB_GETUNICODEFORMAT returns TRUE
- SB_ISSIMPLE returns FALSE

Then I call
rc=SendMessage(hWnd, SB_GETPARTS, 0, 0)
which returns correclty the number of parts of the statusbar control.

Th problem araises when I want to retrieve the content of one of these
parts. Here's the steps I follow:

1) I determine the length of the part text:
nChars=SendMessageW(hWnd, SB_GETTEXTLENGTHW, 0, 0) & 0xFFFF;
(this is correct: it's the length of the text of the first statusbar part)

2) I allocate a buffer to hold the text
lChars=(WCHAR *)malloc((nChars+1)*sizeof(WCHAR));

3) And finally, I retrieve the text:
nChars=SendMessageW(hWnd, SB_GETTEXTW, 0, lChars) & 0xFFFF;
Here it comes the error. Windows says that the error "unhandled
exception" is in comctl32.dll (v5.82.2900.2180), at offset 00006600.
After showing up the message, the running application owning the status
bar ends. To verify it's not an error of buffer overflow, I tried to
allocate a bigger buffer than the one specified by SB_GETTEXTLENGTHW
(30,000 bytes), but the error is still there.
I've trie to do use the SendMessageA with GETTEXTLENGTHA and
SB_GETTEXTA, but the error happened again.

I'm using Windows XP Pro with SP2.

Anyone?


Ok, I solved it finally. It was due to inter-process memory protection.
To be able to use shared memory between two processes I used the code
shown here (adapted from Visual Basic)
http://www.visualbasicforum.com/showthread.php?t=114019
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.