I'm trying to get text from 'Messages' window in spy++ using c++.
i have tried to send WM_GETTEXT,LB_GETMESSAGE message to the window and its children, and its not working.
The code tested on notepad and it just working fine, so how to do this?
I call this function EnumChildWindows(spyHwnd,EnumChildProc,1); //spyHwnd is the handle of 'Messages' window
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
TCHAR text[40];
int length = 0;
int index = 5;
length = SendMessage(hwnd,LB_GETTEXT,index,(LPARAM)text);//or WM_GETTEXT & maxLength=40
return true;
}
The window you're looking for has a "AfxWnd80u" class. I'm pretty sure it's owner drawn. It doesn't seem to receive any messages other than paint and mouse related ones. Owner drawn means that Spy++ stores the text somewhere internally and manually paints the window canvas.
If in this same list you open the "Message Properties" window, you can see the standard listbox control being used. It obviously has different behavior - selection looks different, scrolling is smoother (it's a poor evidence, since these things can be customized, but still somewhat telling - why would you do things differently in one app?)
If you search the web for "get text AfxWnd", you can see a lot of questions without answers. Some resort to simulating Ctrl+C and getting clipboard contents, but Spy++ Messages window doesn't seem to support Ctrl+C.
So, no easy WinAPI way here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With