A recent development with delphi, uses DbGrid control, you want to click the right mouse button pop-up menu on the control
The association DbGrid Popupmenu touches can be achieved, but the effect of this is regardless of where you click the right mouse button
As long as there will be pop-up menu in the DBGrid, I want to just pop in the data area, checked on the net N more information, we do not find a satisfactory
Accidentally found that when DbGrid on the right-click when the mouse when the data area will not trigger the MouseDown event
So I wanted to use to distinguish MouseUp and MouseDown The mouse is not in the data area, then the pop-up menu
First, define a global variable:
var ShowPopupMenu: Boolean = true; // default, the popup menu may
Then define the MouseDown event when the mouse when the non-data zone will trigger an event, this time will be set to False ShowPopMenu
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->procedure TForm1.gridAccountMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Button = mbright) then begin ShowPopupMenu := False; end; end;
When the mouse up to determine whether ShowPopupMenu is true in the MouseUp event in
Highlighting Produced by the code Actipro CodeHighlighter Code (Freeware) HTTP: // www.CodeHighlighter.com/-->procedure TForm1.gridAccountMouseUp (Sender: TObject; the Button: TMouseButton; the Shift: TShiftState; X-, the Y: Integer); the begin IF ( = mbright the Button) and ShowPopupMenuthen the begin IF (gridAccount.SelectedField <> nil ) the then // if there is data the begin // pop-up menu to End ; End ; showpop: = True; End ;
This can be achieved when the data area of the pop-up context menu
Note: Since I was a novice can only use this method to achieve a stupid, If any man hoping to have a better way to inform thx.