Solved

How to intercept DrawText request upon WM_PAINT message ?

Posted on 2001-09-12
11
517 Views
Last Modified: 2013-11-20

I was told that we can intercept the call to DrawText function of Window DLL so that whenever a window is asked to redraw the text, and calls DrawText to do that, the interceptng function will get called and know the text that may be written on

Does anyone know how to do this ? I need this functionality in my program

Thank you very much for you rhelp
0
Comment
Question by:hung2k
11 Comments
 
LVL 5

Expert Comment

by:FengYuan
Comment Utility
DrawText eventually calls TextOut or ExtTextOut.

It's very hard to intercept calls system-wide in user mode.
0
 
LVL 1

Expert Comment

by:MRNMurthy
Comment Utility
Hi,

I doubt whether it is possible, I will check & come back with updates.

From

MRN Murthy
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi hung2k,
Intercepting calls to a system DLL is difficult and inadvisable.  Please describe what you wish to accomplish.  Perhaps somebody will be able to come up with some ideas on how to solve your problem without needing to intercept a system API call.

Hi MRNMurthy,
Why do you make all of these "informationless" posts?  If you have something to contribute, then please do.  But saying "I'll get back soon with some information" (which I've now seen you do several times) contributes nothing.

-- Dan
0
 

Author Comment

by:hung2k
Comment Utility
Well,
What I want to do here is:
- When I press right button on a word in a HTML page in my application, I can get the word text and look for its meaning in my own dictionary

The problem with normal method - select the text and retrieve the selected text out - doesnot work here since the word user selects may be part of the link, which HTML View prevent us to select or retrieve part of the word

I intend to intercept DrawText to see what would be redrawn in the adjacent part of the cursor where user clicks right button and hope to get the text

Is there any other way to do that ?
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Jus to see if I understand:

So have a CHtmlView in which you are already handling right clicks of the mouse (How? There are several methods and the way that you have implemented this part helps to frame the question).

When the user right-clicks, you currently select the clicked word (How?  By simulating a double-click of the left mouse button??), copy it to the clipboard, then examine the clipboard.  Now you look up the word and pop up a definition for it.

Is that correct?

But the problem is that is the user right-clicks on a multiple-word hyperlink, the action that you currently take (see the second "How?", above) result in you ending up with several words so you don't know which one to look up.

Is that correct?

Depending upon your response to the above "How?" questions, I can think of several ways to solve your problem.

-- Dan
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:hung2k
Comment Utility
Dan,
For the moment, in CHtmlView, user can highlight a text within the HTML page if this is not a link. I believe that in such case I can get the selection text whenever user right click the mouse, popup the dialog, lookup the selection text in dictionary and give out explanation. So the first of your questions above seems to be Yes. (but user need to highlight the text before right click)

This technique, I have not implemented yet, seemed unable to be used if the word is part of a multiple-word hyperlink: user can not highlight a word in such case. And I cannot get a whole link's text to lookup. So the second answer is also Yes
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
It sounds like you are in the exploratory phase -- you have not actually implemented any part of this.  Is that correct?

I'm certain that the presence of hyperlinks -- and the way IE tends to highlight a link as as a single unit -- is not a showstopper.  For one thing, it *is* possible to highlight a portion of a hyperlink (but you have to kinda sneak up on it from above or below).  For another, it should be possible to use the location of the mouse pointer to zero in on a particular single word, regardless of whether it is in a link or otherwise.

So, go ahead an implement whatever part of the project you can, and I'll provide additional help when you get to the point where you actually need it.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi hung2k,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
Comment Utility
hi hung2k,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 

Author Comment

by:hung2k
Comment Utility
Dan,

Well,
I've done some code to read HTML file into my own browser
Now I want to capture the places where I press right button on the loaded page, to get the text of element of the page there

It seemed to me that something like IMarker may do this
But I'm not sure about the usage of this interface

Any advice is appreciated

Hung
0
 

Author Comment

by:hung2k
Comment Utility
Dear all,
One more time, the solution for the subject question is not here. What I want is to get the right click on HtmlView page and get the word near to the mouse point
to start some special treatment.

But this seemed tricky and Dan had suggested me to implement a real app to investigate another way round

I had use CHtmlView and find out way to work with my own ShowContextMenu to process the right mouse click event
And this question must be closed without its correct reply

I still grant the points to Dan anyway, since he led me to another viewpoint

Thank you for it Dan
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now