aoutlbcs.pas

来自「delphi编程控件」· PAS 代码 · 共 153 行

PAS
153
字号
unit aoutlbcs;
(*
 COPYRIGHT (c) RSD Software 1997 - 98
 All Rights Reserved.
*)

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, aimctrls, ExtCtrls, aoutlbar;

type
  TFAoutLookBarCustomize = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    ListBox: TListBox;
    Panel4: TPanel;
    Button: TButton;
    ImageListBox: TAutoImageListBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ListBoxClick(Sender: TObject);
    procedure ImageListBoxStartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure ImageListBoxEndDrag(Sender, Target: TObject; X, Y: Integer);
    procedure ButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ImageListBoxDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure ImageListBoxDragDrop(Sender, Source: TObject; X, Y: Integer);
  private
    Store : TAutoOutLookBarStore;
    procedure WMGetMinMaxInfo(var Message: TMessage); message WM_GETMINMAXINFO;
  end;

procedure  AutoOutLookBarCustomize(AStore : TAutoOutLookBarStore);

implementation
uses autostrs, areginf;

Var
  AForm : TFAoutLookBarCustomize;


procedure  AutoOutLookBarCustomize(AStore : TAutoOutLookBarStore);
begin
  if(AForm = Nil) then begin
    AForm := TFAoutLookBarCustomize.Create(Nil);
    with AForm do begin
      ListBox.Items.Assign(AStore.Categories);
      ImageListBox.ImageList := AStore.LargeImages;
      if(ListBox.Items.Count > 0) then
        ListBox.ItemIndex := 0;
    end;
  end;
  AForm.Store := AStore;  
  AForm.ListBoxClick(Nil);


  AForm.Show;
end;

{$R *.DFM}

procedure TFAoutLookBarCustomize.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  StoreAutoFormsInformtion(self);
  Action := caFree;
  AForm := Nil;
end;

procedure TFAoutLookBarCustomize.ListBoxClick(Sender: TObject);
Var
  List : TList;
  i : Integer;
  item : TAutoOutLookStoredItem;
begin
  ImageListBox.Items.Clear;
  if(ListBox.ItemIndex > -1) and (ListBox.Items.Count > 0) then begin
    List := TList.Create;
    Store.GetItemsByCategory(ListBox.Items[ListBox.ItemIndex], List);
    for i := 0 to List.Count - 1 do begin
      Item := TAutoOutLookStoredItem(List[i]);
      ImageListBox.AddItem(Item.Caption, Item.LargeImage)
    end;
    List.Free;
  end;
  if(ImageListBox.Items.Count > 1) then
    ImageListBox.ItemIndex := 0;
end;

procedure TFAoutLookBarCustomize.ImageListBoxStartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  if(ImageListBox.ItemIndex > -1) and (ImageListBox.Items.Count > 0) then
    AutoOutLookBarDragObject :=
      TAutoOutLookBarDragObject.Create(ImageListBox, DragObject, Nil,
      Store.GetItemByCategory(ListBox.Items[ListBox.ItemIndex],
                  ImageListBox.ItemIndex));
end;

procedure TFAoutLookBarCustomize.ImageListBoxEndDrag(Sender,
  Target: TObject; X, Y: Integer);
begin
  if(AutoOutLookBarDragObject <> NIl) then
    AutoOutLookBarDragObject.EndDrag(Target, X, Y);
end;

procedure TFAoutLookBarCustomize.ButtonClick(Sender: TObject);
begin
  AForm.Close;
end;

procedure TFAoutLookBarCustomize.WMGetMinMaxInfo(var Message: TMessage);
var
   P : PMinMaxInfo;
begin
    P:=PMinMaxInfo(Message.lParam);
    P^.ptMinTrackSize.X:= 350;
    P^.ptMinTrackSize.Y:= 250;
    P^.ptMaxTrackSize.X:= 350;
    P^.ptMaxTrackSize.Y:= 250;
end;


procedure TFAoutLookBarCustomize.FormCreate(Sender: TObject);
begin
  Caption := LoadStr(AEC_OUTLOOKBARCUSTOMIZE);
  Button.Caption := LoadStr(ACB_CLOSE);
  ReStoreAutoFormsInformtion(self);
end;

procedure TFAoutLookBarCustomize.ImageListBoxDragOver(Sender,
  Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
  if(AutoOutLookBarDragObject <> NIl) And (Source is TAutoOutLookBar) then begin
    AutoOutLookBarDragObject.DeleteItem := True;
    Accept := True;
  end;
end;

procedure TFAoutLookBarCustomize.ImageListBoxDragDrop(Sender,
  Source: TObject; X, Y: Integer);
begin
  if(AutoOutLookBarDragObject <> NIl) And (Source is TAutoOutLookBar) then begin
    AutoOutLookBarDragObject.Item.Free;
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?