Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  3 670

•  TDictionary Custom Sort  5 800

•  Fast Watermark Sources  5 603

•  3D Designer  8 218

•  Sik Screen Capture  5 913

•  Patch Maker  6 388

•  Айболит (remote control)  6 378

•  ListBox Drag & Drop  5 237

•  Доска для игры Реверси  94 551

•  Графические эффекты  6 570

•  Рисование по маске  5 644

•  Перетаскивание изображений  4 760

•  Canvas Drawing  5 135

•  Рисование Луны  4 863

•  Поворот изображения  4 411

•  Рисование стержней  3 116

•  Paint on Shape  2 360

•  Генератор кроссвордов  3 228

•  Головоломка Paletto  2 551

•  Теорема Монжа об окружностях  3 328

•  Пазл Numbrix  2 200

•  Заборы и коммивояжеры  2 849

•  Игра HIP  1 820

•  Игра Go (Го)  1 740

•  Симулятор лифта  2 072

•  Программа укладки плитки  1 798

•  Генератор лабиринта  2 240

•  Проверка числового ввода  1 925

•  HEX View  2 225

•  Физический маятник  1 911

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Преобразование иконок в Gliph-ы



Вот небольшой пример того, как можно загрузить иконку, содержащуюся в файле EXE, в Glyph у SpeedButton, и как очистить этот самый Glyph.

Огорчен, но комментарии в исходном коде на испанском языке.


unit Procs;

interface
uses

  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, StdCtrls, Buttons, ExtCtrls, ShellAPI;

procedure LlenaBoton(boton: TSpeedButton; Programa: string);
procedure LimpiaBoton(boton: TSpeedButton);

var
  {Botones de programas}
  Pic: TPicture;
  Fname: string;
  TempFile: array[0..255] of Char;
  Icon: TIcon;

implementation
uses ttotro;

procedure LlenaBoton(boton: TSpeedButton; Programa: string);

var
  NumFiles, NameLength: integer;
  nIconsInFile: word;
  rBoton: TRect;
  oBitmap: TBitmap;
  oBitmap2: TBitmap;
  NombreBitmap: string;

begin

  try
    screen.cursor := crHourglass;

    {Extrae el Icono}
    Icon := TIcon.Create;
    StrPCopy(TempFile, Programa);
    Icon.Handle := ExtractIcon(HInstance, TempFile, 0);

    {Crea una instancia de TPicture}
    Pic := TPicture.Create;
    {Asigna el icon.handle a la propiedad Pic.icon}

    Pic.Icon := Icon;

    {Configura el tamano del bitmap como el del icono y el del segundo
    bitmap con el tamano del boton}
    oBitmap := TBitMap.create;
    oBitmap2 := TBitMap.create;
    oBitmap2.Width := Icon.Width;
    oBitmap2.Height := Icon.Height;
    oBitmap.Width := boton.Width - 4;
    oBitmap.Height := boton.Height - 4;

    { Dibuja el icono en el bitmap }
    oBitmap2.Canvas.Draw(0, 0, Pic.Graphic);
    rBoton.left := 1;
    rBoton.Top := 1;
    rBoton.right := boton.Width - 6;
    rBoton.Bottom := boton.Height - 6;
    oBitmap.Canvas.StretchDraw(rBoton, oBitmap2);

    Boton.Hint := Programa;

    NombreBitmap := Copy(programa, 1, Length(programa) - 3) + 'BMP';
    {Salva el bitmap en un fichero}
    if not FileExists(NombreBitmap) then
    begin
      oBitmap.SaveToFile(ExtractFilePath(Application.ExeName) +
        ExtractFileName(NombreBitmap));
      Boton.Glyph := oBitmap;
    end
    else
      {Carga el BMP en el boton}
      Boton.Glyph.LoadFromFile(ExtractFilePath(Application.ExeName) +
        ExtractFileName(NombreBitmap));

  finally
    Icon.Free;
    oBitmap.Free;
    oBitmap2.Free;
    screen.cursor := crDefault;

  end; {main begin}
end; {llenaboton}

procedure LimpiaBoton(boton: TSpeedButton);

var
  oBitmap: TBitmap;
  rBoton: TRect;
begin

  try
    {Configuara el tamano del bitmap como el del icono y el del segundo
    bitmap con el tamano del boton}
    oBitmap := TBitMap.create;
    oBitmap.Width := boton.Width - 4;
    oBitmap.Height := boton.Height - 4;
    Boton.Glyph := oBitmap;

  finally
    oBitmap.Free;
  end; {main begin}
end; {limpiaboton}

end.








Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте