aoutlbed.pas

来自「delphi编程控件」· PAS 代码 · 共 555 行 · 第 1/2 页

PAS
555
字号

procedure TFAutoOutLookBarEditor.BIDeleteClick(Sender: TObject);
begin
   Bar.SelectedItem.Free;
end;

procedure TFAutoOutLookBarEditor.BIClearClick(Sender: TObject);
begin
  Bar.ActiveGroup.Items.Clear;
end;

procedure TFAutoOutLookBarEditor.BIMoveUpClick(Sender: TObject);
begin
  if(Bar.SelectedItem.Index > 0) then begin
    Bar.SelectedItem.Index := Bar.SelectedItem.Index - 1;
    Bar.SelectedItem.MakeVisible;
 end;
end;

procedure TFAutoOutLookBarEditor.BIMovedownClick(Sender: TObject);
begin
  if(Bar.SelectedItem.Index < Bar.ActiveGroup.Items.Count - 1) then begin
    Bar.SelectedItem.Index := Bar.SelectedItem.Index + 1;
    Bar.SelectedItem.MakeVisible;
  end;      
end;

procedure TFAutoOutLookBarEditor.LBStoredItemsStartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  if(LBStoredItems.ItemIndex > -1) and (LBStoredItems.Items.Count > 0) then
    AutoOutLookBarDragObject :=
      TAutoOutLookBarDragObject.Create(LBStoredItems, DragObject, Nil,
      Bar.Store.GetItemByCategory(CBStoredGroup.Items[CBStoredGroup.ItemIndex],
                  LBStoredItems.ItemIndex));
end;

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

procedure TFAutoOutLookBarEditor.FormCreate(Sender: TObject);
begin
  OldSelectedGroup := Nil;
  OldSelectedIndex := -1;

  Caption := LoadStr(AEC_OUTLOOKBAR);
  BDefault.Caption := LoadStr(ACB_DEFAULT);
  BOk.Caption := LoadStr(ACB_OK);
  bCancel.Caption := LoadStr(ACB_CANCEL);
  bHelp.Caption := LoadStr(ACB_HELP);

  BIAdd.Caption := LoadStr(ACB_ADD);
  BIInsert.Caption := LoadStr(ACB_INSERT);
  BIDelete.Caption := LoadStr(ACB_DELETE);
  BIClear.Caption := LoadStr(ACB_CLEAR);
  BIMoveUp.Caption := LoadStr(ACB_MOVEUP);
  BIMoveDown.Caption := LoadStr(ACB_MOVEDOWN);

  BGAdd.Caption := LoadStr(ACB_ADD);
  BGDelete.Caption := LoadStr(ACB_DELETE);
  BGRename.Caption := LoadStr(ACB_RENAME);
  BGUp.Caption := LoadStr(ACB_MOVEUP);
  BGDown.Caption := LoadStr(ACB_MOVEDOWN);  

  BIDefault.Caption := LoadStr(AEL_SETDEFITEMPROP);

  GGroup.Caption := LoadStr(AEL_GROUPS);
  LIconType.Caption := LoadStr(AEL_ICONTYPE);
  CBGIType.Caption := LoadStr(AEL_ICONTYPELAGRE);
  GStoredItems.Caption := LoadStr(AEL_STOREDITEMS);
  GItemProp.Caption := LoadStr(AEL_ITEMPROPETIES);

  LCustomData.Caption := LoadStr(AEL_CUSTOMDATA);
  LTag.Caption := LoadStr(AEL_TAG);
  LCaption.Caption := LoadStr(AEL_CAPTION);
  LHint.Caption := LoadStr(AEL_HINT);
  LSILarge.Caption := LoadStr(AEL_LARGEIMAGE);
  LSISmall.Caption := LoadStr(AEL_SMALLIMAGE);
end;

