Right-click menu problem

Category: Delphi -> VCL/Component Author: wangsizhicq Date: 2002-03-19 13:12:16
 
wangsizhicq
2002-03-19 13:12:16
In the same Panel, there are many a GroupBox, I think these GroupBox share a context menu but the menu that pops up context menu is not the same, how to achieve this
feng522
2002-03-19 13:24:58
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ExtCtrls;

type
TForm1 = class (TForm)
Panel1: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
PopupMenu1: TPopupMenu;
N11: TMenuItem;
N21: TMenuItem;
procedure GroupBox1MouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure GroupBox2MouseDown (Sender: TObject; Button: TMouseButton ;
Shift: TShiftState; X, Y: Integer);
private
; {Private declarations}
public
{Public declarations}
end;

var
Form1: TForm1;

implementation

{$ R *. dfm}

procedure TForm1.GroupBox1MouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
PopUpMenu1.Items [0]. Enabled: = False;
PopUpMenu1.Items [ 1]. Enabled: = True;
end;
end;

procedure TForm1.GroupBox2MouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
PopUpMenu1.Items [1]. Enabled: = False;
PopUpMenu1.Items [0]. Enabled: = True;
end;
end;

end.
----------------- two groupbox are used popupmenu1, but not the same pop-up menu
deviltony4
2002-03-19 13:31:20
dynamically create their own Caesar
Zhe_gezhanghao
2002-03-19 13:49:19
GroupBox.Click bound to the same event, and then deal with, playing different menus.
zhumsh
2002-03-19 13:57:59
pressed shift Select All, and then double-click inside the event, the practice is to generate the same event such as a ~ ~
Select property after you modify popmemu memu1; popmemu then all components are is menu1 a ~
gith11s
2002-03-19 14:01:47
dynamically created menu bar.