Call TextMatrix on external app's MSHFlexGrid
I would like to get the text from cells in an external application's MSHFlexGrid.
http://msdn.microsoft.com/library/de...ridcontrol.asp
Can it be done with hooking/subclassing or another method?
value = externalForeignAppsMSHFlexGrid.TextMatrix(rowindex, colindex)
Edit: Below (upto post 13) may be irrelevant.
Spy++ doesn't give me a handle for individual cells like it would for the caption of a window. So I have no WM_SETTEXT message. The only messages I see when data in a cell is updated are:
WM_STYLECHANGING
WM_STYLECHANGED
WM_PAINT
The text in the cells change colors, so I guess that's why the WM_STYLE* messages are there. Spy++ reports a point for the WM_PAINT messages and I thought those points may always be bounded by the RECT for the MSHFlexGrid, but they are not.
Thoughts?
Re: Not your average GetText/Hook: MSHFlexGrid
have you tried FindWindowEx ?... to get handle of MSHFlexGrid then work with it... :)
Re: Not your average GetText/Hook: MSHFlexGrid
There isn't a window for each cell - you'd soon run out of resources if there were.
Re: Not your average GetText/Hook: MSHFlexGrid
If Spy++ doesn't show messages coming to the grid, then I guess the grid's text isn't handled with messages.
Try hooking the app anyway and see what messages you get. When you hook an external app you are actually hooking the entire process that the app is running in. Make sure you hook both sent and posted messages.
If the values are being input via the keyboard, then you could always do a keyboard hook.
...
Image processing as last resort. Keep the ideas coming.
There are 3 messages when the grid is updated (spying on the grid). Just not the convenient WM_SETTEXT.
Are you suggesting spying on the whole app instead of only the grid?
I was thinking that the point in the WM_PAINT would indicate a location for the OS to begin a BitBlt, but I see no width/height. This is still leading to my only proposed solution of capturing an image and trying some image processing.
If I send the WM_PAINT message to my subclassed picturebox, could I cause the picturebox to be rendered/painted to appear graphically as the grid (or grid cell) being repainted? If so, how?
Or can I get access to the image/pixel data of the grid (even if the grid is not completely visible onscreen) -- similar to rendering to an offscreen buffer to attempt image processing?
Re: Not your average GetText/Hook: MSHFlexGrid
Someone mentioned the offscreen buffer a while back. I know that unless you know of a way to do that, the bitblt method will return -1 for the pixel color. Also you might try an API spy to see if maybe the text is being drawn to the cells. Check for calls to Rlt functions.
Reference Note: SendMessage versus PostMessage and some questions
I fell into this trap again. Please correct me if I am wrong.
I wasn't seeing the WM_PAINT message in my CallWndProc callback. Probably because I should be using the GetMsgProc callback.
I believe Spy++ reports the message as S and P for sent messages via SendMessage and posted messages via PostMessage, respectively.
For a sent message S (SendMessage) use CallWndProc
For a posted message P (PostMessage) use GetMsgProc
http://msdn.microsoft.com/library/de...dowshookex.asp
Quote:
WH_CALLWNDPROC
Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.
WH_GETMESSAGE
Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.
Other notes:
Also, I thought all the info to paint/render an area on the screen would be in a WM_PAINT message. My plan was to send my picturebox the WM_PAINT message and have it paint itself with the same image. Apparently this is wrong. So I used Partial Screen Capture http://vbforums.com/showthread.php?t...screen+capture using the coordinates given by Spy++ for the found target window. I just need to sample the area of the screen when a WM_PAINT message is received. Also, my target app sends (or rather POSTS) 2 WM_PAINT messages. Apparently 1 at the beginning of the paint and 1 at the end. I don't see any visual change after the 2nd WM_PAINT, only after the 1st. Ever seen that before? What's going on?
Next step: Get color data
This seems kind of bulky (but it is in VB).
http://vbforums.com/showthread.php?t...screen+capture
I'm thinking I should move as much as possible to the DLL to get faster execution (for upcoming image processing code and other calculations). Are there any drawbacks to this approach and shouldn't I get faster execution?
Re: Not your average GetText/Hook: MSHFlexGrid
Quote:
I believe Spy++ reports the message as S and P for sent messages via SendMessage and posted messages via PostMessage, respectively.
For a sent message S (SendMessage) use CallWndProc
For a posted message P (PostMessage) use GetMsgProc
This is correct.
Quote:
I'm thinking I should move as much as possible to the DLL to get faster execution
If most of the code is API calls, then you won't see much of an improvement in performance. Being a VB programmer, I always like to move the coding back to VB as soon as pratical so that I can compile the dll and forget about it.
Re: Not your average GetText/Hook: MSHFlexGrid
So hand coded matrix math operations and for loops would benefit?
Are there any matrix math api calls?
Re: Not your average GetText/Hook: MSHFlexGrid
Quote:
So hand coded matrix math operations and for loops would benefit?
Is the Pope Catholic?
Quote:
Are there any matrix math api calls?
There are certainly a lot of open source C++ libraries out there for this.
Re: Not your average GetText/Hook: MSHFlexGrid
How about the double WM_PAINT messages? Could it be some parent getting a WM_PAINT and trickling down?
Re: Not your average GetText/Hook: MSHFlexGrid
Where do you see these WM_PAINT messages? In your hook or in SPY++?
Re: Not your average GetText/Hook: MSHFlexGrid
I see them in Spy++. The app is at home, so I can't even change to the GetMsgProc yet to see them in my hook.
Maybe it is average... GetText/Hook: MSHFlexGrid
Is there a way to call TextMatrix on the external applications's MSHFlexGrid?
I just want to read the data not change it. :ehh:
The screen capture/image processing technique may be overkill.