Click to See Complete Forum and Search --> : The x,y position in TextoutX functions


BlackAPI
March 20th, 2006, 10:36 AM
I get the overriding of TextoutX function , the x,y coordinates in parameters is the coordinates in the current device context, I use a splash form to force the current form redrwaw it self, if the text is English all work well but if text is Russian the coordinates is the coordinate in the flash form( y negative value, a x is ok) PLEASE HELP !WHAT IS PROBLEM?

NoHero
March 20th, 2006, 10:43 AM
Your problem is not obvious... Can you reformulate it, please? And please, post the code here using code tags.

BlackAPI
March 20th, 2006, 12:04 PM
Your problem is not obvious... Can you reformulate it, please? And please, post the code here using code tags.

Yes this is ExtTextOut functions

BOOL WINAPI myExtTextOutW(HDC hDC, int x, int y, UINT options, const RECT *lprc, LPCWSTR str, UINT len, CONST INT *lpDx)

{
//My overriding codes
return ExtTextOutW(hDC, x, y, options, lprc, str, len, lpDx);

}

Informations about the text are writen is in parameters, the x, y possition is logical possition in hDC but problem like this:
I use this overriding to get the text from IE, (at possition of mouse) ,in English site like this site it works well, but in some other-language site(example Russian-site) the y coordinate <0 as if it references to the logical coordinate of splash-fake form, which I draw at the mouse possition to force IE to redraw itself(then I can catch the textout function), a x -coordinate is corrected.
The second problem at the lpDX, it is array of the widths of characters in string str, which will be draw, when IE word at normal font size lpDX is not NULL but when we set the View/FontSize != normal it always NULL, msdn says, that the default width is used but how to get the default character width in those situations? I used the GetCharacterWith32 and the GetTextMetrics but they didn't help!
Is it clear?

Brenton S.
March 20th, 2006, 02:36 PM
OK, I know you tried hard to explain the problem but it is still very confusing. Could you please be more specific?

BlackAPI
March 20th, 2006, 04:20 PM
OK, I know you tried hard to explain the problem but it is still very confusing. Could you please be more specific?

Yes my English is not good, but I 'll try again ,the first of all If you have experiences with technology WINAPI HOOK you will know what is catching and overriding TextOutXX functions.
The seconds lets take a look at parameters of TextOutXX function you will see there x, y as coordinates of the string(str), which will be writen to the screen but x, y reference to the coordinates(Logical) of DeviceContext in hDC but not to ScreenCoordinates(Physical)
My program work like a hook proccess I use a fake form, whose size is very small(20x2) and the lifetime ~50ms, the fake form will show at the possition of the mouse like a splash , after that the current application(Internet Exproler(IE)..) redraws part, where the fake form was, IE calls the TextOutXX, which is overrided by my function myTextOutXX.
Then I will get the strings in parameter str called by TextOut, but I have problem when trying to caculate the coordinates of the strings,
Look at example
>>>>>>>>>>>>>>>>
109 132 //are the mouse possition in this devicecontext(hDC)
77 //Leng of the string
//72 number = width of the character
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
/ /72 widths of 72 character
I can get extractly the word under possition of mouse, but in other website
//the strings to be rewriten ( "hooked " this form!!!)
>>>>>>>>>>>>>>

I can get extractly the word under possition of mouse, but in other website when the View/TextSize == large or largest.. or in the sites where the fonts is not english base the y coordinate <0, if is referenced to the coordinates of splash(fake) form so it is negative.

Brenton S.
March 21st, 2006, 07:43 AM
So you're are having trouble getting the coordinates of the text relative to IE, right?

BlackAPI
March 21st, 2006, 09:22 AM
Yes, When IE is redrawing itself It calls many TextOUtXX so it is difficult to locate the text base on location of mouse when the sizes of text are not known . Problem is solved if I can make IE redraw only the text where the mouse is then I haven't care about text's possition. Do you have any idea?

Brenton S.
March 21st, 2006, 02:39 PM
I think I may know a solution, just give me some time. Can you possibly email me a code snippet so that I can find a solution?

BlackAPI
March 21st, 2006, 04:11 PM
I think I may know a solution, just give me some time. Can you possibly email me a code snippet so that I can find a solution?
Yes the I have only demo Code of WINAPI HOOK
You can Dowload and read about it from here http://www.codeproject.com/system/Paladin.asp
It works (the mai DLL HookAPINT.dll complie by VS C++6.0 , These are many types of API hook in this Demo version included TextOut, mydll.dll can be complied in VS 7.1 or higher
My Program is writen in C#, it work with ~50 MB data so I can't send it to you, You can creat a C# or other program and use this DLL on it, the
recommend use a GlobalHook (there is C#source code in Code Project, try Google) to hook Keyboard, so you can invoke the hook process in other application!!
(If you are API programer it is not difficult..)
You will see in MS Word it work well.
If you need more specific I can send by email some of my codes!
Thanks for your help!
Regards, BlackAPI

Brenton S.
March 21st, 2006, 06:25 PM
Can you please send me the code by email?

BlackAPI
March 24th, 2006, 05:57 AM
Can you please send me the code by email?
Yes , the cod is in C#, Tell me the address so I can attact file!

shahswapnil963
February 26th, 2009, 05:16 AM
Hi,
I want to capture word under mouse poisition. I have used api hooking. I have hooked all TextOutXX function. It capture all TextOutXX function but it wont be useful. Now I want to determine and invalidate specific Rect which contains mouse position. so I can capture string that is under mouse position. I am not able to determine that rect . Can u please share how did u find that rect to capture word ?