你说的是Code Insight,可以到网上找代码,一般可以另外建立一个Form,然后里面放一个Listbox或者ListView等控件,但是需要对你点的时候当前位置前面的那个单词进行分析,
GetCaretPos();
ClientToScreen();
这个两个函数,它的作用在指定位置弹出一个右键菜单,可以根据这个东西弹出一个非模态form,然后选择,
下面的链接供参考,代码是CB的,但是在Delphi里面差不多,我做了一定修改
http://www.delphibbs.com/delphibbs/dispq.asp?lid=105163
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
RE : TRichEdit;
PopTest:TPopupMenu ;
Test1 : TMenuItem ;
procedure REMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.REMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
P : TPoint;
begin
if Button <> mbRight then Exit;
if not GetCaretPos(P) then Exit;
if not Windows.ClientToScreen(RE.Handle, P) then Exit;
PopTest.Popup(p.x,p.y);
end;
end.
object Form1: TForm1
Left = 192
Top = 112
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object RE: TRichEdit
Left = 16
Top = 12
Width = 425
Height = 281
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
ImeName = '中文 (简体) - 拼音加加3.11'
Lines.Strings = (
'#include "Unit1.h"'
'//--------------------------------------------------------------' +
'-----'
'--------'
'#pragma package(smart_init)'
'#pragma resource "*.dfm"'
'TForm1 *Form1;'
'//--------------------------------------------------------------' +
'-----'
'--------'
'__fastcall TForm1::TForm1(TComponent* Owner)'
' : TForm(Owner)'
'{'
'}'
'//--------------------------------------------------------------' +
'-----'
'--------'
'void __fastcall TForm1::REMouseDown(TObject *Sender, TMouseButto' +
'n '
'Button,'
' TShiftState Shift, int X, int Y)'
'{'
' POINT p;'
' if(GetCaretPos(&p)==false)'
' return;'
''
' if
:ClientToScreen(RE->Handle,&p)==false)'
' return;'
' PopTest->Popup(p.x,p.y);'
'}')
ParentFont = False
TabOrder = 0
OnMouseDown = REMouseDown
end
object PopTest: TPopupMenu
Left = 472
Top = 140
object Test1: TMenuItem
Caption = 'Test'
end
end
end