Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Intercepting windows messages using a hook

Posted on 2003-03-23
1
Medium Priority
?
503 Views
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.
0
Comment
Question by:timns
1 Comment
 
LVL 6

Accepted Solution

by:
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;
var
  Wnd: hWnd;
begin
  case nCode of
    HCBT_SYSCOMMAND:
    begin
      if (wp and $FFF0 = SC_MINIMIZE) then
      begin
        Wnd := hWnd(wp);
        // your code here
      end;
    end;
  end;
  Result := CallNextHookEx(HookHandle, nCode, wp, lp);
end;

(not tested)

Markus
0

Featured Post

Technology Partners: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

564 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