Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#20

AW: Menu Ownerdraw

  Alt 8. Mär 2019, 00:17
Destotrotz das ich mit "Windows Detective" die Class nicht finde versuche ich es jetzt auf diesen weg.
OK ist im Log zu finden seltsames Konzept..

Delphi-Quellcode:
function CBTHookProc(nCode: Integer; wP: WPARAM; lP: LPARAM): LRESULT; stdcall;
var
  buf: array[0..128] of Char;
  Style: DWORD;
begin
  if nCode < 0 then
  begin
    result := CallNextHookEx(FHook, nCode, wP, lP);
    exit;
  end;

  case nCode of
    HCBT_CREATEWND:
      begin
        CBTSturct := PCBTCreateWnd(lP)^;
        GetClassName(wP, buf, SizeOf(buf));
        if (Integer(CBTSturct.lpcs.lpszClass) = 32768) then
        begin
          CBTMenuHandle := wP;
          Style := GetWindowLongPtr(CBTMenuHandle, GWL_STYLE);
          if (Style and WS_POPUP = WS_POPUP) then
            ToolBarMenuSubClass(CBTMenuHandle);
        end;
        result := 0;
        exit;
      end;

    HCBT_DESTROYWND:
      if FHook <> 0 then
      begin
        UnhookWindowsHookEx(FHook);
        ToolBarMenuUnSubClass(CBTMenuHandle);
      end;
  end;
  result := CallNextHookEx(FHook, nCode, wP, lP);
end;
Delphi-Quellcode:
function ToolBarProc(WinHandle: HWND; Msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
var
  hDCTemp: HDC;
  rc, rw: TRect;
  ps: TPaintStruct;
  lpt: TPoint;
  DC: HDC;
  hDCBack: HDC;
begin
  Result := 0;

  case Msg of

    WM_LBUTTONDOWN:
      FHook := SetWindowsHookEx(WH_CBT, @CBTHookProc, 0, GetCurrentThreadId);
Das Problem das ich nun aber habe ist das 2 mal die Class "#32768" gefunden wird das verursacht nun richtige Probleme da ich nicht weis
welches handle nun gültig ist.

Dementsprechend wird jetzt auch 2 mal die Subclass ToolBarMenuSubClass(CBTMenuHandle); aufgerufen.

gruss

Geändert von EWeiss ( 8. Mär 2019 um 13:11 Uhr)
  Mit Zitat antworten Zitat