Intercepting windows messages using a hook

Posted on 2003-03-23
Medium Priority
Last Modified: 2010-04-03
I have a requirement to catch minimize messages sent to certain windows, at which point I would like to discard the message and minimize the window using my own code. The idea is that certain windows, when minimized, do not then appear on the taskbar. I have code which does this for windows I own, but I have to also do this for other application windows.
Question by:timns
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

DaFox earned 1000 total points
ID: 8195157
Hi timns.

A WH_CBT hook should be enough here.
I suppose it's not the first time you're dealing with windows hooks. So, set up your WH_CBT hook using SetWindowsHookEx(), in your hook proc try this:

function HookProc(nCode: Integer; wp: wParam; lp: lParam): LongInt; stdcall;
  Wnd: hWnd;
  case nCode of
      if (wp and $FFF0 = SC_MINIMIZE) then
        Wnd := hWnd(wp);
        // your code here
  Result := CallNextHookEx(HookHandle, nCode, wp, lp);

(not tested)


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question