Implement findwindow tool highlighting of spy ++

Source: Internet
Author: User
Method 1 of implementing the findwindow tool highlighted (highlight) of an application's form or internal object:
Implementation through SelectObject
 
Procedure inverttracker (hwnddest: hwnd );
// Draw a border
VaR
Hdcdest: hwnd;
Hpen: hwnd;
Holdpen: hwnd;
Holdbrush: hwnd;
Cr: hwnd;
RC: trect;
Begin
Getwindowrect (hwnddest, RC );
Hdcdest: = getwindowdc (hwnddest );
Setrop2 (hdcdest, r2_not );
Cr: = clblack;
Hpen: = createpen (ps_insideframe, 2, Cr );
 
Holdpen: = SelectObject (hdcdest, Hpen );
Holdbrush: = SelectObject (hdcdest, getstockobject (null_brush ));
Rectangle (hdcdest, 0, 0, RC. Right-RC. Left, RC. Bottom-RC. Top );
SelectObject (hdcdest, holdbrush );
SelectObject (hdcdest, holdpen );
 
Releasedc (hwnddest, hdcdest );
Deleteobject (Hpen );
End;
 
 
Method 2:
Reversed the border area color
 
Procedure highlightwindow (hwndwindow: hwnd );
VaR hdcwindow: HDC;
Rect: trect;
Dinv: integer;
Begin
If (hwndwindow = 0) or (not iswindow (hwndwindow) then
Exit
Else begin
Hdcwindow: = getwindowdc (hwndwindow );
Windows. getwindowrect (hwndwindow, rect );
Offsetrect (rect,-rect. Left,-rect. Top );
 
Dinv: = 4;
If not isrectempty (rect) then
Begin
Patblt (hdcwindow, rect. Left, rect. Top, rect. Right-rect. Left, dinv, dstinvert );
Patblt (hdcwindow, rect. Left, rect. Bottom-dinv, dinv,
-(Rect. Bottom-rect. Top-2 * dinv), dstinvert );
Patblt (hdcwindow, rect. Right-dinv, rect. Top + dinv, dinv,
Rect. Bottom-rect. Top-2 * dinv, dstinvert );
Patblt (hdcwindow, rect. Right, rect. Bottom-dinv,-(rect. Right-rect. Left ),
Dinv, dstinvert );
End;
Releasedc (hwndwindow, hdcwindow );
End;
End;
 
However, neither of these two functions can achieve the highlighted special form,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.