HTSpy (HitTester) by kero

v.2008-01-19 (init: 2007-07-06)

http://geocities.com/xmemor/2lz/tinyasm.html
("Tiny apps + sources (masm32)")

Tested on xp-pro-sp2
------
This educational utility is my comment to "WM_NCHITTEST Notification" and some other MSDN articles.
------
(Hookless)
------

[HTSpy info panel] :

Line 1:
  hw    - current/selected window
  id=hm - control ID / hMenu
  p/tid - PID/TID
Line 2:
  "ClassName"/"RealWindowClass" (if "RealWindowClass" != "ClassName")
  "ExeFile" (name only, without path)
Line 3:
  "WindowText"
Line 4:
  "+" if RectVisible(GetWindowRect)!=0, else "-"  // + note below about WS_EX_LAYERED
  rt [...] - WindowRect [left,top,width*height]
  w-cl [...] - WindowRect-ClientRect relative difference [d(left),d(top),d(right),d(bottom)]
  [* region] - type of current/selected window region
Line 5:
  "+" if PtVisible!=0, else "-"
  "+" if PtInRect(GetWindowRect)!=0, else "-"
  "+" if PtInRegion(GetWindowRgn)!=0, "-" if PtInRegion==0, "." if window region not exist
  pt - current point under cursor in screen coordinates as (x,y)
  lp - pt as lParam for WM_NC*
  dco - DcOrgEx of current/selected window // compare WS_EX_LAYERED+SetLayeredWindowAttributes & WS_EX_LAYERED+UpdateLayeredWindow (+ keep in mind WS_EX_COMPOSITED)
Line 6:
  <dis> , if window or its ancestor is disabled, else - empty field
  dwp/sm [*/*] - result of WM_NCHITTEST via DefWindowProc / via SendMessage
Line 7: 
  (empty, if "lock" checkbox isn't checked)
  "dwp" - via DefWindowProc (after Shift), "sm" - via SendMessage (after Ctrl)
  HT <number> - selected HT-region
  [...] - bounding rectangle of selected HT-region, [left,top,width*height]
  [* region] - type of selected HT-region


[USAGE]

Drag HTSpy window: also via "HTCAPTION"/"setcursor"/"mousemove"/"lbuttondown" rectangles.

Resize/Move "-3...22" rectangle: hit scrollbar arrows.

Resize/Move "setcursor/mousemove/lbuttondown" rectangle: press+hold Ctrl key and hit scrollbar arrows.

Resize info panel with help of mouse.

Close HTSpy: also via double-click to "HTSYSMENU" rectangle.


If "lock" is unchecked :

  Fix target window: place cursor over target window  + F8 ("lock" becomes checked).

  Fix root window of target window: place cursor over target window, press+hold  Ctrl key  + F8 ("lock" becomes checked).


If "lock" is checked :

  You can create popup-"copy" (with 1-pixel-"chess"-patternbrush) of selected HT region of target window
    -  if HT value isn't standard (i.e <-2 or >21)  -  via "sm" :  place cursor over this HT region  + F8.
    -  else  -  via "dwp"("sm") :  place cursor over corresponding HT-rectangle of HTSpy  + Shift (Ctrl).

  Grab menu of window_with_menu to target window (=> create HTMENU) :  place cursor over window_with_menu  + F9.


  For ws_/ws_ex_(/cs_) checkboxes:
    Left-click  ->   trigger, set/clear corresponding bit for target window  on-fly.

  If checkbox has mark "*"   =>  use Right-click also,  "**"  =>  use Right-click and Middle-click also.

  "ws_disabled *": 
    Right-click  ->  trigger  EnableWindow (TRUE/FALSE) to target window

  "ws_visible **": 
    Right-click  ->  trigger  ShowWindow (SW_HIDE/SW_SHOWNORMAL)
    Middle-click ->  trigger  ShowWindowAsync (SW_HIDE/SW_SHOWNORMAL)

  "ws_maximize **": 
    Right-click  ->  trigger  ShowWindow (SW_MAXIMIZE/SW_RESTORE)
    Middle-click ->  trigger  ShowWindowAsync (SW_MAXIMIZE/SW_RESTORE)

  "ws_minimize **": 
    Right-click  ->  trigger  ShowWindow (SW_MINIMIZE/SW_RESTORE)
    Middle-click ->  trigger  ShowWindowAsync (SW_MINIMIZE/SW_RESTORE)

  "ws_ex_toolwindow *": 
    Right-click  ->  SW_HIDE, trigger +/- WS_EX_TOOLWINDOW, SW_SHOWNORMAL  // => for Taskbar (mind WS_EX_APPWINDOW also)

  "ws_ex_layered **": 
    Right-click  ->  trigger  (- WS_EX_LAYERED / + WS_EX_LAYERED + SetLayeredWindowAttributes)
    Middle-click ->  trigger  (- WS_EX_LAYERED) / + WS_EX_LAYERED + UpdateLayeredWindow)

  "cs_dropshadow *": 
    Right-click  ->  SW_HIDE, trigger  +/- CS_DROPSHADOW, SW_SHOWNORMAL


  "cs_ime * <<": 
    Right-click  ->  trigger  +/- CS_IME  + HTSpy window RECREATION (with last WindowRect and last WS/WS_EX/CS styles)

  "timer *":
    On/Off timer  (useful for simultaneous using some exemplars of HTSpy)

  For "timer *" & "lock *" -  right-click = left-click, for "ht-drag **" & "sc-drag **" - plus  = middle-click.


CUSTOMISER 
  For selected (unchecked "lock") or fixed (checked "lock") window:
  if "ht-drag" checkbox is checked :  
    move <resize> with help of Left/Middle <Right> mouse button  // via DefWindowProc (WM_NCLBUTTONDOWN, HTCAPTION <HTBOTTOMRIGHT>)
  if "sc-drag" checkbox is checked :  
    move (resize} with help of Left/Middle <Right> mouse button  // via PostMessage (WM_SYSCOMMAND, SC_SIZE+9 <SC_SIZE+8>)


COMBOBOX
  1) Restoration initial Id/hMenu of control/top-level-window
    Fix target window (via cursor+F8 or via string in combo with it's hWnd),
    restore initial window's styles, + right-click to button of combo/

  2) Other way to fix window: input hWnd as string in HEX-format (exactly 8 symbols) to edit of combobox.

  3) Load Z-ordered list of all existing windows ( +message-only): middle-click (or pressed Ctrl key + left-click) to button of combo.

------
WM_SETCURSOR "cancels" EnableWindow !
Even if HTSpy window is disabled (WS_DISABLED) - you can 
1) resize info panel,
2) Right/Middle-click  */**-marked checboxes.
------
If target top-level window is disabled (WS_DISABLED) =>  result of extern WM_NCHITTEST via dwp/sm  isn't right !
Interior WM_NCHITTEST is blocked in this case, and real HT-area is HTERROR (see lParam of WM_SETCURSOR).
------
Missing details - find in source.