怎么才能获取大型控件集(比如DevExpress VCL等)或者DELPHI自带控件的图标?

解决方案 »

  1.   

    Var
     j:integer;
     P:TICON;
    begin
    P:=TICON.Create; for j:=self.ComponentCount-1 downto 0 do begin
     if self.Components[j].ClassType=TMainMenu then
     (self.Components[j] as TMainMenu).Images.GetIcon(0,p); image1.Picture.Assign(p);
     p.SaveToFile('d:\a.ico'); p.Free;
     end;
    end;
    提取mianmenu图标的,不过到红色会报错,请高手回答
      

  2.   

    P:=TICON.Create;在循环外, p.Free;在循环内。
    第一次循环后,执行了p.Free,第二次循环,再执行p.Free,因为P已经销毁而又没有重新创建,所以指向一个无效指针。把p.Free放到后面两个End之间就没问题了。这段程序是遍历窗口,寻找并提取主菜单第一项的图标,跟我的问题基本没关系。我是想提取DevExpress VCL这个控件集的图标。看了下DevExpress VCL源码,它的图标分散在N个RES资源文件里。我不想用{$R XXX.RES}这种方式一个个引入资源文件,而且,由于不知道每个图标的资源名称(ResName),也不能用
    Res := TResourceStream.Create(HInstance,ResName, PChar(ResType));
    Res.SaveToFile(FileName);
    这样的方法提取图标。
      

  3.   

    怀念10年前的DELPHIBBS大富翁论坛
      

  4.   

    就是那个错误。
    还有,你用了Images.GetIcon,就必须指定MainMenu1的Images属性为一个Images,如下例中的Images1
    以下程序在DELPHI7、DELPHI XE2下运行均正常。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls, Menus, ImgList;type
      TForm1 = class(TForm)
        MainMenu1: TMainMenu;
        aaa1: TMenuItem;
        bbb1: TMenuItem;
        ccc1: TMenuItem;
        Button1: TButton;
        Image1: TImage;
        ImageList1: TImageList;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    Var
      j:integer;
      P:TICON;
    begin
      P := TICON.Create;  for j := ComponentCount - 1 downto 0 do
        if (Components[j] is TMainMenu) then
        begin
          (Components[j] as TMainMenu).Images.GetIcon(0,p);
          image1.Picture.Assign(p);
          p.SaveToFile('d:\a.ico');
        end;  p.Free;
    end;end.