📄 sbeditor.pas
字号:
unit SBEditor;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TSpeedbarEditor = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
CommandBevel: TBevel;
Label3: TLabel;
CategoryList: TListBox;
CloseButton: TButton;
HelpButton: TButton;
ResetButton: TButton;
CommandListBox: TListBox;
procedure HelpButtonClick(Sender: TObject);
procedure CategoryListClick(Sender: TObject);
procedure CommandListBoxDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
private
{ Private declarations }
procedure AddItem(ItemName:string);
public
{ Public declarations }
end;
var
SpeedbarEditor: TSpeedbarEditor;
implementation
{$R *.DFM}
procedure TSpeedbarEditor.HelpButtonClick(Sender: TObject);
var
KeyWord:string;
begin
KeyWord:= 'Properties command (SpeedBar context menu)';
Application.HelpCommand(HELP_KEY,longint(KeyWord));
end;
procedure TSpeedbarEditor.AddItem(ItemName:string);
begin
CommandListBox.Clear;
with CommandListBox do
begin
if ItemName = 'File' then
begin
Items.Add('New Application');
Items.Add('Open Project');
Items.Add('Save all');
Items.Add('Close all');
Items.Add('New form');
Items.Add('New unit');
Items.Add('New data module');
Items.Add('Open file');
Items.Add('Save file');
Items.Add('Add file to project');
Items.Add('Remove file from project');
Items.Add('Print active form or unit');
Items.Add('New package');
Items.Add('Exit Handel');
end
else if ItemName = 'Edit' then
begin
Items.Add('Undo');
Items.Add('Redo');
Items.Add('Cut');
Items.Add('Copy');
Items.Add('Paste');
Items.Add('Add to interface');
end
else if ItemName = 'Search' then
begin
Items.Add('Find');
Items.Add('Replace');
Items.Add('Search Again');
Items.Add('Find in files');
Items.Add('Go to line number');
Items.Add('Browse symbol');
end
else if ItemName = 'View' then
begin
Items.Add('View Project Manager');
Items.Add('View Project Source');
Items.Add('View Object Inspector');
Items.Add('View Alignment Palette');
Items.Add('View Browser');
Items.Add('View Breakpoints');
Items.Add('View Call Stack');
Items.Add('View Watches');
Items.Add('Toggle Form/Unit');
Items.Add('Select unit from list');
Items.Add('Select form from list');
Items.Add('View Type Library');
end
else if ItemName = 'Project' then
begin
Items.Add('Compile project');
Items.Add('Build all');
Items.Add('Syntax check');
Items.Add('Information');
Items.Add('Project options');
end
else if ItemName = 'Run' then
begin
Items.Add('Run');
Items.Add('Step over');
Items.Add('Trace into');
Items.Add('Trace to Next Source Line');
Items.Add('Pause');
Items.Add('Show Execution Point');
Items.Add('Add watch');
Items.Add('Add breakpoint');
Items.Add('Evaluate/Modify');
Items.Add('Run to cursor');
Items.Add('Toggle breakpoint');
end
else if ItemName = 'Component' then
begin
Items.Add('Install component');
Items.Add('Install packages');
Items.Add('New component');
end
else if ItemName = 'Tools' then
begin
Items.Add('Environment options');
Items.Add('Repository options');
Items.Add('Configure tools');
end
else if ItemName = 'Help' then
begin
Items.Add('Help contents');
Items.Add('Windows API help');
end
end;
end;
procedure TSpeedbarEditor.CategoryListClick(Sender: TObject);
var
Item:string;
begin
Item:= CategoryList.Items[CategoryList.ItemIndex];
AddItem(Item);
end;
procedure TSpeedbarEditor.CommandListBoxDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
Bitmap:TBitmap;
Offset,PriIndex:Integer;
ResName: array[0..64] of Char;
CommandName,IconName:string;
begin
PriIndex:= 0;
case CategoryList.ItemIndex of
0: PriIndex:= 30000;
1: PriIndex:= 30010;
2: PriIndex:= 30020;
3: PriIndex:= 30030;
4: PriIndex:= 30040;
5: PriIndex:= 30050;
6: PriIndex:= 30060;
7: PriIndex:= 30070;
8: PriIndex:= 30080;
end;
IconName:= IntToStr(PriIndex + Index);
CommandName:= CommandListBox.Items[Index];
with (Control as TListBox).Canvas do
begin
FillRect(Rect);
Offset:= 2;
Bitmap := TBitmap.Create;
try
StrPLCopy(ResName, IconName, SizeOf(ResName));
AnsiUpper(ResName);
Bitmap.Handle := LoadBitmap(hInstance, ResName);
if Bitmap.Handle = 0 then
Bitmap.Handle := LoadBitmap(hInstance, 'DEFAULT');
BrushCopy(Bounds(Rect.Left + 2, Rect.Top, Bitmap.Width, Bitmap.Height),
Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), clWhite);
Offset:= Bitmap.Width + 6;
TextOut(Rect.Left + Offset, Rect.Top+5, CommandName);
finally
Bitmap.Free;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -