如题
解决方案 »
- 改变RichEdit中字体大小
- 工资终于排到宿舍倒数第1了
- 简单的文本处理问题,求教高手指点!!!!!!
- 关于MainMenu控件的问题,
- 机子是许多.itm文件,是不是病毒,能用什么程序打开吗?我是大菜鸟,请各位大侠帮帮忙!
- 请问哪里有“浏览目录对话狂“控件下啊?
- ado问题
- 如何得到ADOCommand对象执行Insert或者Update后影响的行数啊?
- 报表
- 打开可选择的EXCEL的文件,如何办?
- 算出的百分比不正确。IPlist.Strings[I] := Format('★%5d次★%5f%%★%s', [J,(J/IPlist.Count)*100,IPlist.Strings[I]]);
- 请教高人:如何实现给动态菜单的动态初始化事件?有分
两种情况:
1。开始显示ComboBox时,字符往后移
2。ComboBOX消失,字符往后移
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
ComboBox1: TComboBox;
procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ComboBox1Exit(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FSelStart: Integer;
FSelLength: Integer;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
vPoint: TPoint;
begin
case Key of
VK_INSERT: begin
RichEdit1.Perform(EM_POSFROMCHAR, Integer(@vPoint), RichEdit1.SelStart);
RichEdit1.SelLength := 0;
FSelStart := RichEdit1.SelStart;
///////
Canvas.Font.Assign(RichEdit1.SelAttributes);
FSelLength := 1;
while Canvas.TextWidth(StringOfChar(#32, FSelLength + 1)) < ComboBox1.Width do
Inc(FSelLength);
///////
RichEdit1.SelText := StringOfChar(#32, FSelLength);
ComboBox1.Left := RichEdit1.Left + vPoint.X + 2;
ComboBox1.Top := RichEdit1.Top + vPoint.Y + 1;
ComboBox1.Visible := True;
ComboBox1.SetFocus;
ComboBox1.DroppedDown := True;
end;
end;
end;procedure TForm1.ComboBox1Exit(Sender: TObject);
begin
RichEdit1.SelStart := FSelStart;
RichEdit1.SelLength := FSelLength;
RichEdit1.SelText := ComboBox1.Text;
RichEdit1.ReadOnly := False;
ComboBox1.Visible := False;
end;procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_RETURN: RichEdit1.SetFocus;
VK_ESCAPE: begin
ComboBox1.Text := '';
RichEdit1.SetFocus;
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Visible := False;
end;end.