• 什么是四眼狗

    • “四眼狗”并不是指狗有近视,而是由于狗毛的原因,头顶的毛看起来像多了一对眼晴,所以俗称叫“四眼狗”。

      我家就养了一只,跟一般的狗差不多,还多乖的(附图),这就是传说中的“四眼狗”,被我抓拍到了,哈哈~~~~~~

      有兴趣的朋友可留言,下次再多弄几张照片上来。


      dsc01578.jpg

      dsc01732.jpg

      dsc01733.jpg

    • ListView 排序功能

    •   private
          { Private declarations }
          SortCol: Integer;
          SortWay: Integer;

      procedure TMainFrm.ListView1ColumnClick(Sender: TObject; Column: TListColumn);
      begin
        SortCol:=Column.Index;
        if (SortWay=1) then SortWay:=-1 else SortWay:=1;
        (Sender as TCustomListView).AlphaSort;
      end;

      procedure TMainFrm.ListView1Compare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
      var
        t: Integer;
      begin
        if (SortCol=0) then
        begin
          Compare:=SortWay * CompareText(Item1.Caption,Item2.Caption);
        end else
        begin
          t:=SortCol-1;
          Compare:=SortWay * CompareText(Item1.SubItems[t],Item2.SubItems[t]);
        end;
      end;

    • dsgnintf.dcu 找不到的解决方案

    • d5下开发的大多数控件都是从tcomponenteditor派生的
      对于在d5开发的从tcomponenteditor派生的控件,要到d6下使用,需要经过以下
      几个步骤:
      1、添加 lib\designide.dcp到控件的dpk文件的requires部分
      2、在控件的pas源文件中凡是uses dsgnintf的地方改成uses designintf, designeditors

      3.加入搜索路径
      C:\Program Files\Borland\Delphi7\Source\ToolsAPI

      偶测试成功, 下面还有一种方法(来至大富翁论坛), 测试失败.

      ---------------------------------------------------------------------------------------------------

      这个问题是D6及D7才有的,原因及解决方法如下文(英文站点,看晕了)
      http://community.borland.com/article/0,1410,27717,00.html
       
      不改包,直接改Delphi源文件的解决方法:(我是这样改的,没有出什么问题)
      1.加入搜索路径
      C:\Program Files\Borland\Delphi7\Source\ToolsAPI
      2.打开
      C:\Program Files\Borland\Delphi7\Source\ToolsAPI\DesignEditors.pas
      3.找到并把
      uses
        Types, SysUtils, Classes, TypInfo, Variants, DesignIntf, DesignMenus,Proxies;
      改为
      uses
        Types, SysUtils, Classes, TypInfo, Variants, DesignIntf, DesignMenus{,Proxies};
      4.找到并把
            if (FAncestor = nil) and (Component <> Designer.Root)
              and IsProxyClass(Component.ClassType) then
      改为
            if (FAncestor = nil) and (Component <> Designer.Root)
              {and IsProxyClass(Component.ClassType)} then
      5.找到并把
        while IsProxyClass(ComponentClass) do
      改为
        //while IsProxyClass(ComponentClass) do
      6.保存,编译运行,OK

      上面3.4.5.就是把Proxies单元从DesignEditors单元中剔除,DesignEditors单元
      中只有两个地方引用了Proxies单元的函数,而且是同一个函数:IsProxyClass,把
      这两个地方注释掉就可以了.



      proxies.pas

    • 查找某目录下的特定文件

    • procedure ChangeDir(dir: string; SL: TStringList);
      var
        SearchRec : TSearchRec;
        Attr : integer;
        Found : integer;
        ExtFileName:string;
        temstr:string;
      begin
          SL.Clear;
          //查找该目录下所有*.jpg的文件,并将文件路径及文件名添加到SL
          temstr:=dir+'\*.jpg';
          Attr := faAnyFile;
          Found := FindFirst(temstr, Attr, SearchRec);
          while Found = 0 do
          begin
            //获取扩展名
            //ExtFileName:=LowerCase(ExtractFileExt(SearchRec.Name));
            try
              SL.Add(dir+'\'+SearchRec.Name);
            except
            end;
            Found := FindNext(SearchRec);
          end;
          FindClose(SearchRec);
      end;

    • Delphi翻转图控件

    • 本控件实现翻转图效果,共有三个图像:默认图像,活动图像,移开图像。

      代码源于大富翁论坛,由于在设计器图像活动,会将默认图像与活动图像设为一样,所以我增加了一个属性isActiveNow ,设计期将此属性设为False ,在Form.create 中将该属性设为True 就OK了。

      //========================================================

      unit IMageMouse;

      interface

      uses
       SysUtils, Classes, Controls, ExtCtrls,Graphics,Windows,Messages;

      type
       TIMageMouse = class(TImage)
       private
         { Private declarations }

         FInPicture:TPicture;
         FOutPicture:TPicture;
         FisActiveNow:Boolean;

         procedure SetInPicture(const value:TPicture);
         procedure SetOutPicture(const value:TPicture);
         procedure SetisActiveNow(Value: Boolean);
         procedure MouseEnter(var mess:TMessage);message CM_MOUSEENTER;
         procedure MouseLeave(var mess:TMessage);message CM_MOUSELEAVE;
       protected
         { Protected declarations }
         procedure DOPaint(var Mess:TWMPaint);message WM_PAINT;
       public
         { Public declarations }
          isMouseHere:Boolean;
         constructor Create(AOwner:TComponent);override;
         destructor Destroy();override;
       published
         { Published declarations }
         property InPicture:TPicture read FInPicture write SetInPicture;
         property OutPicture:TPicture read FOutPicture write SetOutPicture;
         property isActiveNow:boolean read FisActiveNow write FisActiveNow;
        
       end;

      procedure Register;

      implementation

       

      { TIMageMouse }

      constructor TIMageMouse.Create(AOwner: TComponent);
      begin
       inherited;
       FInPicture :=TPicture.Create;
       FOutPicture :=TPicture.Create;
       FisActiveNow :=false;
      end;

      destructor TIMageMouse.Destroy;
      begin
       FInPicture.Free;
       FOutPicture.Free;
       FInPicture :=nil;
       FOutPicture :=nil;
       inherited;
      end;

      procedure TIMageMouse.DOPaint(var Mess: TWMPaint);
      begin
       inherited;
      end;

      procedure TIMageMouse.MouseEnter(var mess: TMessage);
      begin
       isMouseHere :=True;
       if (finpicture<>nil) and FisActiveNow then
       begin
          picture.Assign(finpicture);
          Repaint();
       end;
      end;

      procedure TIMageMouse.MouseLeave(var mess: TMessage);
      begin
        isMouseHere :=False;
        if (foutpicture<>nil) and FisActiveNow then
        begin
           picture.Assign(foutpicture);
           Repaint();
        end;
      end;

      procedure TIMageMouse.SetisActiveNow(value: Boolean);
      begin
        FisActiveNow:=Value;
      end;

      procedure TIMageMouse.SetInPicture(const value: TPicture);
      begin
       FInPicture.Assign(value);
      end;

      procedure TIMageMouse.SetOutPicture(const value: TPicture);
      begin
      FOutPicture.Assign(value);
      end;

      procedure Register;
      begin
       RegisterComponents('Samples', [TIMageMouse]);
      end;

      end.


      imagemouse.pas

Powered by Typecho)))   ICP:蜀ICP备05009250号