我要求備忘錄自動完成功能。 最終,我希望能夠在用戶按下與Delphi IDE自動完成類似的熱鍵(Ctrl-space)時顯示自定義自動完成列表。德爾福 - 自動完成備忘錄
我有TMS AdvMemo
,但說實話,這個特定組件的幫助是缺乏的。看來AdvMemo支持自定義自動完成,但我似乎無法找到如何顯示列表。
因此,如果任何人有任何建議,將實現在備忘錄自動完成,或者開導我,使用AdvMemo的,我們將不勝感激
我要求備忘錄自動完成功能。 最終,我希望能夠在用戶按下與Delphi IDE自動完成類似的熱鍵(Ctrl-space)時顯示自定義自動完成列表。德爾福 - 自動完成備忘錄
我有TMS AdvMemo
,但說實話,這個特定組件的幫助是缺乏的。看來AdvMemo支持自定義自動完成,但我似乎無法找到如何顯示列表。
因此,如果任何人有任何建議,將實現在備忘錄自動完成,或者開導我,使用AdvMemo的,我們將不勝感激
我決定使用TPopupmenu作爲自動完成列表,爲TMemo編寫一些處理程序。
對於那些閱讀,請參考我的另一篇: Delphi - Get the whole word where the caret is in a memo(感謝RRUZ)
以下代碼: OnPopup爲自動完成TPopupMenu:(memoAutoComplete持有自動完成的項目清單)
procedure AutoCompletePopup(Sender: TObject);
var i : integer;
NewItem : TMenuItem;
AutoCompleteToken: String;
begin
//filter list by token
AutoCompleteToken := SelectWordUnderCaret(edtComment);
AutoComplete.Items.Clear;
for i:=0 to memoAutoComplete.Lines.Count -1 do
begin
if SameText(LeftStr(memoAutoComplete.Lines.Strings[i],Length(AutoCompleteToken)),AutoCompleteToken) then
begin
NewItem := TMenuItem.Create(AutoComplete);
NewItem.Caption := memoAutoComplete.Lines.Strings[i];
NewItem.OnClick := AutoComplete1Click;
NewItem.OnMeasureItem := AutoComplete1MeasureItem;
NewItem.OnAdvancedDrawItem := AutoComplete1AdvancedDrawItem;
AutoComplete.Items.Add(NewItem);
end;
end;
end;
而對於Tmemo:
procedure Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var pt : TPoint;
begin
if (Key = VK_SPACE) and (GetKeyState(VK_CONTROL) < 0) then
begin
pt := Memo1.ClientToScreen(Point(0,Memo1.Height));
AutoComplete.Popup(pt.X,pt.Y);
end;
end;
+1創意使用的popupmenu。 – Johan 2011-06-14 19:24:41
也許最好的方式來獲得一些幫助可能是聯繫組件供應商,而不是公開說它(或它的文檔)*糟糕*? – 2011-06-14 02:26:46
我必須詳細說明,其他TMS文檔是好的,它只是這個特定的組件缺乏。 – Simon 2011-06-14 02:29:11