Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2011, 01:47 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default To delphimpd.

Examples on how to create popupmenu during run-time:

http://www.delphi3000.com/articles/a...p?SK=PopupMenu
http://www.delphi3000.com/articles/a...p?SK=PopupMenu
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #2  
Old 01-17-2011, 04:42 PM
delphimpd delphimpd is offline
Senior Member
 
Join Date: Oct 2006
Posts: 701
Default

Like always my Friend.

Thank you So much. I will look into it and work on it.

Thank you so much.

Best regards,
Reply With Quote
  #3  
Old 01-17-2011, 05:39 PM
delphimpd delphimpd is offline
Senior Member
 
Join Date: Oct 2006
Posts: 701
Default

Hum Man!!

I do not know what I am doing wrong this thing is frustrating me already.

the compiler does not recognize the newly created Onclick Events, and I get errors on the MenuItem1Click ("Undeclared Identifier MenuItem1Click)
So is for 2, 3, 4

Here is the entire Unit.

What is it that I am doing wrong?

##@#$$##()&*^&

Excuse my Language!




Code:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var
PopupMenu1 : TPopupMenu;
MenuItem1   : TMenuItem;
begin
PopupMenu1 := TPopupMenu.Create(Self); 
    with PopUpMenu1.Items do 
      begin 
        Add(NewItem('First Menu',0,False,True,MenuItem1Click,0,'MenuItem1'));
        Add(NewItem('Second Menu',0,False,True,MenuItem2Click,0,'MenuItem2')); 
        Add(NewItem('Third Menu',0,False,True,MenuItem3Click,0,'MenuItem3')); 
        Add(NewLine);                       // Adds a separator bar 
        Add(NewItem('Fourth Menu',0,False,True,MenuItem4Click,0,'MenuItem4')); 

      end; 
Button1.PopupMenu := PopupMenu1;

end;

end.
Reply With Quote
  #4  
Old 01-17-2011, 06:02 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

It is late here in this side of the world. However, where is the body of the "MenuItem1Click" procedure? This maybe my last post for tonight, but we will continue this tomorrow.
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #5  
Old 01-17-2011, 06:33 PM
delphimpd delphimpd is offline
Senior Member
 
Join Date: Oct 2006
Posts: 701
Default

LOL Sorry for that my friend go ahead and have a good night.

Yes I this that's what I am missing the freaking Procedure. let me try that

Later and Thanks
Reply With Quote
  #6  
Old 01-17-2011, 06:46 PM
delphimpd delphimpd is offline
Senior Member
 
Join Date: Oct 2006
Posts: 701
Default

Thank You Sir,

That's what it was. I am going to bed too.

Let me display the code so that others can take advantage of the code


Later

Code:
unit Unit2;

interface

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

type
    TForm2 = class(TForm)
    Button1: TButton;
    PopupMenu1: TPopupMenu;
    procedure Button1Click(Sender: TObject);
    procedure MenuItem1Click(Sender: TObject); 
    procedure MenuItem2Click(Sender: TObject); 
    procedure MenuItem3Click(Sender: TObject); 
    procedure MenuItem4Click(Sender: TObject); 
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.MenuItem1Click(Sender: TObject); 
    begin 
      ShowMessage('Menu 1');
    end; 
    procedure TForm2.MenuItem2Click(Sender: TObject); 
    begin 
      ShowMessage('Menu 2');
    end;
    procedure TForm2.MenuItem3Click(Sender: TObject); 
    begin 
      ShowMessage('Menu 3');
    end;
    procedure TForm2.MenuItem4Click(Sender: TObject); 
    begin 
      Application.Terminate; 
    end;

procedure TForm2.Button1Click(Sender: TObject);
var
PopupMenu1 : TPopupMenu;
MenuItem1   : TMenuItem;
begin
PopupMenu1 := TPopupMenu.Create(Self); 
    with PopUpMenu1.Items do 
      begin 
        Add(NewItem('First Menu',0,False,True,MenuItem1Click,0,'MenuItem1'));
        Add(NewItem('Second Menu',0,False,True,MenuItem2Click,0,'MenuItem2')); 
        Add(NewItem('Third Menu',0,False,True,MenuItem3Click,0,'MenuItem3')); 
        Add(NewLine);                       // Adds a separator bar 
        Add(NewItem('Exit',0,False,True,MenuItem4Click,0,'MenuItem4')); 

      end; 
Button1.PopupMenu := PopupMenu1;

end;

end.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.