Solved

How to intercept DrawText request upon WM_PAINT message ?

Posted on 2001-09-12
11
526 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

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
 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 78
Named range not carried over 10 63
ShiftLeft challenge 21 81
FizzBuzz challenge 9 80
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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