1
我有一個按預期工作的彈出式菜單。同一對象上的拖放功能按預期工作。把它們放在一起,然後...右鍵單擊TPopupMenu解釋爲拖放
彈出菜單出現,當我右鍵單擊。如果菜單仍然存在,隨後的左鍵單擊關閉彈出菜單,但仍然在該對象上調用拖放功能,就好像最初的右鍵單擊是直到現在一直保留的左鍵單擊,然後釋放。
void __fastcall myGrid::eDragDrop(System::TObject *Sender, System::TObject *Source, int X, int Y)
{
while((Sender != this) && (Sender != NULL))
{
TControl *control = dynamic_cast < TControl * > (Sender);
if(control != NULL)
{
X += control->Left;
Y += control->Top;
Sender = control->Parent;
}
else
{
Sender = NULL;
}
} // while
// Check for a drop onto the Chart
if((Column != NULL)&&(Column->Visible)&& (Column->HeaderIndex>=0))
{
int Xt = X - FHeaderSB->Left + FHorzScroll->Position;
int HeaderIndex = Column->HeaderIndex;
if((Xt > FHeaderSections->Items[HeaderIndex]->Left) && (Xt < FHeaderSections->Items[HeaderIndex]- >Right))
{
Xt -= FHeaderSections->Items[HeaderIndex]->Left;
GotDragDropTime = true;
DragDropTime = Column->GetTimeFromPosition(Xt);
} // if
} // if Visible
if(fDragDrop != NULL)
{
fDragDrop(Sender, Source, X, Y);
}
}
我做了什麼錯了?我怎樣才能解決這個問題?
你能展示一些代碼嗎?你有任何額外的代碼(OnMouseXYZ事件)來顯示彈出或執行拖放? – GolezTrol 2012-08-13 07:56:08
你在這裏顯示的代碼是不相關的,因爲它運行的時間已經太晚了;拖動操作已經開始。你需要弄清楚你是如何到達那裏的。告訴我們您的鼠標事件和您的控件的DragMode屬性。 (另外,這個函數的第一個循環似乎是'this-> ScreenToClient(Sender-> ClientToScreen(x,y))'的重新實現。) – 2012-08-13 12:07:36