delphi - How to detect a mouse click for a button with drop down menu -
My question comes from the answer
I'm trying to repeat the behavior of "office" Yes Button "found in the top left hand corner of the Mircosoft Office 2007 UI, especially where the user clicks the button, the popup menu is visible, and the button is reproduced in the" down "position. Remains until the user clicks the mouse on the menu, or on the form And, or even outside of the application.
I need to find this mouse so that I can again in the normal image button, and if I hide the menu as my own popup menu I am using the dialogue.
I am using D6.
thanks for any advice,
present,
Explanation:
Now I realize that when TPopUpMenu is used, its answer is trivial, under incorrect understanding After the popup menu was shown, this main event was left for the fate of the loop, and I have happily coded the code in the past as the diffuser, and a bit upset (but it's fine between friends). Should have been specific, and said:
"How can I detect this mouse when I am using a dialog form such as TPopUpMenu?
Sorry for the confusion
I'm probably missing something, But for at least one popup menu it is easy:
process TForm1.FormCreate (Sender: TObject); Start SpeedButton1.Allowed: = True; SpeedButton1 GroupIndex: = 1 ; Finished; Process TForm1.SpeedButton1Click (Sender: TObject); Var CurPos: TPoint; Started CurPos: Mouse = cursorpage; PopupMenu1.Popup (CurPos.x, CurPos.y); SpeedButton 1. Down: = False; Finished; < / Code>
This works because a popup menu Secondary message is shown using the loop, and clicking it outside is dismissed like clicking on menu item.
If you want to show a form instead of a popup menu You only need to provide the wrapper function, which is turned off the form, only returns when it is above the code in the popup ()
code, for example, Show the modal form You can use the SetCaptureControl ()
method to handle all mouse events, even when the mouse cursor is outside the form area.
Edit:
Some code to get you started - this shows the theory, but is certainly not absolute or optimal. A form is shown instead of the popup menu:
Process TForm1.SpeedButton1Click (Sender: Tubbed); Var PtLeftTop: TPoint; Start PtLeftTop: = ClientScreen (Point (SpeedBugton 1. Left + SpeedButton 1. Wide, SpeedButton 1. Fresh + SpeedButton.1. Highlight)); TForm2.ShowFormAsPopup (PtLeftTop); Speedbutton1 Down: = Falls; End;
The form contains the following code:
Type TForm2 = class (TForm) Process FormCreate (Sender: Tubect); Process formCardDown (sender: tobjject; var key: word; shift: teesoftstate); Process formMouseDown (Sender: Tobage; Button: TMouse Button; Shift: TIFFSTATE; X, Y: Integer); Process form deactivate (sender: tubet); Public-class process ShowFormAsPopup (euphr eft: TPInt); End; // boilerplate snap class process TForm2.ShowFormAsPopup (etop lift: T-point); Var form 2: TForm2; Old Deactivet: TNotifyEvent; Start form 2: = TIFerms 2 Cut (zero); Try OldDeactivate: Deactivate the application. Try the application. Deactivate: = Form 2 Disable form; Form 2. Left: = atoplift.x; Form 2. Top: = AUTOP LIFT; Form2.Show; SetCaptureControl (Form2); While form 2 Make the appropriate application. Processing message; Eventually the application On-Deactivate: = Old Detective; End; Ultimately form 2 Relay; End; End; Process TForm2.FormCreate (Sender: TObject); Start Main performance: = true; End; Process TForm2.FormKeyDown (Sender: TOBject; var key: word; Shift: TShiftState); If key = VK_ESCAPE then visible: = FALSE; End; Process TForm2.FormMouseDown (Sender: TOBject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Var screenpost: tappoint; Start ScreenPos: = ClientScreen (Point (X, Y)); If (screen.po.x left + width) or (ScreenPos.Y> Top + height) then Start Visible: = FALSE; End; End; Process TForm2.FormDeactivate (Sender: TObject); Start Visible: = FALSE; End;
Comments
Post a Comment