473,382 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Handling Menus/Toolbars/ContextMenus

Hi,

I'm looking for a decent way to manage Commands in my Application. As in
many applications, a Command can be triggered through various actions
(Click on the Menu, Click on the ContextMenu, Click on the Toolbar, using a
Shortcut).

Is there a common pattern used for managing the creation and state of your
commands, i.e. their visibility, whether they are enabled or not, etc.?

Any opinions, further readings?

Thanks in advance.
--

kind regards,

matthias

--

I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams]
Nov 16 '05 #1
2 1204
Hi Matthias,

I had a same situation in one of my previous project - we had the same
commads that could be triggered from either a toolbar button, a menu item or
other buttons available in the form.

The solution we came up with was this: we used the tag property of the
controls to store a command 'name'. And we set the event handler of each of
these controls to the same method - say 'HandleUserEvent'. From this method,
we would get the tag value of the control and then call another 'DoAction'
method passing the command string. This DoAction method would centrally
manage all the actions to be carried out depending upon the command name.

But note that the MenuItem object doesn't have the tag property as it
doesn't derive from the Control class. To handle that you could store all the
menu items in a hashtable and then store their corresponding command name.
It's just a matter of retrieving that value in the HandleUserEvent method.

You could easily handle the visibility of the controls in the DoAction method.

Will this help?

If you want to handle Undo operations, there is a design pattern on those
lines...but I don't remember the link to that...will let you know.

HTH,
Rakesh Rajan
"Matthias S." wrote:
Hi,

I'm looking for a decent way to manage Commands in my Application. As in
many applications, a Command can be triggered through various actions
(Click on the Menu, Click on the ContextMenu, Click on the Toolbar, using a
Shortcut).

Is there a common pattern used for managing the creation and state of your
commands, i.e. their visibility, whether they are enabled or not, etc.?

Any opinions, further readings?

Thanks in advance.
--

kind regards,

matthias

--

I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams]

Nov 16 '05 #2
Hi,

There is the Command pattern, search the MSDN magazine
msdn.microsoft.com/msdnmag/ I do remember one article about this in the mar
or apr issue from last year ( or the year before :) )

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Matthias S." <matthias@_e_m_v_o_i_d_.de> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
Hi,

I'm looking for a decent way to manage Commands in my Application. As in
many applications, a Command can be triggered through various actions
(Click on the Menu, Click on the ContextMenu, Click on the Toolbar, using a Shortcut).

Is there a common pattern used for managing the creation and state of your
commands, i.e. their visibility, whether they are enabled or not, etc.?

Any opinions, further readings?

Thanks in advance.
--

kind regards,

matthias

--

I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams]

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jason Webb | last post by:
Dear Microsoft, The current "Windows.Forms" controls included in the .Net Framework are good, but in many ways they're pretty basic, and I think it's time that you take Windows.Forms to the...
4
by: Karl Irvin | last post by:
In a 2000, can you transfer custom menus and toolbars to a new Access database. My mdf file is not compiling and I'm importing all data to a new database but don't see a way to get the...
2
by: Heather | last post by:
I'm working on a db that has custom toolbars and menus. So all the commands for editing/designing forms, etc are gone. How do I get the default toolbars and menus back? I have no way to contact...
1
by: cefrancke | last post by:
I have set the Startup properties to the following... All menus, toolbars, etc are turned off plus these are unchecked Allow Full Menus Allow Built-in Toolbars Allow Default Shortcut Menus...
3
by: cefrancke | last post by:
The only reason I ask is that no one has made this subject clear or given a definitive answer. What I would like to do is, after turning off all the menus/tbars/etc using the startup options. ...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
4
by: ssg31415926 | last post by:
I've got a ListView which can show many different types of object. I need to display a ContextMenu whose MenuItems depend on the object type. I was planning to pre-create the ContextMenus when...
0
by: Frank Rizzo | last post by:
I've noticed that the toolbars and menu controls got an overhaul in vs2005. Is there anyway to make them work like they do in 3rd party solutions (like infragistics or devexpress) or MFC (back in...
1
by: bjaeger | last post by:
A few months back I was "playing" with an Access 2000 application I created. I somehow disabled the delete option from all menus, toolbars, and context menus. Now I cannot do any maintenance on...
6
by: terrycr | last post by:
In an attempt to clean up my form I went to TOOLS STARTUP and removed check marks from the following: Allow full menus Allow default shortcut menus Allow built in toolbars Allow toolbar/menu...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.