屏幕取词(100分)

  • 主题发起人 主题发起人 寒芳轻
  • 开始时间 开始时间

寒芳轻

Unregistered / Unconfirmed
GUEST, unregistred user!
  最近在研究屏幕取词,网上找到一些资料,说的是取鼠标选中的"词"的方法<br>我想做个取某个窗口中特定控件上的字,如:我想在我的程序界面上同步显示我打开的IE地址栏内的东西,首先我通过鼠标获取ie的句柄,然后在dll中做个定时器,能不能得到这个IE地址栏的内容同步显示在我的程序界面上~~~~<br>  有没有达人做过类似的东西,给点参考思路~~~~~~
 
用timer效率肯定不行的,试试hook某个消息~~~
 
转个:<br><br>如有讨论者可以通过huiyugan@263.net甘化新(作者)联系。<br><br>//链接库 GFDict.dll的代码,GFDict.dpr<br>(*******************************************************************************<br>* Copy Right (C) Gan Huaxin 2001, 2002, huiyugan@263.net<br>* A Free Screen Words Capture Library<br>* &nbsp; Dedicated to my GirlFriend Sunny, Happy for ever<br>* <br>* Version &nbsp; &nbsp; &nbsp; &nbsp; Date &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Modification<br>* &nbsp; 0.1 &nbsp; &nbsp; &nbsp; 2001-11-07~09 &nbsp; &nbsp; &nbsp; New, oly a test<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Can Get Word, Sometimes occure error<br>* &nbsp; 0.2 &nbsp; &nbsp; &nbsp; 2002-05-14~16 &nbsp; &nbsp; &nbsp; Some Bugs Fixed,And<br>*******************************************************************************)<br>library GFDict;<br><br>// {$DEFINE MSG_NOT_SEND}<br>{$DEFINE WIN_NT}<br><br>{$IFNDEF WIN_NT}<br>&nbsp; {$DEFINE WIN_9X}<br>{$ENDIF}<br><br>// {$DEFINE DEBUG}<br><br><br>uses<br>&nbsp; SysUtils,<br>&nbsp; Classes,<br>&nbsp; windows,<br>&nbsp; messages,<br>&nbsp; untTypes;<br><br>const<br>&nbsp; STR_MSGNOTIFY:PChar='WM_GANNOTIFY';<br><br>var<br>&nbsp; HMapFile:THandle;<br>&nbsp; CommonData:^TCommonData;<br>&nbsp; idMsg : UINT;<br>&nbsp; hwndServer : HWnd;<br><br>var<br>&nbsp; hWndCover : THandle;<br>&nbsp; LastMousePos : TPoint;<br>&nbsp; LastTime : DWORD;<br>&nbsp; g_CriticalSection : TRTLCriticalSection;<br>&nbsp; m_CriticalSection : TRTLCriticalSection;<br>&nbsp; b_InCS : boolean;<br><br>var<br>&nbsp; hNextHookProc: HHook;<br>&nbsp; hProc : THandle;<br>&nbsp; bFirst : boolean;<br>&nbsp; bDllInstalled : boolean;<br>&nbsp; ThunkCodeArr : array[TThunkFunc] of TThunkCode;<br><br>{$IFDEF DEBUG}<br>&nbsp; procedure GanWarning;<br>&nbsp; begin<br>&nbsp; &nbsp; MessageBeep(0);<br>&nbsp; end;<br>{$ELSE}<br>&nbsp; procedure GanWarning;<br>&nbsp; begin<br>&nbsp; end;<br>{$ENDIF}<br><br>{$DEFINE _NOTIFY_}<br><br>{$IFDEF _NOTIFY_}<br>&nbsp; procedure GanNotify;<br>&nbsp; begin<br>&nbsp; &nbsp; MessageBeep(0);<br>&nbsp; end;<br>{$ELSE}<br>&nbsp; procedure GanNotify;<br>&nbsp; begin<br>&nbsp; end;<br>{$ENDIF}<br><br><br>// about Memory Map file support<br>procedure MapCommonData;<br>var FirstCall: Boolean;<br>begin<br>&nbsp; HMapFile:=OpenFileMapping(FILE_MAP_WRITE, False, 'GanGan_ThunkDict');<br>&nbsp; FirstCall:=(HMapFile = 0);<br>&nbsp; if FirstCall then<br>&nbsp; &nbsp; HMapFile:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,SizeOf(TCommonData),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'GanGan_ThunkDict');<br>&nbsp; CommonData:= MapViewOfFile(HMapFile, FILE_MAP_WRITE, 0, 0, 0);<br>&nbsp; if FirstCall then FillChar(CommonData^, SizeOf(TCommonData), 0);<br>end;<br><br>// -----------------------------------------------------------------------------<br>procedure UnInstallThunkFunc(tfType : TThunkFunc);<br>var<br>&nbsp; nCount : DWORD;<br>begin<br>&nbsp; if not ThunkCodeArr[tfType].bInstalled then exit;<br>&nbsp; if (hProc=0) or (ThunkCodeArr[tfType].addr_sys=nil) then exit;<br>&nbsp; WriteProcessMemory(hProc,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ThunkCodeArr[tfType].addr_sys,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@(ThunkCodeArr[tfType].codeBak),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nCount);<br>&nbsp; ThunkCodeArr[tfType].bInstalled := false;<br>end;<br><br>procedure InstallThunkFunc(tfType : TThunkFunc);<br>var<br>&nbsp; nCount : DWORD;<br>begin<br>&nbsp; if ThunkCodeArr[tfType].bInstalled then exit;<br>&nbsp; if (hProc=0) or (ThunkCodeArr[tfType].addr_sys=nil) then exit;<br>&nbsp; WriteProcessMemory(hProc,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ThunkCodeArr[tfType].addr_sys,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@(ThunkCodeArr[tfType].codeThunk),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nCount);<br>&nbsp; ThunkCodeArr[tfType].bInstalled := True;<br>end;<br><br>procedure UnInstallGanFilter; forward;<br><br>{=================== &nbsp;TextOut &nbsp; ==============================================}<br>function GanTextOutA(DC: HDC; X, Y: Integer; Str: PAnsiChar; Count: Integer): BOOL; stdcall;<br>var<br>&nbsp; tm : TTextMetric;<br>&nbsp; rect : TRect;<br>&nbsp; size : TSize;<br>&nbsp; i, j : integer;<br>&nbsp; posDcOrg : TPoint;<br>&nbsp; posDcOff : TPoint;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br><br>&nbsp; result := FALSE;<br>&nbsp; UnInstallThunkFunc(tfTextOutA);<br>{$IFNDEF MSG_NOT_SEND}<br>try<br>&nbsp; if (CommonData&lt;&gt;nil) then begin<br>&nbsp; &nbsp; GetDcOrgEx(dc, posDcOrg); // Get The DC offset<br>&nbsp; &nbsp; posDcOff := Point(x,y);<br>&nbsp; &nbsp; LPtoDP(dc, posDcOff, 1);<br><br>&nbsp; &nbsp; Rect.Left := posDcOrg.x + posDcOff.x;<br>&nbsp; &nbsp; Rect.Top := posDcOrg.y + posDcOff.y;<br><br>&nbsp; &nbsp; if BOOL(GetTextAlign(dc) and &nbsp;TA_UPDATECP) then begin<br>&nbsp; &nbsp; &nbsp; GetCurrentPositionEx(dc, @posDcOff);<br>&nbsp; &nbsp; &nbsp; Inc(Rect.Left, posDcOff.x);<br>&nbsp; &nbsp; &nbsp; Inc(Rect.Top, posDcOff.y);<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; GetTextExtentPointA(DC, Str, Count, size);<br><br>&nbsp; &nbsp; Rect.Right := &nbsp;Rect.Left + size.cx;<br>&nbsp; &nbsp; Rect.Bottom := Rect.Top + size.cy;<br><br>&nbsp; &nbsp; if PtInRect(rect, CommonData.MousePos) then begin // in total area!<br>&nbsp; &nbsp; &nbsp; if StrPos(Str, ' ')&lt;&gt;nil then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; i := 0;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; while (Str = Char(' ')) and (i&lt;Count) do Inc(i);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; j := i;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; while (i&lt;Count) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Str=Char(' ') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := Char(0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTextExtentPointA(DC, Str, i-1, size);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rect.Right := rect.Left + size.cx;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if PtInRect(rect, CommonData.MousePos) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // SendMessage(CommonData.CallBackHandle, idMsg, i, 3);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, PChar(@(Str[j])));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutA), 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := Char(' ');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := Char(' ');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (Str = Char(' ')) and (i &lt; Count) do Inc(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if i=Count then break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j := i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dec(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; if (i=Count) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, PChar(@(Str[j])));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutA), 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, Str);<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutA), 0);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; (*<br>&nbsp; StrCopy(CommonData.BufferA, Str);<br>&nbsp; CommonData^.Rect := Rect;<br>&nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutA), 0);<br>&nbsp; *)<br>except<br>&nbsp; GanWarning;<br>&nbsp; StrCopy(CommonData.BufferA, 'Error in TextOutA');<br>&nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutA), 0);<br>end;<br>{$ENDIF}<br>&nbsp; TextOutA(DC, X, Y, Str, Count);<br>&nbsp; InstallThunkFunc(tfTextOutA);<br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>function GanTextOutW(DC: HDC; X, Y: Integer; Str: PWideChar; Count: Integer): BOOL; stdcall;<br>var<br>&nbsp; tm : TTextMetric;<br>&nbsp; rect : TRect;<br>&nbsp; size : TSize;<br>&nbsp; i, j : integer;<br>&nbsp; wChar : WideChar;<br>&nbsp; posDcOrg, posDcOff : TPoint;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br><br>&nbsp; result := FALSE;<br>&nbsp; UnInstallThunkFunc(tfTextOutW);<br>{$IFNDEF MSG_NOT_SEND}<br>try<br>&nbsp; if (CommonData&lt;&gt;nil) then begin<br>&nbsp; &nbsp; GetDcOrgEx(dc, posDcOrg);<br>&nbsp; &nbsp; posDcOff := Point(x,y);<br>&nbsp; &nbsp; LPtoDP(dc, posDcOff, 1);<br><br>&nbsp; &nbsp; Rect.Left := posDcOrg.x + posDcOff.x;<br>&nbsp; &nbsp; Rect.Top := posDcOrg.y + posDcOff.y;<br><br>&nbsp; &nbsp; if BOOL(GetTextAlign(dc) and &nbsp;TA_UPDATECP) then begin<br>&nbsp; &nbsp; &nbsp; GetCurrentPositionEx(dc, @posDcOff);<br>&nbsp; &nbsp; &nbsp; Inc(Rect.Left, posDcOff.x);<br>&nbsp; &nbsp; &nbsp; Inc(Rect.Top, posDcOff.y);<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; GetTextExtentPointW(DC, Str, Count, size);<br><br>&nbsp; &nbsp; rect.Right := rect.Left + size.cx;<br>&nbsp; &nbsp; rect.Bottom := rect.Top + size.cy;<br><br>&nbsp; &nbsp; if PtInRect(rect, CommonData.MousePos) then begin<br>&nbsp; &nbsp; &nbsp; if StrPos(PChar(WideCharToString(Str)), ' ')&lt;&gt;nil then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; i := 0;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; while (Str = WideChar(' ')) and (i&lt;Count) do Inc(i);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; j := i;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; while (i&lt;Count) do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Str=WideChar(' ') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := WideChar(0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTextExtentPoint32W(DC, Str, i-1, size);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rect.Right := rect.Left + size.cx;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if PtInRect(rect, CommonData.MousePos) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // SendMessage(CommonData.CallBackHandle, idMsg, i, 3);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA,PChar(WideCharToString(@(Str[j]))));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutW), 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := WideChar(' ');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str := WideChar(' ');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (Str = WideChar(' ')) and (i &lt; Count) do Inc(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if i=Count then break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j := i;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dec(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // break;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inc(i);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; if (i=Count) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, PChar(WideCharToString(@(Str[j]))));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutW), 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA,PChar(WideCharToString(Str)));<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := Rect;<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutW), 0);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>except<br>&nbsp; GanWarning;<br>&nbsp; StrCopy(CommonData.BufferA, 'Error in TextOutW');<br>&nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfTextOutW), 0);<br>end;<br>{$ENDIF}<br>&nbsp; result := TextOutW(DC, X, Y, Str, Count);<br>&nbsp; InstallThunkFunc(tfTextOutW);<br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>{=================== &nbsp;ExtTextOut &nbsp;============================================}<br>(*<br>&nbsp; 这个函数在UltraEdit里会出错,加上异常处理就没有关系。<br>&nbsp; Bug Fixed 2002-05-13<br>*)<br>function GanExtTextOutA(DC: HDC; X, Y: Integer; Options: Longint;<br>&nbsp; Rect: PRect; Str: PAnsiChar; Count: Longint; Dx: PInteger): BOOL; stdcall;<br>var<br>&nbsp; posDcOrg : TPoint;<br>&nbsp; posDc : TPoint;<br>&nbsp; RectText : TRect;<br>&nbsp; size : TSize;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br><br>&nbsp; result := FALSE;<br>&nbsp; UnInstallThunkFunc(tfExtTextOutA);<br>{$IFNDEF MSG_NOT_SEND}<br><br>&nbsp; GetDcOrgEx(dc, posDcOrg);<br>&nbsp; posDc := Point(x,y);<br>&nbsp; LPtoDP(dc, posDc, 1);<br><br>&nbsp; RectText.Left := posDc.x + posDcOrg.x;<br>&nbsp; RectText.Top := posDc.y + posDcOrg.y;<br><br>&nbsp; if BOOL(GetTextAlign(dc) and TA_UPDATECP) then begin<br>&nbsp; &nbsp; GetCurrentPositionEx(dc, @posDc);<br>&nbsp; &nbsp; Inc(RectText.Left, posDc.x);<br>&nbsp; &nbsp; Inc(RectText.Top, posDc.y);<br>&nbsp; end;<br><br>&nbsp; GetTextExtentPointA(dc, Str, Count, size); {Get The Length and Height of str}<br>&nbsp; with RectText do begin<br>&nbsp; &nbsp; Right := Left + size.cx;<br>&nbsp; &nbsp; Bottom := Top + Size.cy;<br>&nbsp; end;<br>&nbsp; <br>&nbsp; if (CommonData&lt;&gt;nil) {and false} and PtInRect(RectText, CommonData.MousePos) then begin<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, Str);<br>&nbsp; &nbsp; &nbsp; CommonData^.Rect := RectText;<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; GanWarning;<br>&nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, 'ERROR in ExtTextOutA');<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfExtTextOutA), 0);<br>&nbsp; end;<br>{$ENDIF}<br>&nbsp; result := ExtTextOutA(DC, X, Y, Options, Rect, Str, Count, Dx);<br>&nbsp; InstallThunkFunc(tfExtTextOutA);<br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>function GanExtTextOutW(DC: HDC; X, Y: Integer; Options: Longint;<br>&nbsp; Rect: PRect; Str: PWideChar; Count: Longint; Dx: PInteger): BOOL; stdcall;<br>var<br>&nbsp; posDcOrg : TPoint;<br>&nbsp; posDc : TPoint;<br>&nbsp; RectText : TRect;<br>&nbsp; size : TSize;<br>label last;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br>&nbsp; result := FALSE;<br>&nbsp; UnInstallThunkFunc(tfExtTextOutW);<br>{$IFNDEF MSG_NOT_SEND}<br>&nbsp; if CommonData^.bInSpec then begin<br>&nbsp; &nbsp; (*if (Options and ETO_CLIPPED)=0 then goto last;*)<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA,PChar(WideCharToString(Str)));<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := RectText;<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; GanWarning;<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, 'ERROR in ExtTextOutW');<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfExtTextOutW), 0);<br>&nbsp; &nbsp; goto last;<br>&nbsp; end;<br><br>&nbsp; GetDcOrgEx(dc, posDcOrg);<br>&nbsp; posDc.x := x;<br>&nbsp; posDc.y := y;<br><br>&nbsp; LPtoDP(dc, posDc, 1);<br><br>&nbsp; RectText.Left := posDc.x + posDcOrg.x;<br>&nbsp; RectText.Top := posDc.y + posDcOrg.y;<br><br><br><br>&nbsp; if BOOL(GetTextAlign(dc) and TA_UPDATECP) then begin<br>&nbsp; &nbsp; GetCurrentPositionEx(dc, @posDc);<br>&nbsp; &nbsp; Inc(RectText.Left, posDc.x);<br>&nbsp; &nbsp; Inc(RectText.Top, posDc.y);<br>&nbsp; end;<br><br>&nbsp; GetTextExtentPointW(dc, Str, Count, size); {Get The Length and Height of str}<br>&nbsp; with RectText do begin<br>&nbsp; &nbsp; Right := Left + size.cx;<br>&nbsp; &nbsp; Bottom := Top + Size.cy;<br>&nbsp; end;<br><br><br><br>&nbsp; if (CommonData&lt;&gt;nil) {and false} and PtInRect(RectText, CommonData.MousePos) then begin<br>&nbsp; &nbsp; {Bug Find 2002-05-13}<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA,PChar(WideCharToString(Str)));<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := RectText;<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; GanWarning;<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, 'ERROR in ExtTextOutW');<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfExtTextOutW), 0);<br>&nbsp; end;<br>{$ENDIF}<br>last:<br>&nbsp; result := ExtTextOutW(DC, X, Y, Options, Rect, Str, Count, Dx);<br>&nbsp; InstallThunkFunc(tfExtTextOutW);<br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>{=================== &nbsp;DrawText &nbsp;==============================================}<br>function GanDrawTextA(hDC: HDC; lpString: PAnsiChar; nCount: Integer;<br>&nbsp; var lpRect: TRect; uFormat: UINT): Integer; stdcall;<br>var<br>&nbsp; RectSave : TRect;<br>&nbsp; posDcOrg : TPoint;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br><br>&nbsp; UnInstallThunkFunc(tfDrawTextA);<br>{$IFNDEF MSG_NOT_SEND}<br>&nbsp; if (CommonData&lt;&gt;nil) {and false} then begin<br>&nbsp; &nbsp; GetDcOrgEx(hDc, posDcOrg);<br>&nbsp; &nbsp; RectSave := lpRect;<br>&nbsp; &nbsp; OffsetRect(RectSave, posDcOrg.x, posDcOrg.y);<br><br>&nbsp; &nbsp; if PtInRect(RectSave, CommonData^.MousePos) then begin<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA, lpString);<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := lpRect;<br>&nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; GanWarning;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfDrawTextA), 0);<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>{$ENDIF}<br>&nbsp; result := DrawTextA(hDC, lpString, nCount, lpRect, uFormat);<br>&nbsp; InstallThunkFunc(tfDrawTextA);<br><br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>function GanDrawTextW(hDC: HDC; lpString: PWideChar; nCount: Integer;<br>&nbsp; var lpRect: TRect; uFormat: UINT): Integer; stdcall;<br>var<br>&nbsp; RectSave : TRect;<br>&nbsp; posDcOrg : TPoint;<br>begin<br>// &nbsp;EnterCriticalSection(g_CriticalSection);<br><br>&nbsp; UnInstallThunkFunc(tfDrawTextW);<br>{$IFNDEF MSG_NOT_SEND}<br>&nbsp; if (CommonData&lt;&gt;nil) {and false} then begin<br>&nbsp; &nbsp; GetDcOrgEx(hDc, posDcOrg);<br>&nbsp; &nbsp; RectSave := lpRect;<br>&nbsp; &nbsp; OffsetRect(RectSave, posDcOrg.x, posDcOrg.y);<br><br>&nbsp; &nbsp; if PtInRect(RectSave, CommonData^.MousePos) then begin<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; StrCopy(CommonData.BufferA,PChar(WideCharToString(lpString)));<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData^.Rect := lpRect;<br>&nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; GanWarning;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; SendMessage(CommonData^.CallBackHandle, idMsg, Integer(tfDrawTextW), 0);<br>&nbsp; end;<br>{$ENDIF}<br>&nbsp; result := DrawTextW(hDC, lpString, nCount, lpRect, uFormat);<br>&nbsp; InstallThunkFunc(tfDrawTextW);<br>// &nbsp;UnInstallGanFilter;<br><br>// &nbsp;LeaveCriticalSection(g_CriticalSection);<br>end;<br><br>procedure InstallGanFilter;<br>var<br>&nbsp; tfType : TThunkFunc;<br>begin<br>&nbsp; if bDllInstalled then exit;<br><br>&nbsp; for tfType := tfTextOutA to {tfExtTextOutW}tfDrawTextW do<br>&nbsp; // for tfType := LOW(TThunkFunc) to TThunkFunc(Ord(HIGH(TThunkFunc))-2) do<br>&nbsp; &nbsp; InstallThunkFunc(tfType);<br><br>&nbsp; bDllInstalled := true;<br>end;<br><br>procedure UnInstallGanFilter;<br>var<br>&nbsp; tfType : TThunkFunc;<br>begin<br>&nbsp; if not bDllInstalled then exit;<br><br>&nbsp; for tfType := tfTextOutA to {tfExtTextOutW}tfDrawTextW do<br>&nbsp; // for tfType := LOW(TThunkFunc) to TThunkFunc(Ord(HIGH(TThunkFunc))-2) do<br>&nbsp; &nbsp; UnInstallThunkFunc(tfType);<br><br>&nbsp; bDllInstalled := false;<br>end;<br><br>{================== &nbsp;=========================================================}<br>function WMCoverGetMinMaxInfo(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hWnd &nbsp; &nbsp;: THandle;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Msg &nbsp; &nbsp; : LongWord;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wParam &nbsp;: WPARAM;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lParam &nbsp;: LPARAM):BOOL;stdcall;<br>var<br>&nbsp; info : ^MINMAXINFO;<br>begin<br>&nbsp; result := BOOL(0);<br>&nbsp; info := Pointer(lParam);<br>&nbsp; info^.ptMaxSize.x := GetSystemMetrics(SM_CXFULLSCREEN);<br>&nbsp; info^.ptMaxSize.y := GetSystemMetrics(SM_CYFULLSCREEN);<br>&nbsp; info^.ptMinTrackSize.x := 0;<br>&nbsp; info^.ptMinTrackSize.y := 0;<br>&nbsp; info^.ptMaxTrackSize.x := GetSystemMetrics(SM_CXFULLSCREEN);<br>&nbsp; info^.ptMaxTrackSize.y := GetSystemMetrics(SM_CYFULLSCREEN);<br>end;<br><br>function CoverMainProc(<br>&nbsp; &nbsp; hWnd:LongWord;<br>&nbsp; &nbsp; Message:LongWord;<br>&nbsp; &nbsp; wParam:WPARAM;<br>&nbsp; &nbsp; lParam:LPARAM<br>&nbsp; &nbsp; ):BOOL;stdcall;<br>begin<br>&nbsp; case Message of<br>&nbsp; &nbsp; WM_CLOSE :<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DestroyWindow(hWnd);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// PostQuitMessage(0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; result := BOOL(DefWindowProc(hWnd, Message, lParam, lParam));<br>end;<br><br><br>procedure GanGetWordTimer(wnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal;<br>begin<br>&nbsp; SendMessage(CommonData^.hWndMouse, idMsg, 1, 0);<br>&nbsp; if (CommonData.BufferA='') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData.CallBackHandle, idMsg, 0, 2);<br>&nbsp; end;<br>&nbsp; KillTimer(CommonData^.hWndFloat, 2);<br>end;<br><br>procedure WndCoverTimer(wnd : HWND; msg, idTimer : Cardinal; dwTime : DWORD);far pascal; //CallBack Type<br>var<br>&nbsp; mouseWnd : HWnd;<br>&nbsp; szClass : PChar;<br>&nbsp; strClass : string;<br>&nbsp; iLeft, iWidth : Integer;<br>&nbsp; rect : TRect;<br>begin<br>&nbsp; if (CommonData=nil) or (not CommonData^.bCapture) then begin<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br><br>&nbsp; mouseWnd := WindowFromPoint(CommonData^.MousePos);<br>&nbsp; if (mouseWnd=CommonData^.CallBackHandle) then begin<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br>&nbsp; szClass := StrAlloc(256);<br>&nbsp; GetClassName(mouseWnd, szClass, 255);<br>&nbsp; strClass := Strpas(szClass);<br>&nbsp; StrDispose(szClass);<br><br>&nbsp; CommonData^.bInSpec := FALSE;<br><br>&nbsp; if (Pos('Internet Explorer_Server', strClass)&gt;0) then begin<br>&nbsp; &nbsp; GetWindowRect(mouseWnd, rect);<br>&nbsp; &nbsp; iLeft := rect.Left - 4;<br>&nbsp; &nbsp; iWidth := rect.Right - rect.Left + 14;<br>&nbsp; &nbsp; if (CommonData^.MousePos.x - iLeft &gt; 200) then begin<br>&nbsp; &nbsp; &nbsp; iLeft := CommonData^.MousePos.x - 200;<br>&nbsp; &nbsp; &nbsp; iWidth := 210;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; CommonData^.bInSpec := TRUE;<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; iLeft := CommonData^.MousePos.x - 1;<br>&nbsp; &nbsp; iWidth := 1;<br>&nbsp; end;<br>&nbsp; // InstallGanFilter;<br>(*<br>&nbsp; SetWindowPos(CommonData^.hWndFloat,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HWND_TOPMOST,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CommonData.MousePos.x, CommonData.MousePos.y, 10, 10,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SWP_NOACTIVATE or SWP_SHOWWINDOW);<br>&nbsp; ShowWindow(CommonData^.hWndFloat, SW_HIDE);<br>*)<br>&nbsp; CommonData^.BufferA := '';<br>&nbsp; SetWindowPos(CommonData^.hWndFloat,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HWND_TOPMOST,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iLeft{CommonData.MousePos.x-1}, CommonData.MousePos.y-1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;iWidth, 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;88{SWP_NOACTIVATE or SWP_NOREDRAW});<br><br>&nbsp; SendMessage(CommonData^.hWndMouse, idMsg, 0, 0);<br><br><br> MoveWindow(CommonData^.hWndFloat, -1, -1, 1, 1, TRUE);<br><br>&nbsp; {<br>&nbsp; SetWindowPos(CommonData^.hWndFloat,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HWND_TOPMOST,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CommonData.MousePos.x, CommonData.MousePos.y,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;120, 1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SWP_NOACTIVATE or SWP_SHOWWINDOW);<br>&nbsp; ShowWindow(CommonData^.hWndFloat, SW_HIDE);<br>&nbsp; }<br>&nbsp; SetTimer(CommonData^.hWndFloat, 2, 300, @GanGetWordTimer);<br>end;<br><br>procedure InitCoverWindow(hInst : LongWord);<br>var<br>&nbsp; WndClass : TWndClass; //Ex;<br>begin<br>&nbsp; with WndClass do begin<br>&nbsp; &nbsp; style &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= WS_EX_TOPMOST;<br>&nbsp; &nbsp; lpfnWndProc &nbsp; &nbsp; &nbsp; &nbsp;:= @CoverMainProc; &nbsp;(*消息处理函数*)<br>&nbsp; &nbsp; hInstance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= hInst;<br>&nbsp; &nbsp; hbrBackground &nbsp; &nbsp; &nbsp;:= color_btnface + 1;<br>&nbsp; &nbsp; lpszClassname &nbsp; &nbsp; &nbsp;:= 'GanFreeDict';<br>&nbsp; &nbsp; hicon &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= 0;<br>&nbsp; &nbsp; hCursor &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= 0;<br>&nbsp; &nbsp; cbClsExtra &nbsp; &nbsp; &nbsp; &nbsp; := 0;<br>&nbsp; &nbsp; cbWndExtra &nbsp; &nbsp; &nbsp; &nbsp; := 0;<br>&nbsp; end;<br><br>&nbsp; try<br>&nbsp; &nbsp; if not BOOL(RegisterClass{Ex}(WndClass)) then begin<br>&nbsp; &nbsp; &nbsp; MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PChar(Format('$EEEE, Can not register class CHILD %d',[GetLastError])),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Register Error',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);<br>&nbsp; &nbsp; end;<br>&nbsp; except<br>&nbsp; &nbsp; MessageBox(0, 'EXCEPTION', 'Register Class', MB_OK);<br>&nbsp; end;<br><br>&nbsp; hWndCover := CreateWindowEx(WS_EX_TOPMOST or WS_EX_TOOLWINDOW,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'GanFreeDict',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '^_^',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WS_POPUP or WS_VISIBLE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -1,-1,1,1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hInst, // GetModuleHandle('dll.dll'), // 98 for this, 2000 for 0<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil);<br><br>&nbsp; if CommonData&lt;&gt;nil then begin<br>&nbsp; &nbsp; CommonData^.hWndFloat := hWndCover;<br>&nbsp; end;<br>&nbsp; SetTimer(hWndCover, 1, 450, @WndCoverTimer);<br><br>end;<br>(******************************************************************************)<br>function GanServerProc(<br>&nbsp; &nbsp; hWnd:LongWord;<br>&nbsp; &nbsp; Message:LongWord;<br>&nbsp; &nbsp; wParam:WPARAM;<br>&nbsp; &nbsp; lParam:LPARAM<br>&nbsp; &nbsp; ):BOOL;stdcall;<br>begin<br>&nbsp; if (Message=idMsg) then &nbsp;begin<br>&nbsp; &nbsp; if (wParam = 0) then begin<br>&nbsp; &nbsp; &nbsp; InstallGanFilter;<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; UnInstallGanFilter;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; case Message of<br>&nbsp; &nbsp; WM_CLOSE :<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DestroyWindow(hWnd);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// PostQuitMessage(0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; result := BOOL(DefWindowProc(hWnd, Message, lParam, lParam));<br>end;<br><br><br>procedure InitServerWnd;<br>var<br>&nbsp; WndClass : TWndClass; //Ex;<br>begin<br>&nbsp;with WndClass do begin<br>&nbsp; &nbsp; style &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= WS_EX_TOPMOST;<br>&nbsp; &nbsp; lpfnWndProc &nbsp; &nbsp; &nbsp; &nbsp;:= @GanServerProc; &nbsp;(*消息处理函数*)<br>&nbsp; &nbsp; hInstance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= GetModuleHandle('GFDict.dll');<br>&nbsp; &nbsp; hbrBackground &nbsp; &nbsp; &nbsp;:= color_btnface + 1;<br>&nbsp; &nbsp; lpszClassname &nbsp; &nbsp; &nbsp;:= 'GanServerDict';<br>&nbsp; &nbsp; hicon &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= 0;<br>&nbsp; &nbsp; hCursor &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:= 0;<br>&nbsp; &nbsp; cbClsExtra &nbsp; &nbsp; &nbsp; &nbsp; := 0;<br>&nbsp; &nbsp; cbWndExtra &nbsp; &nbsp; &nbsp; &nbsp; := 0;<br>&nbsp; end;<br><br>&nbsp; try<br>&nbsp; &nbsp; if not BOOL(RegisterClass{Ex}(WndClass)) then begin<br>&nbsp; &nbsp; &nbsp; MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PChar(Format('Can not register class server %d',[GetLastError])),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Register Error',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);<br>&nbsp; &nbsp; end;<br>&nbsp; except<br>&nbsp; &nbsp; MessageBox(0, 'EXCEPTION', 'Register Server Class', MB_OK);<br>&nbsp; end;<br><br>&nbsp; hWndServer := CreateWindowEx(WS_EX_TOPMOST or WS_EX_TOOLWINDOW,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'GanServerDict',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Gan Server',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WS_POPUP or WS_VISIBLE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -1,-1,1,1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0, //hInst, // GetModuleHandle('dll.dll'), // 98 for this, 2000 for 0<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil);<br>&nbsp; if (hWndServer=0) then begin<br>&nbsp; &nbsp; MessageBeep(0);<br>&nbsp; end;<br><br>end;<br>(******************************************************************************)<br><br>procedure InitThunkCode;<br>var<br>&nbsp; tfType : TThunkFunc;<br>&nbsp; hMod : HMODULE;<br>&nbsp; pSysFunc, pThunkFunc : Pointer;<br>begin<br>&nbsp; for tfType := LOW(TThunkFunc) to HIGH(TThunkFunc) do begin<br>&nbsp; &nbsp; // clear to zero<br>&nbsp; &nbsp; FillChar(ThunkCodeArr[tfType], sizeof(TThunkCode), 0);<br><br>&nbsp; &nbsp; // fill it by right value<br>&nbsp; &nbsp; hMod := 0;<br>&nbsp; &nbsp; hMod := GetModuleHandle(PChar(ThunkFuncNameArr[tfType].strMod));<br>&nbsp; &nbsp; if hMod = 0 then continue;<br><br>&nbsp; &nbsp; pSysFunc := nil;<br>&nbsp; &nbsp; pSysFunc := GetProcAddress(hMod,<br>&nbsp; &nbsp; &nbsp; PChar(ThunkFuncNameArr[tfType].strSysProc));<br>&nbsp; &nbsp; if pSysFunc = nil then continue;<br><br>&nbsp; &nbsp; pThunkFunc := nil;<br>&nbsp; &nbsp; pThunkFunc := GetProcAddress(hInstance,<br>&nbsp; &nbsp; &nbsp; PChar(ThunkFuncNameArr[tfType].strThunkProc));<br>&nbsp; &nbsp; if pThunkFunc = nil then continue;<br><br>&nbsp; &nbsp; // now fill it!<br>&nbsp; &nbsp; ThunkCodeArr[tfType].addr_sys := pSysFunc;<br>&nbsp; &nbsp; ThunkCodeArr[tfType].addr_thunk := pThunkFunc;<br><br>&nbsp; &nbsp; ThunkCodeArr[tfType].codeThunk.siJmp := ShortInt($E9); &nbsp;// jmp ____<br>&nbsp; &nbsp; ThunkCodeArr[tfType].codeThunk.dwAddr :=<br>&nbsp; &nbsp; &nbsp; DWORD(pThunkFunc) - DWORD(pSysFunc) - 5;<br><br>&nbsp; &nbsp; ThunkCodeArr[tfType].codeBak.siJmp := PByte(pSysFunc)^;<br>&nbsp; &nbsp; ThunkCodeArr[tfType].codeBak.dwAddr := PDWORD(DWORD(pSysFunc)+1)^;<br>&nbsp; end;<br>end;<br><br>{================== &nbsp;Install Mouse Hook Support ==============================}<br>function MousePosHookHandler(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;<br>var<br>&nbsp; pMouse : PMOUSEHOOKSTRUCT;<br>&nbsp; mPoint : TPoint;<br>&nbsp; rect : TRect;<br>&nbsp; bMousePosChg : boolean;<br>begin<br>&nbsp; if iCode &lt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>&nbsp; end<br>&nbsp; else<br>&nbsp; if (CommonData&lt;&gt;nil) and<br>&nbsp; &nbsp; (CommonData^.bCapture) and<br>&nbsp; &nbsp; (TryEnterCriticalSection(m_CriticalSection))<br>&nbsp; then begin<br><br>{$IFDEF WIN_9X}<br>&nbsp; &nbsp; if bFirst then begin<br>&nbsp; &nbsp; &nbsp; bFirst := false;<br>&nbsp; &nbsp; &nbsp; // InstallGanFilter;<br>&nbsp; &nbsp; &nbsp; InitCoverWindow;<br>&nbsp; &nbsp; end;<br>{$ENDIF}<br><br>&nbsp; &nbsp; pMouse := PMOUSEHOOKSTRUCT(lParam);<br><br>&nbsp; &nbsp; if (CommonData&lt;&gt;nil) then begin<br>&nbsp; &nbsp; &nbsp; CommonData.MousePos := pMouse.pt;<br>&nbsp; &nbsp; &nbsp; CommonData.hWndCapture := pMouse.hWnd;<br>&nbsp; &nbsp; &nbsp; PostMessage(CommonData.CallBackHandle, idMsg, 0, 1);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if (GetCurrentProcessID &lt;&gt; CommonData^.CallBackProcID) then begin<br>&nbsp; &nbsp; &nbsp; CommonData^.hWndMouse := hWndServer;<br><br>&nbsp; &nbsp; &nbsp; mPoint := pMouse^.pt;<br>&nbsp; &nbsp; &nbsp; ScreenToClient(pMouse^.hwnd, mPoint);<br>&nbsp; &nbsp; &nbsp; if Assigned(CommonData) then<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData.MousePClient := mPoint;<br>&nbsp; &nbsp; end<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; CommonData^.hWndMouse := 0;<br><br>&nbsp; &nbsp; end;<br>(*<br>&nbsp; &nbsp; if (pMouse.pt.x = LastMousePos.x) and (pMouse.pt.y = LastMousePos.y) then<br>&nbsp; &nbsp; &nbsp; bMousePosChg := false<br>&nbsp; &nbsp; else begin<br>&nbsp; &nbsp; &nbsp; bMousePosChg := true;<br>&nbsp; &nbsp; &nbsp; LastMousePos := pMouse.pt;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if (wParam = WM_MOUSEMOVE)<br>&nbsp; &nbsp; &nbsp; and true<br>{$IFDEF WIN_9X}<br>&nbsp; &nbsp; &nbsp; and (hWndCover &lt;&gt; 0)<br>{$ENDIF}<br>&nbsp; &nbsp; &nbsp; and bMousePosChg<br>&nbsp; &nbsp; &nbsp; and (not b_InCS)<br>&nbsp; &nbsp; &nbsp; and (GetTickCount - LastTime &gt; G_DELAY_TIME) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; LastTime := GetTickCount;<br><br>&nbsp; &nbsp; &nbsp; // whether in my window<br>&nbsp; &nbsp; &nbsp; if (CommonData&lt;&gt;nil) and<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(GetCurrentProcessID = CommonData^.CallBackProcID) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; result := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; LeaveCriticalSection(m_CriticalSection);<br>&nbsp; &nbsp; &nbsp; &nbsp; result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; mPoint := pMouse^.pt;<br>&nbsp; &nbsp; &nbsp; ScreenToClient(pMouse^.hwnd, mPoint);<br>&nbsp; &nbsp; &nbsp; if Assigned(CommonData) then<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData.MousePClient := mPoint;<br><br>&nbsp; &nbsp; &nbsp; rect.TopLeft := mPoint;<br>&nbsp; &nbsp; &nbsp; rect.Right := mPoint.x + 2;<br>&nbsp; &nbsp; &nbsp; rect.Bottom := mPoint.y + 1;<br>&nbsp; &nbsp; &nbsp; // Work for NT 2000 XP<br>{$IFDEF WIN_NT}<br>&nbsp; &nbsp; &nbsp; InstallGanFilter;<br><br>&nbsp; &nbsp; &nbsp; if Assigned(CommonData) then<br>&nbsp; &nbsp; &nbsp; &nbsp; CommonData.BufferA := '';<br><br>&nbsp; &nbsp; &nbsp; InvalidateRect(pMouse^.hWnd, @rect, TRUE);<br>&nbsp; &nbsp; &nbsp; if (mPoint.X&lt;0) or (mPoint.Y&lt;0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(pMouse.hwnd, WM_NCPAINT, 1, 0)<br>&nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(pMouse.hwnd, WM_PAINT, 0, 0);<br><br>&nbsp; &nbsp; &nbsp; UninstallGanFilter;<br>&nbsp; &nbsp; &nbsp; if Assigned(CommonData) and (CommonData.BufferA='') then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; SendMessage(CommonData.CallBackHandle, idMsg, 0, 2);<br>&nbsp; &nbsp; &nbsp; end;<br>{$ENDIF}<br>&nbsp; &nbsp; &nbsp; // flowing work on 98<br>{$IFDEF WIN_9X}<br>&nbsp; &nbsp; &nbsp; if (hWndCover &lt;&gt; 0) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; SetWindowPos(hWndCover, 0, pMouse.pt.X, pMouse.pt.Y, 4, 1,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SWP_NOZORDER or SWP_NOACTIVATE);<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(hWndCover, SW_SHOW);<br><br>// &nbsp; &nbsp; &nbsp; &nbsp;EnterCriticalSection(m_CriticalSection);<br><br>&nbsp; &nbsp; &nbsp; &nbsp; InstallGanFilter;<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(hWndCover, SW_HIDE);<br><br>// &nbsp; &nbsp; &nbsp; &nbsp;LeaveCriticalSection(m_CriticalSection);<br>&nbsp; &nbsp; &nbsp; end;<br>{$ENDIF}<br>&nbsp; &nbsp; end;<br>*)<br>&nbsp; &nbsp; LeaveCriticalSection(m_CriticalSection);<br>&nbsp; &nbsp; Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; Result := CallNextHookEx(hNextHookProc, iCode, wParam, lParam);<br>&nbsp; end;<br>end;<br><br>function EnableMouseHook(hld:hwnd; ProcessID : DWORD; hInst:THandle): BOOL; export;<br>begin<br>&nbsp; Result := False;<br>&nbsp; if hNextHookProc &lt;&gt; 0 then Exit;<br><br>&nbsp; hNextHookProc := SetWindowsHookEx(WH_MOUSE, MousePosHookHandler,Hinstance, 0);<br>// &nbsp; &nbsp;GetWindowThreadProcessID(hWnd, nil));<br><br>&nbsp; InitCoverWindow(hInst);<br>&nbsp; if CommonData &lt;&gt; nil then begin<br>&nbsp; &nbsp; CommonData^.CallBackHandle := hld;<br>&nbsp; &nbsp; CommonData^.CallBackProcID := ProcessID;<br>&nbsp; end;<br>&nbsp; Result :=hNextHookProc &lt;&gt; 0 ;<br>end;<br><br>function DisableMouseHook: BOOL; export;<br>begin<br>try<br>&nbsp; if hNextHookProc &lt;&gt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; KillTimer(CommonData^.hWndFloat, 1);<br>&nbsp; &nbsp; KillTimer(CommonData^.hWndFloat, 2);<br>&nbsp; &nbsp; SendMessage(CommonData^.hWndFloat, WM_CLOSE, 0, 0);<br>&nbsp; &nbsp; CommonData^.hWndFloat := 0;<br><br>&nbsp; &nbsp; UnInstallGanFilter;<br>&nbsp; &nbsp; UnhookWindowshookEx(hNextHookProc);<br>&nbsp; &nbsp; hNextHookProc := 0;<br>&nbsp; end;<br>&nbsp; Result := hNextHookProc = 0;<br>except<br>&nbsp; MessageBeep(0);<br>end;<br>end;<br><br>function SetCaptureFlag(bSet:BOOL):BOOL; export;<br>begin<br>&nbsp; if CommonData&lt;&gt;nil then begin<br>&nbsp; &nbsp; result := TRUE;<br>&nbsp; &nbsp; CommonData^.bCapture := bSet;<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; result := FALSE;<br>&nbsp; end;<br>end;<br><br>procedure DllMain(dwReason : DWORD);<br>begin<br>&nbsp; case dwReason of<br>&nbsp; &nbsp; DLL_PROCESS_ATTACH :<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; // InstallGanFilter;<br>&nbsp; &nbsp; &nbsp; &nbsp; // InitCoverWindow;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; DLL_PROCESS_DETACH :<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if (hWndServer &lt;&gt; 0) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SendMessage(hWndServer, WM_CLOSE, 0, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hWndServer := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnRegisterClass('GanServerDict', hInstance);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBeep(0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; UnInstallGanFilter;<br>&nbsp; &nbsp; &nbsp; &nbsp; if CommonData&lt;&gt;nil then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnMapViewOfFile(CommonData);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommonData := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(HMapFile);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HMapFile := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Error when free MapViewFile',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'FreeDict Error',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>(*<br>&nbsp; &nbsp; &nbsp; &nbsp; if (hWndCover &lt;&gt; 0) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestroyWindow(hWndCover);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hWndCover := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (UnRegisterClass('GanFreeDict', hInstance)) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Success to Unregister _GanFreeDict_ Class',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Success',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);}<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Error when Destroy window and UnRegisterClass',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'FreeDict Error',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>*)<br><br>&nbsp; &nbsp; &nbsp; &nbsp; if hProc&lt;&gt;0 then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(hProc);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hProc := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'Error when CloseHandle',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'FreeDict Error',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MB_OK);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; DeleteCriticalSection(g_CriticalSection);<br>&nbsp; &nbsp; &nbsp; &nbsp; DeleteCriticalSection(m_CriticalSection);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; DLL_THREAD_ATTACH :<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; DLL_THREAD_DETACH :<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>exports<br>&nbsp; EnableMouseHook,<br>&nbsp; DisableMouseHook,<br>&nbsp; GanTextOutA,<br>&nbsp; GanTextOutW,<br>&nbsp; GanExtTextOutA,<br>&nbsp; GanExtTextOutW,<br>&nbsp; GanDrawTextA,<br>&nbsp; GanDrawTextW,<br>&nbsp; SetCaptureFlag;<br><br>begin<br>&nbsp; InitializeCriticalSection(g_CriticalSection);<br>&nbsp; InitializeCriticalSection(m_CriticalSection);<br>&nbsp; b_InCS := false;<br>&nbsp; hNextHookProc := 0;<br>&nbsp; hProc := 0;<br>&nbsp; bFirst := true;<br>&nbsp; bDllInstalled := false;<br>&nbsp; hWndCover := 0;<br>&nbsp; hWndServer := 0;<br>&nbsp; CommonData := nil;<br>&nbsp; HMapFile := 0;<br>&nbsp; LastTime := 0;<br>&nbsp; FillChar(LastMousePos, sizeof(TPoint), 0);<br>&nbsp; idMsg := RegisterWindowMessage(STR_MSGNOTIFY);<br><br>&nbsp; MapCommonData;<br><br>&nbsp; hProc := OpenProcess(PROCESS_ALL_ACCESS,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FALSE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GetCurrentProcessID());<br>&nbsp; InitThunkCode;<br>&nbsp; InitServerWnd;<br>&nbsp; // InitCoverWindow;<br><br>&nbsp; // DisableThreadLibraryCalls(hInstance);<br><br>&nbsp; DLLProc := @DLLMain;<br>&nbsp; DLLMain(DLL_PROCESS_ATTACH);<br>end.<br><br><br><br><br>(*******************************************************************************<br>* Copy Right (C) Gan Huaxin 2001, 2002, huiyugan@263.net<br>* A Free Screen Words Capture Library<br>* &nbsp; Dedicated to my GirlFriend Sunny, Happy for ever<br>* <br>* Version &nbsp; &nbsp; &nbsp; &nbsp; Date &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Modification<br>* &nbsp; 0.1 &nbsp; &nbsp; &nbsp; 2001-11-07~09 &nbsp; &nbsp; &nbsp; New, oly a test<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Can Get Word, Sometimes occure error<br>* &nbsp; 0.2 &nbsp; &nbsp; &nbsp; 2002-05-14~16 &nbsp; &nbsp; &nbsp; Some Bugs Fixed,And<br>*******************************************************************************)<br>unit untTypes;<br><br>interface<br><br>uses<br>&nbsp; Windows;<br><br>type<br>&nbsp; TCommonData = record<br>&nbsp; &nbsp; bCapture : BOOL;<br>&nbsp; &nbsp; bInSpec : BOOL;<br>&nbsp; &nbsp; CallBackHandle:HWnd;<br>&nbsp; &nbsp; CallBackProcID : DWORD;<br>&nbsp; &nbsp; hWndFloat : HWnd; (*浮动窗口的句柄*)<br>&nbsp; &nbsp; hWndMouse : HWnd; (*鼠标所在窗口server的句柄*)<br>&nbsp; &nbsp; hWndCapture : HWnd; (*当前鼠标所在的窗口*)<br>&nbsp; &nbsp; MousePos &nbsp;: TPoint; (*当前鼠标屏幕坐标*)<br>&nbsp; &nbsp; MousePClient : TPoint; (*鼠标所在窗口的坐标*)<br>&nbsp; &nbsp; Rect : TRect;<br>&nbsp; &nbsp; case integer of<br>&nbsp; &nbsp; &nbsp; 0 : (BufferA : array [0..1023] of Char);<br>&nbsp; &nbsp; &nbsp; 1 : (BufferW : array [0..511] of WideChar);<br>&nbsp; end;<br><br><br>&nbsp; PCommonData = ^TCommonData;<br><br>&nbsp; TCode5 = packed record<br>&nbsp; &nbsp; siJmp : ShortInt;<br>&nbsp; &nbsp; dwAddr : DWORD;<br>&nbsp; end;<br><br>&nbsp; TThunkFunc = (tfTextOutA, &nbsp; &nbsp; &nbsp; tfTextOutW,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tfExtTextOutA, &nbsp; &nbsp;tfExtTextOutW,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tfDrawTextA, &nbsp; &nbsp; &nbsp;tfDrawTextW);<br><br>&nbsp; TThunkFuncName = packed record<br>&nbsp; &nbsp; strMod &nbsp; &nbsp; &nbsp; &nbsp;: string; &nbsp;// 系统模块名称<br>&nbsp; &nbsp; strSysProc &nbsp; &nbsp;: string; &nbsp;// 系统DLL中的名字<br>&nbsp; &nbsp; strThunkProc &nbsp;: string; &nbsp;// 你替换的函数的名字,必须在DLL的引出表中<br>&nbsp; end;<br><br>&nbsp; TThunkCode = packed record<br>&nbsp; &nbsp; codeBak &nbsp; &nbsp; &nbsp; : TCode5; &nbsp;// 系统函数的代码的前5个字节<br>&nbsp; &nbsp; codeThunk &nbsp; &nbsp; : TCode5; &nbsp;// 跳转到你的代码的5个字节<br>&nbsp; &nbsp; addr_sys &nbsp; &nbsp; &nbsp;: Pointer; // 系统函数的地址<br>&nbsp; &nbsp; addr_thunk &nbsp; &nbsp;: Pointer; // 替换函数的地址<br>&nbsp; &nbsp; bInstalled &nbsp; &nbsp;: boolean; // 安装了吗?<br>&nbsp; end;<br><br>const<br>&nbsp; G_DELAY_TIME = 100;<br><br>const<br>&nbsp; ThunkFuncNameArr : array[TThunkFunc] of TThunkFuncName = (<br>&nbsp; &nbsp; (strMod : 'gdi32.dll'; &nbsp;strSysProc : 'TextOutA'; &nbsp; &nbsp;strThunkProc : 'GanTextOutA'),<br>&nbsp; &nbsp; (strMod : 'gdi32.dll'; &nbsp;strSysProc : 'TextOutW'; &nbsp; &nbsp;strThunkProc : 'GanTextOutW'),<br>&nbsp; &nbsp; (strMod : 'gdi32.dll'; &nbsp;strSysProc : 'ExtTextOutA'; strThunkProc : 'GanExtTextOutA'),<br>&nbsp; &nbsp; (strMod : 'gdi32.dll'; &nbsp;strSysProc : 'ExtTextOutW'; strThunkProc : 'GanExtTextOutW'),<br>&nbsp; &nbsp; (strMod : 'user32.dll'; strSysProc : 'DrawTextA'; &nbsp; strThunkProc : 'GanDrawTextA'),<br>&nbsp; &nbsp; (strMod : 'user32.dll'; strSysProc : 'DrawTextW'; &nbsp; strThunkProc : 'GanDrawTextW')<br>&nbsp; );<br><br><br>implementation<br><br>end.<br><br><br><br>//单元untMain.pas的代码,窗体设置见下<br>(*******************************************************************************<br>* Copy Right (C) Gan Huaxin 2001, 2002, huiyugan@263.net<br>* A Free Screen Words Capture Library<br>* &nbsp; Dedicated to my GirlFriend Sunny, Happy for ever<br>*<br>* Version &nbsp; &nbsp; &nbsp; &nbsp; Date &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Modification<br>* &nbsp; 0.1 &nbsp; &nbsp; &nbsp; 2001-11-07~09 &nbsp; &nbsp; &nbsp; New, oly a test<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Can Get Word, Sometimes occure error<br>* &nbsp; 0.2 &nbsp; &nbsp; &nbsp; 2002-05-14~16 &nbsp; &nbsp; &nbsp; Some Bugs Fixed,And<br>*******************************************************************************)<br>unit untMain;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, untTypes;<br><br>type<br>&nbsp; TfrmGanDict = class(TForm)<br>&nbsp; &nbsp; btnLoad: TButton;<br>&nbsp; &nbsp; btnUnLoad: TButton;<br>&nbsp; &nbsp; lblHwnd: TLabel;<br>&nbsp; &nbsp; btnAbout: TButton;<br>&nbsp; &nbsp; lblMousePos: TLabel;<br>&nbsp; &nbsp; memoThunk: TMemo;<br>&nbsp; &nbsp; lblFontWidth: TLabel;<br>&nbsp; &nbsp; lblRect: TLabel;<br>&nbsp; &nbsp; procedure btnLoadClick(Sender: TObject);<br>&nbsp; &nbsp; procedure btnUnLoadClick(Sender: TObject);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; procedure WndProc(var Mess: TMessage); override;<br>&nbsp; end;<br><br>var<br>&nbsp; frmGanDict: TfrmGanDict;<br><br>implementation<br><br>uses untAbout;<br><br>{$R *.DFM}<br><br>var<br>&nbsp; HMapFile:THandle;<br>&nbsp; CommonData:^TCommonData;<br><br><br>const<br>&nbsp; STR_MSGNOTIFY:pchar='WM_GANNOTIFY';<br>var<br>&nbsp; idMsg : UINT;<br><br>function EnableMouseHook(hld:hwnd; ProcessID : DWORD; hInst : THandle): BOOL; external 'GFDict.dll';<br>function DisableMouseHook: BOOL; external 'GFDict.dll';<br>function SetCaptureFlag(bFlag:BOOL): BOOL; external 'GFDict.dll';<br><br>procedure MapCommonData;<br>var FirstCall: Boolean;<br>begin<br>&nbsp; HMapFile:=OpenFileMapping(FILE_MAP_WRITE, False, 'GanGan_ThunkDict');<br>&nbsp; FirstCall:=(HMapFile = 0);<br>&nbsp; if FirstCall then<br>&nbsp; &nbsp; HMapFile:=CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,SizeOf(TCommonData),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'GanGan_ThunkDict');<br>&nbsp; CommonData:= MapViewOfFile(HMapFile, FILE_MAP_WRITE, 0, 0, 0);<br>&nbsp; if FirstCall then FillChar(CommonData^, SizeOf(TCommonData), 0);<br>end;<br><br>procedure TfrmGanDict.btnLoadClick(Sender: TObject);<br>begin<br>&nbsp; if not EnableMouseHook(handle, GetCurrentProcessID, Application.Handle) then<br>&nbsp; &nbsp; ShowMessage('ERROR')<br>&nbsp; else<br>&nbsp; &nbsp; SetCaptureFlag(TRUE);<br>end;<br><br>procedure TfrmGanDict.btnUnLoadClick(Sender: TObject);<br>begin<br>&nbsp; DisableMouseHook;<br>end;<br><br>procedure TfrmGanDict.FormDestroy(Sender: TObject);<br>begin<br>&nbsp; DisableMouseHook;<br>&nbsp; if CommonData&lt;&gt;nil then begin<br>&nbsp; &nbsp; UnMapViewOfFile(CommonData);<br>&nbsp; &nbsp; CommonData := nil;<br>&nbsp; &nbsp; CloseHandle(HMapFile);<br>&nbsp; &nbsp; HMapFile := 0;<br>&nbsp; end;<br>end;<br><br>procedure TfrmGanDict.FormCreate(Sender: TObject);<br>begin<br>&nbsp; idMsg := RegisterWindowMessage(STR_MSGNOTIFY);<br>&nbsp; CommonData := nil;<br>&nbsp; MapCommonData;<br>&nbsp; SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SWP_NOSIZE or SWP_NOMOVE);<br>end;<br><br>const<br>&nbsp; StrProcNames : array[0..5] of String =<br>&nbsp; &nbsp; ('TextOutA',<br>&nbsp; &nbsp; &nbsp;'TextOutW',<br>&nbsp; &nbsp; &nbsp;'ExtTextOutA',<br>&nbsp; &nbsp; &nbsp;'ExtTextOutW',<br>&nbsp; &nbsp; &nbsp;'DrawTextA',<br>&nbsp; &nbsp; &nbsp;'DrawTextW');<br>procedure TfrmGanDict.WndProc(var Mess: TMessage);<br>begin<br>&nbsp; case Mess.LParam of<br>&nbsp; &nbsp; 0:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if (mess.msg = idMsg) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Mess.wParam &gt;=0) and (Mess.WParam &lt;= 5) then begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lblHwnd.Caption := StrProcNames[mess.wParam]; //Format('Handle : 0x%X', [mess.wParam]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if CommonData &lt;&gt; nil then with CommonData^ do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memoThunk.Text := CommonData.BufferA;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lblRect.Caption := Format('Client X:%d, Y:%d, Rect[%d,%d,%d,%d]',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [MousePClient.x, MousePClient.y,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rect.Left, Rect.Top, Rect.Right, Rect.Bottom]);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // lblThunkText.Caption := CommonData.BufferA;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lblHwnd.Caption := 'UnKnow Message';<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; 1:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if CommonData&lt;&gt;nil then with CommonData^ do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lblMousePos.Caption := Format('Mouse Pos X : %d, Y : %d',<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [MousePos.X,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MousePos.Y]);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; 2:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; memoThunk.Text := '---';<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; 3:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; lblFontWidth.Caption := Format('Font Width : %d', [mess.wParam]);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>&nbsp; inherited;<br>end;<br><br>end.
 
谢谢tandxu:你贴出来的这个是鼠标屏幕取词的代码吧........<br>&nbsp; 我想处理的是.....开始设置的时候设置下要取的对象,,,,之后不用鼠标停留在上面也能同步显示
 
后退
顶部