Click here to Skip to main content
15,861,172 members
Articles / Desktop Programming / MFC
Article

MiniSpy

Rate me:
Please Sign up or sign in to vote.
4.96/5 (26 votes)
27 Jul 20023 min read 253.2K   6.9K   98   37
A dynamic window attribute viewer to replace Spy++

Sample Image - MiniSpy.jpg

Introduction

(Rev 2.0)

I often use Spy++ to track window messages but have rarely used it to look at the attributes of a window.

When i have used it, I've found using the finder tool to be a really awkward device because it presents a static interface to what i find to be a much more dynamic activity.

I decided therefore to see if I could devise an alternative interface which would allow me to look at a window's attributes with the minimum of fuss and bother.

The result is MiniSpy.

There's nothing very special about it, but it does provide the following features:

  • All attributes are visible in one pane
  • Dynamically updates as you drag it around
  • Displays control specific styles for all of the standard windows and common controls separately to the standard window styles.
  • Provides a filter drop-down so that if you have registered you own window class and it is based on a standard control class you can manually select the base window class to see the control styles
  • 'Refresh' button for refreshing the current window's attributes
  • Provides tooltips to view long rows

History

New Features (2.0)

  • 'Lock Updates' button/shortcut to prevent updating of the picked window as you move MiniSpy.
  • Buttons/shortcuts to navigate to parent window, first child windows, next/previous windows (note: these buttons will automatically lock updates to prevent the new window being immediately overridden).
  • Vertical toolbar so that all buttons are visible.
  • Manual implementation of RealWindowFromPoint() for win95 (see bug fixes (1.2) below).
  • Addition of control styles for tooltips_class32.

Bug Fixes (2.0)

  • Missing Menu (#32768), Desktop (#32769), Icon Title (#32772), tooltips_class32, Task Switcher (#32771) classnames added to filter combobox.

New Features (1.2)

  • Show the 'hittest' result returned by the window in response to a WM_NCHITTEST message

Bug Fixes (1.2)

  • Correctly pick windows contained by a group box. Thanks to Philippe Lhoste (PhiLho@GMX.net)

    Previously, MiniSpy used the method ::WindowFromPoint() to pick the window. However, as Philippe pointed out this does not always work with controls within group boxes, specifically when the controls are behind the group box in the z-order.

    To solve this I have extended the window picking to also use ::RealChildWindowFromPoint() once the initial pick is done. The documentation for this function effectively states that it ignores windows which return HTTRANSPARENT to a WM_NCHITTEST message, which group boxes do.

    This solves the problem except for nested group boxes which are ignored by ::RealChildWindowFromPoint because they too return HTTRANSPARENT.

    The docs also indicated that ::RealChildWindowFromPoint() is not supported on windows 95 which is why I have linked to it dynamically.

New Features (1.1)

  • Can use any one of its corners to pick the windows
  • Shows window properties (via EnumPropsEx)
  • Includes richedit ES_ styles
  • Includes richedit ENM_ styles
  • Includes common control CCS_ styles for toolbars and status bars
  • Provides a 'Restore Size' button to return to the startup size

Bug Fixes (1.11)

  • Crash under XP when enumerating properties using EnumPropsEx(). Thanks to limax (limax@hot.ee).

Some Comments on the Source Code

  • All the class, window, windowEx and control styles that are used are located in styles.h. If I've missed any, feel free to add them to your version and mail them to me for addition
  • I decided to make MiniSpy 'always on top' as i find it most useful in that mode, but when i turned on tooltips in the list control these appeared behind the MiniSpy Window! Since the tooltips are a very useful feature for the style rows, I came up with an interesting workaround: I handle WM_ACTIVATEAPP and make MiniSpy 'topmost' when its not the active window and 'not topmost' when it is active.
  • To retrieve the window caption for the window and its parent I've used WM_GETTEXT instead of GetWindowText. This is simply because, for one reason or another, GetWindowText did not seem to work for some windows in this situation.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer Maptek
Australia Australia
.dan.g. is a naturalised Australian and has been developing commercial windows software since 1998.

Comments and Discussions

 
GeneralGreat ! one question... Pin
30-Mar-02 0:25
suss30-Mar-02 0:25 
GeneralRe: Great ! one question... Pin
.dan.g.27-Jun-02 23:57
professional.dan.g.27-Jun-02 23:57 
GeneralVery nice! Pin
2-Feb-02 21:31
suss2-Feb-02 21:31 
GeneralRunning the EXE crashes under WXP Pin
Uwe Keim29-Jan-02 10:24
sitebuilderUwe Keim29-Jan-02 10:24 
GeneralRe: Running the EXE crashes under WXP Pin
.dan.g.29-Jan-02 12:13
professional.dan.g.29-Jan-02 12:13 
GeneralBug in PropEnumProcEx Pin
limax23-Jan-02 1:32
limax23-Jan-02 1:32 
GeneralRe: Bug in PropEnumProcEx Pin
.dan.g.23-Jan-02 11:49
professional.dan.g.23-Jan-02 11:49 
GeneralSome suggestions Pin
James Brown21-Jan-02 7:23
James Brown21-Jan-02 7:23 
Hi,
Just a couple of suggestions really.

Firstly, I think you've forgotten to update the executable download to reflect the new version.

With regard to your tooltip and "always on top" problem - In an application I wrote, I solved this by responding to the TTN_SHOW notification that a tooltip sends to it's parent, and making the tool-tip topmost when necessary. This seemed to be a nice solution, but it's just something for you to bear in mind.

Just a point about your article text also: you say that Spy++ does not display control-specific styles for list-boxes, common controls etc. Well, the version that ships with MSVC 6.0 seems to, so maybe you used an older version?

Good work!
James


GeneralRe: Some suggestions Pin
.dan.g.21-Jan-02 11:52
professional.dan.g.21-Jan-02 11:52 
GeneralVery interesting Pin
16-Jan-02 1:54
suss16-Jan-02 1:54 
Generalproperties Pin
Goran Mitrovic14-Jan-02 12:31
Goran Mitrovic14-Jan-02 12:31 
GeneralRe: properties Pin
.dan.g.14-Jan-02 15:28
professional.dan.g.14-Jan-02 15:28 
GeneralExcellent, but... Pin
Philippe Lhoste14-Jan-02 7:02
Philippe Lhoste14-Jan-02 7:02 
GeneralRe: Excellent, but... Pin
.dan.g.14-Jan-02 11:38
professional.dan.g.14-Jan-02 11:38 
GeneralRe: Excellent, but... Pin
Philippe Lhoste14-Jan-02 22:37
Philippe Lhoste14-Jan-02 22:37 
GeneralRe: Excellent, but... Pin
15-Jan-02 12:03
suss15-Jan-02 12:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.