![]() |
Icon in allen Titelleisten
Hi!
wie kann ich denn aus meinem Programm heraus Icons in jeder Titelleiste erzeugen, welche dann bestimmte Aufgaben erledigen? vielen dank schonmal |
Re: Icon in allen Titelleisten
hat keiner ne idee? :-(
ich weiß gar nicht, wie ich das angehen soll... |
Re: Icon in allen Titelleisten
Wie genau meinst du das? Soll das Icon andeuten, dass dieses Fenster eine bestimmte Aufgabe hat?
|
Re: Icon in allen Titelleisten
ich will das sozusagen zum starten von programmen verwenden. immer wenn irgendein fenster geöffnet ist, dann soll ein symbol neben dem minimieren, maximieren und schließen button sein. und das eben bei allen fenstern...
|
Re: Icon in allen Titelleisten
Die WM_NCPAINT aller Anwendungen Hooken. Gibt genug Hook-Beispiele in diesem Forum.
|
Re: Icon in allen Titelleisten
so schaut jetzt meine dll aus...
hat jemand ne idee, wieso nichts gezeichnet wird... also den handle der anwendung findet er
Delphi-Quellcode:
library Hook;
uses Windows, Messages, sysutils, graphics; type THookRec = record Hook: HHOOK; Wnd: HWND; oldProc: Integer; end; var map: DWord; buf: ^THookRec; startwnd:HWND; function HookProc(nCode: Integer; wp: wParam; lp: lParam): LongInt; stdcall; var ACanvas: TCanvas; begin try if (nCode >= HC_ACTION) then if (PMSG(lP).message=WM_NCPAINT) and (pmsg(lp).hwnd=buf^.Wnd) then begin ACanvas := TCanvas.Create; try ACanvas.Handle := GetWindowDC(startwnd); with ACanvas do begin Brush.Color := clBlack; Font.Name := 'Times New Roman'; Font.Size := 8; Font.Color := clred; Font.Style := [fsItalic, fsBold]; TextOut(GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER), Round((GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height)) / 2) + 1, ' Test'); end; finally ReleaseDC(startwnd, ACanvas.Handle); ACanvas.Free; end; end; Result := CallNextHookEx(buf^.Hook, nCode, wp, lp); except Result := 0; MessageBox(0, 'Fehler in HookProc', 'error', MB_OK); end; end; // sets up hook function SetHook: Boolean; stdcall; export; begin try Result := false; if (not assigned(buf)) then begin map := CreateFileMapping(DWord(-1), nil, PAGE_READWRITE, 0, SizeOf(THookRec), 'HookRecMemBlock'); buf := MapViewOfFile(map, FILE_MAP_ALL_ACCESS, 0, 0, 0); startwnd:=FindWindow(nil, 'Name irgendeiner Anwendung'); buf^.Wnd:=startwnd; buf^.Hook := SetWindowsHookEx(WH_GETMESSAGE, @HookProc, hInstance, GetWindowThreadProcessId(startwnd,nil)); Result := true; end; except Result := false; MessageBox(0, 'Fehler in SetHook', 'error', MB_OK); end; end; // DLL entry point procedure DllEntry(dwReason: DWord); begin Case dwReason of DLL_PROCESS_ATTACH: begin if (not assigned(buf)) then begin map := OpenFileMapping(FILE_MAP_ALL_ACCESS, false, 'HookRecMemBlock'); buf := MapViewOfFile(map, FILE_MAP_ALL_ACCESS, 0, 0, 0); CloseHandle(map); map := 0; end; end; DLL_PROCESS_DETACH: begin UnmapViewOfFile(buf); buf := nil; end; end; end; exports SetHook; // main begin DisableThreadLibraryCalls(hInstance); DllProc := @DLLEntry; DllEntry(DLL_PROCESS_ATTACH); end. |
Re: Icon in allen Titelleisten
ich hab das jetzt eingefügt und es funktioniert. nur muss ich zudem statt WM_NCPAINT WM_PAINT angeben. warum funktioniert das ganze nicht mit WM_NCPAINT?
Delphi-Quellcode:
var
hParent: HWND; begin try if (PMSG(lP).message=WM_PAINT) {and (pmsg(lp).hwnd=startwnd) }then begin hParent := GetParent(pmsg(lp).hwnd); if hParent = startwnd then begin |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz