有那位知道Code Insight是如何实现的,给个思路也成 有那位知道Code Insight是如何实现的,给个思路也成就如在DELPHI里的那样功能望各位大侠不吝赐教,先谢了^_^ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该是通过Open Tools API编程,生成相应的包,在IDE中使用。就像Wizard或者叫Expert那样!这方面的资料不太多,我也不太精只看过一本有相关介绍的书 《Delphi6应用开发指南》——清华大学出版社出版的可以到Google上搜搜,国外有些站点会多些介绍(我的e文太p了!)还听说了一本李维翻译的,好像叫《Delphi3.x奥秘》之类的有介绍,就是没找到!多多交流:) 后一本偶没搜到前一本偶DOWN下来它跟偶说解压要密码,晕那位能给介绍一下具体怎么做的么 我认为delphi的ide同时也有一些简单的类似编译的功能,不断更具程序的更新归出类的结构,然后在你需要的时候将某个类的子方法或成员显示出来可是,这个功能可是vb和delphi曾经比拼过的功能,反正以我的水平恐怕是做不出来吧,最好是懂一点编译原理。 偶也知道和编译原理有关,关键是我的编译原理不是很好(简直就是很菜)可我还是想问在DELPHI里如何实现的谁能告诉我方法或者思路也成 别听编译原理胡说,那个不是你的要求~!如果说编译原理有关的话,我说跟汇编有关呢~!并不是这样的原理,这个原理应该跟showhint的原理类似 什么??showhint??你是指鼠标移动到某个控件上时显示的tooltip吗??你才不要瞎说呢这种功能根本不成问题,关键的是显示的内容。 Code insight? 相当于做一个语法分析器吧,这可不是一个贴子能找到解答的问题。pazze说得不错,看看编译原理吧。 先谢谢几位的帮忙,我现在正在跟一个人做一个解释器(呵呵,他是高手,偶只是跟着学得)他以前已经完成了很多,语法分析及词法分析的功能,但是现在想添加Code Insight功能我想问像 westfly(西翔) 所说的"在然后在光标处创建一个列表选择框"应该怎么做,我听说好像有个API函数能让窗口显示在最上层,但偶实在是不知道是那个查了一下手头的资料也没找到,希望各位能指点一二麻烦各位了 给个例子给你,当然,你的实现应该不会这么简单的,仅供参考:=============================================================unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Printers, StdCtrls, ComCtrls, Clipbrd;type TSymbolInsightListBox = class(TCustomListBox) private fEditor: TMemo; procedure WMCancelMode(var Message: TMessage); message WM_CancelMode; procedure SetEditor(const Value: TMemo); protected procedure CreateParams(var Params: TCreateParams); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Notification(aComponent: TComponent; aOperation: TOperation); override; public constructor Create(aOwner: TComponent); override; procedure Show(aCaretPos: TPoint); procedure Hide; property Editor: TMemo read fEditor write SetEditor; end; TForm1 = class(TForm) Memo1: TMemo; procedure Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormCreate(Sender: TObject); private { Private declarations } fSymbolInsight: TSymbolInsightListBox; protected public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}{ TSymbolInsightListBox }constructor TSymbolInsightListBox.Create(aOwner: TComponent);begin inherited; Visible := False;end;procedure TSymbolInsightListBox.CreateParams(var Params: TCreateParams);begin inherited CreateParams(Params); Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;end;procedure TSymbolInsightListBox.Hide;begin Visible := False;end;procedure TSymbolInsightListBox.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var I, vSelStart: Integer;begin inherited; //下面是简单的插入代码 I := ItemAtPos(Point(X, Y), True); if (I > -1) and (fEditor <> nil) then begin vSelStart := fEditor.SelStart; fEditor.SelText := Items[I]; if fEditor.Visible then fEditor.SelStart := vSelStart + Length(Items[I]); end; if fEditor <> nil then fEditor.SetFocus; Hide;end;procedure TSymbolInsightListBox.Notification(aComponent: TComponent; aOperation: TOperation);begin inherited; if (aComponent = fEditor) and (aOperation = opRemove) then fEditor := nil; end;procedure TSymbolInsightListBox.SetEditor(const Value: TMemo);begin if fEditor <> nil then fEditor.RemoveFreeNotification(Self); fEditor := Value; if fEditor <> nil then fEditor.FreeNotification(Self);end;procedure TSymbolInsightListBox.Show(aCaretPos: TPoint);begin Left := aCaretPos.X; Top := aCaretPos.Y; Visible := True;end;procedure TSymbolInsightListBox.WMCancelMode(var Message: TMessage);begin Visible := False;end;procedure TForm1.FormCreate(Sender: TObject);begin fSymbolInsight := TSymbolInsightListBox.Create(Self); fSymbolInsight.Parent := Self; fSymbolInsight.Editor := Memo1;end;procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);var vCaretPos: TPoint; vSize: TSize; vDC: HDC;begin if (Key = VK_ESCAPE) and (Shift = []) then fSymbolInsight.Hide else if (fSymbolInsight.Visible and not (Key in [VK_UP, VK_DOWN, VK_LEFT_RIGHT])) or ((Shift = [ssCtrl]) and (Key = VK_SPACE)) then begin //再这里分析上下文,决定listbox的内容 fSymbolInsight.Clear; fSymbolInsight.Items.Add('procedure Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState)'); GetCaretPos(vCaretPos); vDC := GetDC(Memo1.Handle); try GetTextExtentPoint(vDC, 'H', 1, vSize); finally if (GetClassLong(Memo1.Handle, GCL_STYLE) or CS_OWNDC) = 0 then ReleaseDC(Memo1.Handle, vDC); end; vCaretPos.Y := vCaretPos.Y + vSize.cy + 1; vCaretPos := Memo1.ClientToParent(vCaretPos); fSymbolInsight.Show(vCaretPos); end; //else 设置ListBox的ItemIndex等等动作end;end. 把上面的改进一下,应该会更好:procedure TSymbolInsightListBox.CreateParams(var Params: TCreateParams);begin inherited CreateParams(Params); Params.WndParent=0; Params.ExStyle=Params.ExStyle or WS_EX_PALETTEWINDOW; //Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;end; 我倒,又忘了改“=”!把上面的改进一下,应该会更好:procedure TSymbolInsightListBox.CreateParams(var Params: TCreateParams);begin inherited CreateParams(Params); Params.WndParent:=0; Params.ExStyle:=Params.ExStyle or WS_EX_PALETTEWINDOW; //Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;end; 谢谢各位,问题才解决,所以结贴也就晚了点偶现在实现的功能很简单,只是查找预先定义好的函数,不过以后会慢慢改进的偶先查找光标所在的位置,在该位置处创建了一个listbox,将以前已经定义好的函数写入,同时赋相应的事件(如回车,上下键,Esc键,以及文本输入区change事件等)当选定相应的函数之后,取出函数名,然后向左查找一直找到行的起始位置或者遇到截至符停止,再向右查找也是找到头或截至符为止(截止符由自己定义,如空格,分号等),然后选中这一区域,用选择的函数替换区域里的字体。以后还会添加功能:如分析前一个变量是那一种类型的变量,然后在函数列表或变量列表里筛选后再显示;输入一个过程后,过程变量类型需要的showhint提示等,暂时就想到这些,估计又够偶忙一阵了。谢谢各位的帮忙!!!! 在上面帮忙的各位大侠别忘了到http://expert.csdn.net/Expert/topic/1238/1238492.xml?temp=.5250666上‘登陆’一下,偶把分散了好结贴,呵呵这样结贴率就可以100%了祝各位圣诞快乐!! WindowsMediaPlayer播放发生invalid floating point operation 应当怎么做? 怎样得到一个panel在窗口中的实际位置 我结婚了 哪位大哥帮我解决一个问题?我是新手啊! 更改.exe程序中的汉字 有趣的图形算法问题-----使图形加载更快,我想实现如下功能,请指教一下,用什么方法可以使它运行最快. 关于通讯的多字节传输 2万元/月招聘图形处理高手! Delphi调试DLL,OCX时怎样才能不用重启? 大四了快毕业了,签不到"招人不招证"的单位,郁闷中... 报表
生成相应的包,在IDE中使用。
就像Wizard或者叫Expert那样!
这方面的资料不太多,我也不太精
只看过一本有相关介绍的书 《Delphi6应用开发指南》——清华大学出版社出版的
可以到Google上搜搜,国外有些站点会多些介绍(我的e文太p了!)
还听说了一本李维翻译的,好像叫《Delphi3.x奥秘》之类的有介绍,就是没找到!多多交流:)
前一本偶DOWN下来它跟偶说解压要密码,晕
那位能给介绍一下具体怎么做的么
可是,这个功能可是vb和delphi曾经比拼过的功能,反正以我的水平恐怕是做不出来吧,最好是懂一点编译原理。
关键是我的编译原理不是很好(简直就是很菜)可我还是想问在DELPHI里如何实现的
谁能告诉我方法或者思路也成
你才不要瞎说呢这种功能根本不成问题,关键的是显示的内容。
我现在正在跟一个人做一个解释器(呵呵,他是高手,偶只是跟着学得)
他以前已经完成了很多,语法分析及词法分析的功能,
但是现在想添加Code Insight功能我想问像 westfly(西翔) 所说的"在然后在光标处创建一个列表选择框"应该怎么做,
我听说好像有个API函数能让窗口显示在最上层,但偶实在是不知道是那个
查了一下手头的资料也没找到,希望各位能指点一二
麻烦各位了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Printers, StdCtrls, ComCtrls, Clipbrd;type
TSymbolInsightListBox = class(TCustomListBox)
private
fEditor: TMemo;
procedure WMCancelMode(var Message: TMessage); message WM_CancelMode;
procedure SetEditor(const Value: TMemo);
protected
procedure CreateParams(var Params: TCreateParams); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
override;
procedure Notification(aComponent: TComponent; aOperation: TOperation);
override;
public
constructor Create(aOwner: TComponent); override;
procedure Show(aCaretPos: TPoint);
procedure Hide;
property Editor: TMemo read fEditor write SetEditor;
end; TForm1 = class(TForm)
Memo1: TMemo;
procedure Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
fSymbolInsight: TSymbolInsightListBox;
protected public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TSymbolInsightListBox }constructor TSymbolInsightListBox.Create(aOwner: TComponent);
begin
inherited;
Visible := False;
end;procedure TSymbolInsightListBox.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
end;procedure TSymbolInsightListBox.Hide;
begin
Visible := False;
end;procedure TSymbolInsightListBox.MouseUp(Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
I, vSelStart: Integer;
begin
inherited; //下面是简单的插入代码
I := ItemAtPos(Point(X, Y), True);
if (I > -1) and (fEditor <> nil) then
begin
vSelStart := fEditor.SelStart;
fEditor.SelText := Items[I];
if fEditor.Visible then
fEditor.SelStart := vSelStart + Length(Items[I]);
end; if fEditor <> nil then
fEditor.SetFocus; Hide;
end;procedure TSymbolInsightListBox.Notification(aComponent: TComponent;
aOperation: TOperation);
begin
inherited;
if (aComponent = fEditor) and (aOperation = opRemove) then
fEditor := nil;
end;procedure TSymbolInsightListBox.SetEditor(const Value: TMemo);
begin
if fEditor <> nil then fEditor.RemoveFreeNotification(Self);
fEditor := Value;
if fEditor <> nil then fEditor.FreeNotification(Self);
end;procedure TSymbolInsightListBox.Show(aCaretPos: TPoint);
begin
Left := aCaretPos.X;
Top := aCaretPos.Y;
Visible := True;
end;procedure TSymbolInsightListBox.WMCancelMode(var Message: TMessage);
begin
Visible := False;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
fSymbolInsight := TSymbolInsightListBox.Create(Self);
fSymbolInsight.Parent := Self;
fSymbolInsight.Editor := Memo1;
end;procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
vCaretPos: TPoint;
vSize: TSize;
vDC: HDC;
begin
if (Key = VK_ESCAPE) and (Shift = []) then
fSymbolInsight.Hide
else if (fSymbolInsight.Visible and not (Key in [VK_UP, VK_DOWN, VK_LEFT_RIGHT]))
or ((Shift = [ssCtrl]) and (Key = VK_SPACE)) then
begin
//再这里分析上下文,决定listbox的内容
fSymbolInsight.Clear;
fSymbolInsight.Items.Add('procedure Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState)'); GetCaretPos(vCaretPos);
vDC := GetDC(Memo1.Handle);
try
GetTextExtentPoint(vDC, 'H', 1, vSize);
finally
if (GetClassLong(Memo1.Handle, GCL_STYLE) or CS_OWNDC) = 0 then
ReleaseDC(Memo1.Handle, vDC);
end;
vCaretPos.Y := vCaretPos.Y + vSize.cy + 1;
vCaretPos := Memo1.ClientToParent(vCaretPos);
fSymbolInsight.Show(vCaretPos);
end;
//else 设置ListBox的ItemIndex等等动作
end;
end.
begin
inherited CreateParams(Params);
Params.WndParent=0;
Params.ExStyle=Params.ExStyle or WS_EX_PALETTEWINDOW;
//Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
end;
begin
inherited CreateParams(Params);
Params.WndParent:=0;
Params.ExStyle:=Params.ExStyle or WS_EX_PALETTEWINDOW;
//Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
end;
偶先查找光标所在的位置,在该位置处创建了一个listbox,将以前已经定义好的函数写入,同时赋相应的事件(如回车,上下键,Esc键,以及文本输入区change事件等)
当选定相应的函数之后,取出函数名,然后向左查找一直找到行的起始位置或者遇到截至符停止,再向右查找也是找到头或截至符为止(截止符由自己定义,如空格,分号等),然后选中这一区域,用选择的函数替换区域里的字体。
以后还会添加功能:如分析前一个变量是那一种类型的变量,然后在函数列表或变量列表里筛选后再显示;输入一个过程后,过程变量类型需要的showhint提示等,暂时就想到这些,估计又够偶忙一阵了。谢谢各位的帮忙!!!!
别忘了到http://expert.csdn.net/Expert/topic/1238/1238492.xml?temp=.5250666
上‘登陆’一下,偶把分散了好结贴,呵呵这样结贴率就可以100%了
祝各位圣诞快乐!!