Intercepting and hiding a window before it appears

I am developing a (in-process) plug-in to application and as part of my plug-in I want to replace the application's tool-tips with my own. However, there is no API available for me to do so, so I've decided to go low-level.

I know the window class of the tool tip, but the question is, how do I detect it being created and how do I close it afterward?

Here's what I thought to do so far:

  1. Create a system-wide hook on WM_CREATE
  2. When caught, check the class and the process of the WM_CREATE target
  3. Verify it is indeed the window I care about:
    • If the process is the one my plug-in is sitting in
    • And if the class is of the correct type
    • And if the correct application is in focus (in case of multiple applications)
  4. Send a WM_DESTROY to the created window and create my own window at its position instead

How does it sound? Assuming there is indeed no API to handle the tooltips, is there a simpler way for what I need?

Thanks!

P.S Tagged as C++/C# as I intend to write it in these 2 languages (C++ for system-wide hook, C# for everything else)

Answers


If you know the type of the window you want to block, you can simply subclass it and handle the destruction in your own WndProc. Use GetClassLongPtr() with GCL_WNDPROC on the tooltip class, use SetClassLongPtr() with GCL_WNDPROC to set your own WndProc and have it call DestroyWindow() on WM_CREATE and call the old WndProc for the rest..


Need Your Help

Android Parse JSON Array

java android arrays json parsing

How Can I parse a JSON ARRAY to get the data without the [] and ""

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.