logo       

Re: Handling lots of menu entries: msg#00413

windows.devel.dotnet.winforms

Subject: Re: Handling lots of menu entries

How would this work if I am using the Forms Designer
(aka Dialog Editor)? I would create my 10 menu itmes
and for a single menu item double click on to create
an event for just that menu entry and go back and edit
the other to add the same event to the other menu
entries using the overloaded "+="?

Where would I do this? In the constructor for the
Form?
If I edit the InitializeComponent funciton generated
by the Dialog editor, do I also have to edit that
.resX file whose format I don't understand? The
InitializeComponent function seems the logical place
to do it (if it does not crash that dialog editor).

Ok, so what do I do in the event hander? Would it look
like this?

MenuItem * pMI = (MenuItem*)sender;
if(pMI == miOpacity100) Opacity = 1.0;
else if (pMI == miOpacity90) Opacity=.9;
else if (pMI == miOpacity80) Opacity=.8;
...

Ugghhh! What do you think? Is that a significant
improvement over having a seperate event handler for
each menu item? Is there a better way?
Sieg



--- Fabian Schmied <fabian.schmied@xxxxxx> wrote:
> Richard Heintze schrieb:
>
> > I wanted to add the ability to change the opacity
> to
> > my GUI app. I added a 10 of menu entries with 10
> > handlers. It was grotesque! Is there a better way?
> >
> > void Form1::Opacity100(System::Object* s,
> > System::EventArgs* e){
> > Opacity = 1.0;
> > }
> > void Form1::Opacity90(System::Object* s,
> > System::EventArgs* e){
> > Opacity = .9;
> > }
> > void Form1::Opacity80(System::Object* s,
> > System::EventArgs* e){
> > Opacity = .8;
> > }
>
> Yes, I believe you should be able to create one
> event handler and check
> the "sender" argument ("s" in your code).
>
> Fabian


__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise