Get/Set WindowIcon جلب مقبض Icon لأي نافذة عن طريق المقبض
#1
السلام عليكم و رحمة الله و بركاته
هذه دالة بسيطة تقوم بجلب مقبض Icon لأي نافذة عن طريق المقبض
PHP كود :
/// <summary> Retrieve the Icon from window handle </summary>
function GetWindowIcon(hWin:HWND):HICON;
begin
Result
:=0;
if 
hWin=INVALID_HANDLE_VALUE then Exit;
Result :=SendMessage(hWin,WM_GETICON,ICON_SMALL,0);
if 
Result<>0 then Exit;
Result :=SendMessage(hWin,WM_GETICON,ICON_BIG,0);
if 
Result<>0 then Exit;
Result :=SendMessage(hWin,WM_GETICON,ICON_SMALL2,0);
if 
Result<>0 then Exit;
Result :=GetClassLongPtr(hWin, GCL_HICON);;
if 
Result<>0 then Exit;
Result :=GetClassLongPtr(hWin, GCL_HICONSM);
Result:=0;
end; 
و هذه دالة تقوم بتغيير ال Icon

PHP كود :
/// <summary> Change window icon from <c>Handle</c> </summary>
///<param name="hWin"> Window Handle
/// </param>
///<param name="Icon"> the new icon
/// </param>
///<param name="IconType"><c> you can use one of this :</c>
///<para>ICON_SMALL = change the window caption icon </para>
///<para>ICON_BIG = change the window TaskBar icon </para>
///<para>ICON_SMALL2 = change the window caption and TaskBar icon </para>
/// </param>
function SetWindowIcon(hWin:HWND;Icon:HICON; const IconType:integer =ICON_SMALL2 ):Boolean;
begin
Result
:=False;
if 
hWin<>INVALID_HANDLE_VALUE then
Result
:=(SendMessage(hWin,WM_SETICON,IconType,LPARAM(Icon))>0);
end; 
مثال للاستعمال :

PHP كود :
var NotePadHandle :HWND;
 
NotePadIcon :HICON;
 
NotePadNewIcon:HICON;
begin
// Get NotePad Handle
NotePadHandle:=FindWindow('Notepad',0);
// Get NotePad Icon from Handle
NotePadIcon:=GetWindowIcon(NotePadHandle);
// Draw Current NotePad Icon
DrawIcon(Canvas.Handle,0,0,NotePadIcon);
NotePadNewIcon:=Application.Icon.Handle;
// Change NotePad Icon
SetWindowIcon(NotePadHandle,NotePadNewIcon,ICON_SMALL2);

end; 
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 2 ) ضيف كريم