好象getcaretpos就可以得到一个tpoint,随着光标的移动变化..但如何通过这个值在memo中创建一个值比如 combobox就象delphi的ide一样, 输入个点..就出来选择的那种..
不需要synedit之类的吧..
不需要synedit之类的吧..
解决方案 »
- 获得鼠标下所有的窗口句柄?windowfrompos只能一个?!!
- 怎样用delphi开发directshow播放mpeg
- 我在程序中使用了WindowsMediaPlayer控件,在打开一个失效的wmv连接时,会....
- RAS 拨号的问题,很急,详细请进!!!
- 在adoquery的sql语句中使用参数,系统提示找不到参数
- 毕业设计课题
- 怎样取一个数值型字段的第三、四位的值?
- DELPHI与WEB SERVLET
- 怎样把一个应用程序和另一个程序合并在一起
- 如何在自己的程序中實現只顯示Word工作區或Excel工作薄而不出現其菜單及工具欄
- ■■■■■■■关于treeview逐级展开的问题!
- 关于多线程的问题!在线等待!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TDemo = class(TForm)
M: TMemo;
LB: TListBox;
procedure MKeyPress(Sender: TObject; var Key: Char);
procedure LBKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
procedure Popup;
{ Private declarations }
public
{ Public declarations }
end;var
Demo: TDemo;implementation
uses Clipbrd;
{$R *.dfm}procedure TDemo.MKeyPress(Sender: TObject; var Key: Char);
var P:TPoint;
begin
if Key='.' then
begin
Popup;
end;
end;procedure TDemo.Popup;
var
AWord : String;
FirstVisibleLine : LongInt;
ATextSize:TSize;
DC:HDC;
AString:String;
P:TPoint;
begin
P:=M.CaretPos;
AString:=Copy(M.Lines[P.Y],1,P.X);
FirstVisibleLine := SendMessage(M.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
DC:=GetWindowDC(M.Handle);
try
SelectObject(DC,M.Font.Handle);
GetTextExtentPoint(DC,PChar(AString),Length(AString),ATextSize);
finally
ReleaseDC(M.Handle,DC);
end;
LB.Top:=M.Top+ATextSize.cy * (P.Y - FirstVisibleLine+1)+4;
LB.Left:=M.Left+ATextSize.CX;
LB.BringToFront;
LB.Show;
Self.ActiveControl:=LB;
LB.ItemIndex:=0;
end;procedure TDemo.LBKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_Return then
begin
if LB.ItemIndex<>-1 then
begin
Clipboard.AsText:=LB.Items[LB.ItemIndex];
M.PasteFromClipboard;
end;
LB.Hide;
ActiveControl:=M;
end;
end;procedure TDemo.FormCreate(Sender: TObject);
begin
with LB.Items do
begin
Add('这是第一行');
Add('这是第二行');
Add('这是第三行');
Add('这是第四行');
Add('这是第五行');
Add('这是第六行');
Add('这是第七行');
Add('这是第八行');
Add('这是第九行');
end;
end;end.
Left = 215
Top = 107
Width = 696
Height = 480
Caption = 'Demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object M: TMemo
Left = 50
Top = 14
Width = 450
Height = 341
Lines.Strings = (
'M')
TabOrder = 0
OnKeyPress = MKeyPress
end
object LB: TListBox
Left = 42
Top = 43
Width = 87
Height = 97
Ctl3D = False
ItemHeight = 13
Items.Strings = (
'111111'
'222222'
'333333'
'444444'
'555555')
ParentCtl3D = False
TabOrder = 1
Visible = False
OnKeyDown = LBKeyDown
end
end