type <br>TForm1 = class(TForm) <br> {...} <br>procedure FormMouseDown(Sender: TObject; Button: TMouseButton; <br> Shift: TShiftState; X, Y: Integer); <br><br>private <br> IsMenuOpen: Boolean; <br> procedure WMMENUSELECT(var message: TWMMENUSELECT); message WM_MENUSELECT; <br><br>{...} <br>implementation <br><br>{...} <br><br>procedure TForm1.WMMENUSELECT(var message: TWMMENUSELECT); <br>begin <br> inherited; <br> IsMenuOpen := not ((message.MenuFlag and $FFFF > 0) and <br> (message.Menu = 0)); <br>end; <br><br>procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; <br> Shift: TShiftState; X, Y: Integer); <br>begin <br> if Button = mbRight then <br> with ClientToScreen(Point(X, Y)) do <br> TrackPopupMenuEx(PopupMenu1.Handle, TPM_LEFTALIGN, X, Y, <br> Self.Handle, nil); <br>end; <br>以后判断IsMenuOpen就行了。