StretchDraw не работает с иконками. В данной ситуации я бы поступил так: рисовал бы иконку в Timage и затем назначал изображение другому, большему Timage.
Пример кода:
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Image1.Canvas.FillRect(Image1.Canvas.ClipRect);
Image1.Canvas.Draw(0, 0,
TIcon(StringGrid1.Objects
[StringGrid1.Col, StringGrid1.Row]));
Form2.Image1.Picture := Image1.Picture;
end;
{Примечание. Form2.Image1 имеет Stretch установленный
в True и размер, бОльший размера иконки в 4 раза}
Read more »
Filed in Графика by admin | Январь 27, 2008 | No Comments
Для этого достаточно текущее разрешение экрана и в соответствии с ним изменить дескриптор иконки приложения. Естественно, что Вам придется создать в ресурсах новые иконки.
Поместите следующий код в файл проекта (.DPR) Вашего приложения:
Application.Initialize;
Application.CreateForm(TForm1, Form1);
case GetDeviceCaps(GetDC(Form1.Handle), HORZRES) of
640 : Application.Icon.Handle := LoadIcon (hInstance, ‘ICON640′);
800 : Application.Icon.Handle := LoadIcon (hInstance, ‘ICON800′);
1024 : Application.Icon.Handle := LoadIcon (hInstance, ‘ICON1024′);
1280 : Application.Icon.Handle := LoadIcon (hInstance, ‘ICON1280′);
end;
Application.Run;
Filed in Графика by admin | Январь 27, 2008 | No Comments
А по утрам я плохо загружаюсь…
Если ваша иконка хранится в компоненте Image (видимым или иным способом), вы можете написать:
Application.Icon := Image1.Picture.Icon;
Если в файле ресурса:
Application.Icon.Handle := LoadIcon(hInstance, ‘ICONNAME’);
В любом случае для форсирования показа иконки необходимо вызвать следующую функцию:
InvalidateRect(Application.Handle, NIL, True);
.. и новая иконка предстанет свету.
Иконка, расположенная в .RES-файле, должна быть видима в .EXE-файле, к примеру, при просмотре файла посредством Program Manager. Иконка, расположенная в компоненте Image, в этом случае не видна.
Filed in Графика by admin | Январь 27, 2008 | No Comments
{How to get icon from a shortcut file ?
I have found that if you use a ListView component,
to show a list of files in any folder that contains shortcuts,
then the shortcut icons do not appear correctly -
they do not show the true icon of the application to which they relate.
However, there is a a very useful feature of SHGetFileInfo,
which is SHGFI_LINKOVERLAY. This adds the shortcut “arrow”,
which is shown in the bottom left corner of any shortcut icon.
The demo code below shows the basic use of the SHGFI_LINKOVERLAY feature.
I have added code to this demo, to distingiush between shortcut and non-shortcut files -
without this code, it will overlay the shortcut “arrow” irrespective of the file type.
To show the icon of a shortcut, the following code can be used as a demo:
Read more »
Filed in Графика by admin | Январь 27, 2008 | No Comments
Сначала в разделе interface пишем такой код:
type ThIconArray = array[0..0] of hIcon;
type PhIconArray = ^ThIconArray;
function ExtractIconExA(lpszFile: PAnsiChar;
nIconIndex: Integer;
phiconLarge : PhIconArray;
phiconSmall: PhIconArray;
nIcons: UINT): UINT; stdcall;
external ’shell32.dll’ name ‘ExtractIconExA’;
function ExtractIconExW(lpszFile: PWideChar;
nIconIndex: Integer;
phiconLarge: PhIconArray;
phiconSmall: PhIconArray;
nIcons: UINT): UINT; stdcall;
external ’shell32.dll’ name ‘ExtractIconExW’;
Read more »
Filed in Графика by admin | Январь 27, 2008 | No Comments