How is word repainting itself?

P

Phil Crosby

I'm using Spy++ to look at the WM_PAINT window messages moving across the
word process, to see how the windows in Word are related. If you edit the
content of the document using the keyboard, it seems like the only windows
that receive a WM_PAINT message are the two MsoCommandBar windows (that are
children of the WwB document window) and the status bar. I think the actual
repainting of the document is happening in the WwG window. Why is it
repainting when there is no WM_PAINT message? I'm no expert in win32
painting, but I thought it was a best practice not to paint outside of a
WM_PAINT message. Do you think word is using CreateGraphics directly on the
device context?

I'm concerned because I'm interested in monitoring closely what Word is
doing - especially when it's done painting. I'm doing this for a research
prototype, so all hacks are allowed and best practices ignored ;-) I was
thinking of listening for WH_CALLWNDPROCRET using SetWindowHookEx and finding
out when the appropriate window was done responding to a WM_PAINT event.
However, if the Word window doing the redrawing of the document isn't sending
a "done" message when it's done painting, well, that strategy won't work.

Are there any general pointers I should look into? If Word is calling
CreateGraphics or some other giveaway win32 method that I can listen for,
what might that method be?

Thanks!
-Phil Crosby
 
P

Phil Crosby

I did a DLL injection hack to monitor calls to the BeginPaint and EndPaint
methods in USER32.DLL as outlined in this classic article:

http://www.fengyuan.com/article/wmprint.html

It seems the only windows that call BeginPaint are the windows I mentioned
in my first post. What other drawing method would Word use to paint on the
device context that corresponds to the window containing the document content?

Someone else ran into this issue while trying to force a hidden window
capture of Word-
http://www.probo.com/timr/blog/pyblosxom.cgi/2005/Nov

He mentions that the Word rendering window probably has its window style set
as CS_OWNDC (which I can't verify in Spy++), but even in that case I thought
you still needed to call BeginPaint to draw. Clearly that's not the case, as
no windows call when the document is modified except the two MsoCommandBar
windows and the status bar.

-Phil Crosby
 
P

Phil Crosby

If you read the post, the question is " Are there any general pointers I
should look into? If Word is calling CreateGraphics or some other giveaway
win32 method that I can listen for, what might that method be?" Since I have
no idea what I'm doing when it comes to win32 GDI, I don't even know "in
general" how Word might be drawing itself, and so any rabbit trails to follow
would help me greatly.

If you're referring to my followup, I'm trying to post my findings as they
relate to this question, so if someone more knowledgable responds, they will
be able to see which paths I've gone down.

-Phil Crosby
 
J

Jonathan West

Karl Peterson is usually the best guy to answer these kinds of questions. I
don't think he comes to this group all that often, but if you repost to
microsoft.public.office.developer.vba he'll see it there.
 
K

Karl E. Peterson

Jonathan said:
Karl Peterson is usually the best guy to answer these kinds of
questions. I don't think he comes to this group all that often, but
if you repost to microsoft.public.office.developer.vba he'll see it
there.

Yep, saw it there, and replied there. Short story, of my take on this, is
that I think Phil's rather SOL here. Word (like nearly all MS apps) breaks
all the rules. And (like nearly _all_ apps), it would paint itself whenever
it felt like it, in addition to doing updates at the provocation of the
system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top