在我的Delphi 2009的應用程序,我有這樣的窗口:如何退出我的就地編輯器並在Delphi中處理按鈕?
它有一個具有上所有紙張操作下就可以了TTabSheet以及按鈕的TPageControl。
在TTabSheet的左邊是一個TElXTree(LMD的樹/網格組件),而在TTabSheet的右邊是一個TPanel,其中包含特定於此工作表的按鈕。
當我在TElXTree中選擇了一行,並且我點擊了任意一組按鈕中的按鈕時,按鈕都正常工作。
現在在TElXTree中,標有「Text」的列可以使用隨TElXtree提供的Inplace-Editor進行編輯。當我點擊文本時,它進入編輯模式。
當處於編輯模式時,當我點擊TElXTree中的任意位置時(例如在複選框上),它將退出編輯器並處理命令(即選中或取消選中複選框)。但是,在編輯模式下,當我點擊任一組按鈕中的任何按鈕時,它將簡單地退出就地編輯器,而不處理按鈕。然後我必須再次點擊該按鈕才能處理該按鈕。
有什麼簡單的,我沒有做或不理解,這將允許我點擊其中一個按鈕,並允許它退出我的就地編輯器和處理按鈕?
跟帖:
感謝@ NGLN的回答,我有我的解決方法。我使用他的Application.OnMessage方法,我以前使用它的一些拖放代碼。我不得不做一些改變,這就是我想出的:
procedure TMainForm.AppMessageHandler(var Msg: TMsg; var Handled: Boolean);
var
P: TPoint;
begin
if Msg.message = WM_LBUTTONDOWN then
if Screen.ActiveControl <> nil then
if Screen.ActiveControl.ClassNameIs('TElInpEdit') then
begin
GetCursorPos(P);
{ When in the inplace editor, I need to go to its parent ElXTree }
{ because the ElXTree does not have the problem. }
{ Only components outside the ElXTree do }
with Screen.ActiveControl.Parent do
if not PtInRect(ClientRect, ScreenToClient(P)) then begin
{ The WM_Killfocus didn't work for me, but it gave me this idea: }
{ 1. Complete the operation, and 2. Simulate the mouse click }
InplaceEdit.CompleteOperation(true);
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
{ Then skip the regular handling of this WM_LBUTTONDOWN }
Handled := true;
end;
end;
end;
看起來像樹組件中的錯誤 –
@PA:即在樹編輯器中處理代碼的就地編輯器。 –