Главная страница
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.011 c
3-73539
gera-killer
2002-09-02 15:02
2002.09.23
Delphi + Btrieve?


1-73618
stas_a
2002-09-12 13:29
2002.09.23
Трей


3-73560
denimas
2002-09-03 15:07
2002.09.23
При группировке виснит


8-73779
MetallAdm
2002-01-23 12:09
2002.09.23
OpenGl or Direct X ??


3-73559
dihlos
2002-09-03 15:10
2002.09.23
Поиск