[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 543
  • Last Modified:

How to intercept DrawText request upon WM_PAINT message ?


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
hung2k
Asked:
hung2k
1 Solution
 
FengYuanCommented:
DrawText eventually calls TextOut or ExtTextOut.

It's very hard to intercept calls system-wide in user mode.
0
 
MRNMurthyCommented:
Hi,

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

From

MRN Murthy
0
 
DanRollinsCommented:
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
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
hung2kAuthor Commented:
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
 
DanRollinsCommented:
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
 
hung2kAuthor Commented:
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
 
DanRollinsCommented:
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
 
DanRollinsCommented:
hi hung2k,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
DanRollinsCommented:
hi hung2k,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
hung2kAuthor Commented:
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
 
hung2kAuthor Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now