Einzelnen Beitrag anzeigen

helgew

Registriert seit: 30. Jul 2008
125 Beiträge
 
#9

Re: Eigene Menuitems in taskbar-popup einschleusen

  Alt 31. Jul 2008, 01:27
So.. nachdem sich jetzt auch noch das Menü nicht wieder erreichen lässt, gönn ich mir mal ne Mütze Schlaf.

Letzter Stand der DLL:

Delphi-Quellcode:
library MouseHookHandler;

uses
  Windows, Messages;

{$R *.res}

var
  hMouseHook : hHook;
  lasthandle: THandle;
type
  TChar = {$IFDEF UNICODE} WideChar; {$ELSE} Char; {$ENDIF}


function CallbackProc(nCode: Integer; wParam: WPARAM;
                          lParam: LPARAM): LRESULT; stdcall;
var
  hWnd : THandle;
  bla : Array[0..255] of Char;
  pt:TPoint;
  text: string;
  i, n: integer;
  r : TRect;
  hMenu: THandle;
begin
  // custom handling in background

  // lParam : integer(^MOUSEHOOKSTRUCT)
  pt := PMouseHookStruct(lParam)^.pt;

  // wParam : mouse message
  if wParam = WM_MOUSEMOVE then lasthandle := WindowFromPoint(pt);
  
  if wParam = WM_LBUTTONDOWN then
  begin
    hMenu := GetSystemMenu(lastHandle);
    if windows.IsMenu(hMenu) then
    begin
      //n := GetMenuItemCount(hWnd);
      //for i := 0 to n - 1 do
      begin
        {GetMenuItemRect(0,hWnd,i,r);
        if (r.Left <= pt.X) and (pt.X <= r.Right) and
           (r.Top <= pt.Y) and (pt.Y <= r.Bottom) then //}

        begin
          windows.MessageBox(0,'Erh... please be patient.','Programmer too lazy',mb_ok);
        end;
      end;
    end;

  end;

  // continue hook chain. No exceptions needed
  result := CallNextHookEx( hMouseHook, nCode, wParam, lParam);
end;

procedure SetHookHandle(h : HHOOK); stdcall;
begin
  hMouseHook := h;
end;


exports
   CallbackProc,
   SetHookHandle;

begin
end.
  Mit Zitat antworten Zitat