(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: Fenster-Icon aus hWnd ermitteln
22. Jun 2005, 20:13
Und hier die Delphi Umsetzung:
Delphi-Quellcode:
const
ICON_SMALL2 = 2;
function get_window_icon_small(hwnd: HWND): HICON;
var
Icon: HICON;
begin
Icon := 0;
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if Icon = 0 then
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if Icon = 0 then
SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if Icon = 0 then
Icon := HICON(GetClassLong(hwnd, GCL_HICONSM));
if Icon = 0 then
Icon := HICON(GetClassLong(hwnd, GCL_HICON));
if Icon = 0 then
SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, DWORD(Icon));
Result := Icon;
end;
function get_window_icon_big(hwnd: HWND; allow_from_class: Boolean): HICON;
var
Icon: HICON;
begin
Icon := 0;
SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if Icon = 0 then
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if Icon = 0 then
SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, DWORD(Icon));
if allow_from_class then
begin
if Icon = 0 then
Icon := HICON(GetClassLong(hwnd, GCL_HICON));
if Icon = 0 then
Icon := HICON(GetClassLong(hwnd, GCL_HICONSM));
end;
if Icon = 0 then
SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, DWORD(Icon));
Result := Icon;
end;
Thomas
|