procedure TFAutoOutLookBarEditor.LBItemsDragOver(Sender, Source: TObject;
  X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
  if ((LBStoredItems.ItemIndex = -1) and (LBStoredItems.Items.Count > 0))
  or (Bar.ActiveGroup = Nil) then
    Accept := False
  else Accept := True;
end;

procedure TFAutoOutLookBarEditor.BDefaultClick(Sender: TObject);
Var
  i, j : Integer;
  fGroup : TAutoOutLookGroup;
  List : TList;
  sItem : TAutoOutLookStoredItem;
  fItem : TAutoOutLookItem;  
begin
  Bar.Groups.Clear;
  List := TList.Create;
  for i := 0 to Bar.Store.Categories.Count - 1 do begin
    fGroup := Bar.Groups.Add;
    fGroup.Caption := Bar.Store.Categories[i];
    Bar.Store.GetItemsByCategory(Bar.Store.Categories[i], List);
    for j := 0 to List.Count - 1 do begin
      sItem := TAutoOutLookStoredItem(List[j]);
      fItem := fGroup.Items.Add;
      fItem.StoredItem := sItem;
    end;
  end;
  List.Free;
end;


procedure TFAutoOutLookBarEditor.ECustomDataExit(Sender: TObject);
begin
  Bar.SelectedItem.CustomData := ECustomData.Text;
end;

procedure TFAutoOutLookBarEditor.ETagKeyPress(Sender: TObject;
  var Key: Char);
begin
  if((Key < '0') Or (Key > '9')) And (Key <> Char(VK_BACK))
  And ((Key <> '-') Or ((ETag.Text <> '') And (ETag.Text <> ETag.SelText))) then begin
    Key := #0;
    MessageBeep(0);
  end;
end;

procedure TFAutoOutLookBarEditor.ETagExit(Sender: TObject);
begin
  if(ETag.Text = '-') then
    ETag.Text := '-1';
  Bar.SelectedItem.Tag := StrToInt(ETag.Text);
end;

procedure TFAutoOutLookBarEditor.bHelpClick(Sender: TObject);
begin
  Application.HelpFile := 'aob_ps.hlp';
  Application.HelpContext(10004);
end;

procedure TFAutoOutLookBarEditor.BarChangeSelectedItem(Sender: TObject);
begin
  if(Bar.SelectedItem <> Nil) And (OldSelectedGroup <> Nil)
  And (OldSelectedIndex < OldSelectedGroup.Items.Count) then begin
   with OldSelectedGroup.Items[OldSelectedIndex] do begin
     CustomData := ECustomData.Text;
     OldSelectedGroup.Items[OldSelectedIndex].Hint := EHint.Text;
     if(ETag.Text = '-') then ETag.Text := '-1';
     if(ETag.Text = '') then ETag.Text := '0';
     Tag := StrToInt(ETag.Text);
   end;
  end;
  if(Bar.SelectedItem = Nil) then
    SelectItem
  else begin
    OldSelectedIndex := Bar.SelectedItem.Index;
    OldSelectedGroup := Bar.SelectedItem.Group;
  end;
  ECustomData.Enabled := Bar.SelectedItem <> Nil;
  ETag.Enabled := Bar.SelectedItem <> Nil;
  BIDelete.Enabled := ETag.Enabled;
  BIClear.Enabled := ETag.Enabled;
  BIMoveUp.Enabled := ETag.Enabled;
  BIMoveDown.Enabled := ETag.Enabled;
  SILarge.Enabled := ETag.Enabled;
  SISmall.Enabled := ETag.Enabled;
  ECaption.Enabled := ETag.Enabled;
  EHint.Enabled := ETag.Enabled;
  BIDefault.Enabled := ETag.Enabled;
  if(ECustomData.Enabled) then begin
    ECustomData.Text := Bar.SelectedItem.CustomData;
    EHint.Text := Bar.SelectedItem.Hint;
    ETag.Text := IntToStr(Bar.SelectedItem.Tag);
    SILarge.ItemIndex := Bar.SelectedItem.LargeImage;
    SISmall.ItemIndex := Bar.SelectedItem.SmallImage;
    ECaption.Text := Bar.SelectedItem.Caption;
  end else begin
    ECustomData.Text := '';
    EHint.Text := '';
    ECaption.Text := '';
    ETag.Text := '';
    SILarge.ItemIndex := -1;
    SISmall.ItemIndex := -1;
  end;
end;

procedure TFAutoOutLookBarEditor.SILargeChange(Sender: TObject;
  ItemIndex: Integer);
begin
  if(Bar.SelectedItem <> Nil) then
    Bar.SelectedItem.LargeImage := ItemIndex;
end;

procedure TFAutoOutLookBarEditor.SISmallChange(Sender: TObject;
  ItemIndex: Integer);
begin
  if(Bar.SelectedItem <> Nil) then
    Bar.SelectedItem.SmallImage := ItemIndex;
end;

procedure TFAutoOutLookBarEditor.BarChangeActiveGroup(Sender: TObject);
begin
  BGDelete.Enabled := Bar.ActiveGroup <> Nil;
  BGRename.Enabled := BGDelete.Enabled;
  CBGIType.Enabled := BGDelete.Enabled;
  if(Bar.ActiveGroup <> Nil) then
    CBGIType.Checked := Bar.ActiveGroup.IconType = aotLargeIcon;
end;

procedure TFAutoOutLookBarEditor.ECaptionChange(Sender: TObject);
begin
  if(Bar.SelectedItem <> Nil) then
    Bar.SelectedItem.Caption := ECaption.Text;
end;

procedure TFAutoOutLookBarEditor.BIDefaultClick(Sender: TObject);
begin
  Bar.SelectedItem.IsDefault := True;
  ECaption.Text := Bar.SelectedItem.Caption;
  ECaption.Hint := Bar.SelectedItem.Hint;
  SILarge.ItemIndex := Bar.SelectedItem.LargeImage;
  SISmall.ItemIndex := Bar.SelectedItem.SmallImage;  
end;

procedure TFAutoOutLookBarEditor.LBStoredItemsDragOver(Sender,
  Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
  if(Source = Bar) And  (AutoOutLookBarDragObject <> Nil) then begin
    AutoOutLookBarDragObject.DeleteItem := True;
    Accept := True;
  end;  
end;

procedure TFAutoOutLookBarEditor.LBStoredItemsDragDrop(Sender,
  Source: TObject; X, Y: Integer);
begin
  if(Source = Bar) then
    Bar.SelectedItem.Free;
end;

procedure TFAutoOutLookBarEditor.EHintChange(Sender: TObject);
begin
  if(Bar.SelectedItem <> Nil) then
    Bar.SelectedItem.Hint := EHint.Text;
end;

procedure TFAutoOutLookBarEditor.BGUpClick(Sender: TObject);
Var
  gr : TAutoOutLookGroup;
begin
  if(Bar.ActiveGroup.Index > 0) then begin
    gr := Bar.ActiveGroup;
    Bar.ActiveGroup.Index := Bar.ActiveGroup.Index - 1;
    Bar.ActiveGroupIndex := gr.Index;
    Bar.Repaint;
  end;
end;

procedure TFAutoOutLookBarEditor.BGDownClick(Sender: TObject);
Var
  gr : TAutoOutLookGroup;
begin
  if(Bar.ActiveGroup.Index < Bar.Groups.Count - 1) then begin
    gr := Bar.ActiveGroup;
    Bar.ActiveGroup.Index := Bar.ActiveGroup.Index + 1;
    Bar.ActiveGroupIndex := gr.Index;
    Bar.Repaint;
  end;
end;

end.

⌨️ 快捷键说明

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