Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.09.23;
Скачать: CL | DM;

Вниз

Народ кто знает   Найти похожие ветки 

 
Cybermonk   (2002-05-23 16:58) [0]

Народ кто знает как выводить уменьшенную иконку например уменьшенную в 2 раза. У меня что-то не получается. Привожу код:<COprocedure TForm1.WMDropFiles(var Message: TWMDropFiles);
//type
// PIco=^HICON;
var
FileName: array [0..MAX_PATH] of Char;
TheBitmap : TBitmap;
Icon: TIcon;
//Ico: PIco;
IconIndex : word;
begin
if DragQueryFile(Message.Drop, 0, FileName, SizeOf(FileName)) > 0 then
begin
SpeedButton2:=TSpeedButton.Create(CoolPanel1);
SpeedButton2.Left:=0;
SpeedButton2.top:=begunok;
SpeedButton2.parent:=CoolPanel1;
SpeedButton2.Width:=SpeedButton1.Width;
SpeedButton2.Height:=SpeedButton1.Height;
SpeedButton2.name:="SpeedButton"+IntToStr(NameIdx);
//SpeedButton2.Caption:=ExtractFileName(FileName);
SpeedButton2.Anchors:=[akLeft,akTop,akRight];
//Вытаскиваем иконку
IconIndex:= 1;
Icon := TIcon.Create;
TheBitmap := TBitmap.Create;
Icon.Handle := ExtractAssociatedIcon(0,FileName,IconIndex);
//TheBitmap.Handle:=ExtractAssociatedIcon(0,FileName,IconIndex);
//Icon.Handle := ExtractIcon(0,FileName,IconIndex);
//Icon.Handle:=ExtractIconEx(FileName,0,nil, ico,1);
//SpeedButton2.Glyph.Width := Icon.Width;
//SpeedButton2.Glyph.Height := Icon.Height;
//SpeedButton2.Glyph.Canvas.Draw(0, 0, Icon);
TheBitmap.Width := Icon.Width;
TheBitmap.Height := Icon.Height;
TheBitmap.Canvas.StretchDraw(Rect(0,0,Trunc(Icon.Width*2),Trunc(Icon.Height*2)),Icon);
SpeedButton2.Glyph.Canvas.StretchDraw(Rect(0,0,Trunc(TheBitmap.Width*2),Trunc(TheBitmap.Height*2)),TheBitmap);
//SpeedButton2.Glyph.Canvas.StretchDraw(Rect(0,0,Trunc(Icon.Width*0.5),Trunc(Icon.Height*0.5)),Icon);
//SpeedButton2.Glyph.Canvas.StretchDraw(Rect(2,2,Trunc(TheBitmap.Width*0.5),Trunc(TheBitmap.Height*0.5)),TheBitmap);
//DrawIconEx(SpeedButton2.Glyph.Canvas.Handle,1,1,Icon.handle,16,16,1,1,DI_COMPAT);
TheBitmap.Free;
Icon.Free;
SpeedButton2.PopupMenu:=PopupMenu1;
SpeedButton2.Enabled:=true;
SpeedButton2.Visible:=true;
//if Btn=nil then New(Btn)
// else
// begin
// Dispose(Btn);
//New(Btn);
// end;

//Btn^.x:=40+begunok;
//Btn^.y:=0;
//try
new(Btn);
Btn^:=SpeedButton2;
FList.Add(Btn);
//finally
// dispose(Btn);
//end;
Begunok:=begunok+42;
NameIdx:=NameIdx+1;
end;
end;
DE>


 
Song ©   (2002-05-23 18:08) [1]

У... сколько кода... . А DrawIconEx() не воспользоваться? И быстрее и в одну строчку пишется...


 
Cybermonk   (2002-05-24 10:04) [2]

Пробовал вот так
DrawIconEx(SpeedButton2.Glyph.Canvas.Handle,1,1,Icon.handle,16,16,1,1,DI_COMPAT);
но не получается


 
Song ©   (2002-05-24 11:27) [3]

Не получается потому что тип Icon у Вас TIcon, читайте хэлп



Страницы: 1 вся ветка

Текущий архив: 2002.09.23;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.017 c
1-73672
AL2002
2002-09-10 17:30
2002.09.23
Undeclared identifier WM_FONTCHANGE


14-73807
Вадим
2002-08-25 03:04
2002.09.23
Это сильно!


7-73901
soldat
2002-06-27 11:00
2002.09.23
фискальный регистратор


1-73689
kronprince
2002-09-10 20:52
2002.09.23
TListView при ViewStyle=vsReport


7-73910
Fredericco
2002-07-12 15:03
2002.09.23
Shell=MyProg.exe