Solved

How to intercept DrawText request upon WM_PAINT message ?

Posted on 2001-09-12
11
522 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
ID: 6478504
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
ID: 6482948
Hi,

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

From

MRN Murthy
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6484393
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
ID: 6486614
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
ID: 6488577
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:hung2k
ID: 6489539
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
ID: 6491420
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
ID: 6516000
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
ID: 6639955
hi hung2k,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 

Author Comment

by:hung2k
ID: 6700399
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
ID: 7139881
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

943 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

5 Experts available now in Live!

Get 1:1 Help Now