我有一个按预期工作的弹出菜单。同一对象上的拖放功能按预期工作。把它们放在一起,然后...
右键单击时会出现弹出菜单。当菜单仍然存在时,随后在弹出菜单上但仍在对象上的左键单击会调用拖放功能,就好像最初的右键单击是一直保持到现在然后释放的左键单击.
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);
}
}
我做错了什么?我怎样才能解决这个问题?