(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: Fenster-Icon aus hWnd ermitteln
22. Jun 2005, 19:54
Habe unter Google folgenden Code gefunden, um das kleine, grosse Icon zu erhalten.
Vielliecht hast du Zeit, das schnell unter Delphi auszuprobieren.
Code:
00306 HICON get_window_icon_small(HWND hwnd)
00307 {
00308 HICON hIcon = 0;
00309
00310 SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00311
00312 if (!hIcon)
00313 SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00314
00315 if (!hIcon)
00316 SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00317
00318 if (!hIcon)
00319 hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
00320
00321 if (!hIcon)
00322 hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
00323
00324 if (!hIcon)
00325 SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hIcon);
00326
00327 return hIcon;
00328 }
00329
00330 HICON get_window_icon_big(HWND hwnd, bool allow_from_class)
00331 {
00332 HICON hIcon = 0;
00333
00334 SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00335
00336 if (!hIcon)
00337 SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00338
00339 if (!hIcon)
00340 SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon);
00341
00342 if (allow_from_class) {
00343 if (!hIcon)
00344 hIcon = (HICON)GetClassLong(hwnd, GCL_HICON);
00345
00346 if (!hIcon)
00347 hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
00348 }
00349
00350 if (!hIcon)
00351 SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&hIcon);
00352
Thomas
|