1,183
社区成员
发帖
与我相关
我的任务
分享
function NewExtTextOutW(theDC: HDC; nXStart, nYStart: integer; toOptions:
Longint; p_rect: PRect;
Str: Pwidechar; Count: Longint; Dx: PInteger): BOOL; stdcall;
type
TExtTextOutW=function (theDC: HDC; nXStart, nYStart: integer; toOptions:Longint;
p_rect: PRect; Str: Pwidechar; Count: Longint; Dx: PInteger): BOOL; stdcall;
var
dwBytes: DWORD;
poOri, poDC, poText, poMouse: TPoint;
Size: TSize;
Rec,tmprec:TRect;
faint:boolean;
nTextLen,uf:integer;
tmpstr:string;
hf:HFONT;
tm:TEXTMETRIC;
begin
Hook[fExtTextOutW].Restore;{暂停截取API,恢复被截的函数}
try
tmpstr:='success';{我将一切截获的字符串替换成success}
str:=pwidechar(tmpstr);
count:=length(tmpstr);
GetTextExtentPointW(theDC, Str, Count, Size);{计算字符串宽高}
if toOptions<>ETO_GLYPH_INDEX then
toOptions:=ETO_OPAQUE and ETO_IGNORELANGUAGE;{刚开始以为是这个参数在搞鬼,我就写死了。如果这个参数等于ETO_CLIPPED,输出文字就会控制在在temprec区域内,不会超出}
tmprec:=Rect(nXStart,nYStart,nXStart+size.Width,nYStart+size.Height); {计算输出字符串截获区域大小,其实这一行可以不要,我是实在没辙做了一下测试,这个区域的宽度无论改多大,对最后输出结果没影响}
finally
{调用被截的函数}
result := TExtTextOutW(Hook[fExtTextOutW].OldFunction)(theDC, nXStart, nYStart, toOptions,@tmprec, Str, Count, nil);
end;
Hook[fExtTextOutW].Change;{重新截取API}
end;