Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Mar : Catching Messages

www.cryer.info
Managed Newsgroup Archive

Catching Messages

Subject:Catching Messages
Posted by:"Michael Fritz" (spam_athome@yahoo.de)
Date:Thu, 29 Mar 2007 17:01:30

Hi,

I'm hooking into the Windows message queue in my component this way:

    FOldWndProc := TFarProc(GetWindowLong(FHandle, GWL_WNDPROC));
    FNewWndProc := Classes.MakeObjectInstance(HookWndProc);
    SetWindowLong(FHandle, GWL_WNDPROC, LongInt(FNewWndProc));

The coding for the HookWndProc look like this:

procedure TMyAppEvents.HookWndProc(var LocalMessage: TMessage);
  begin
    LocalMessage.Result := CallWindowProc(FOldWndProc, (Owner as
TForm).Handle,
      LocalMessage.Msg , LocalMessage.wParam, LocalMessage.lParam);
[..]
    with LocalMessage do
    begin
      case Msg of
        WM_QUERYENDSESSION :
          begin
            HandleQEndSessionBroadCast(LocalMessage);
[..]

First, is this the correct way to catch messages and handle it myself and
second WM_QUERYENDSESSION is never reached. Will this message be removed
from the message queue when calling CallWindowProc()?

Thanks,
--
cu,
Michael

Replies:

www.cryer.info
Managed Newsgroup Archive