473,698 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1217
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 'HandleUserEven t'. 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******** ******@tk2msftn gp13.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
1904
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 next level. I really think that the menus and toolbars used in Office 2003 should be added to the .Net Framework as standard controls in the next release of the Framework and VS.NET, codenamed "Visual Studio .Net for Yukon." This would truly take...
4
8570
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 menus/toolbars over.
2
2168
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 the db's creator. Thanks! Heather
1
11314
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 Allow Toolbar/Menu Changes Use Access Special Keys
3
11515
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. Upon restarting Access, when an admin is detected (I use a GetSystemUser() function) I want to restore everything so that Access behaves like normal, ie. all menus/tbars/etc show up (only where they are supposed to show up).
0
3542
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 reconstruct the one you want as a custom menu/shortcut(popup)/toolbar. All this was a long journey in order to allow the user to sort/copy on a datasheet view of a subform, with all the menus disabled in the startup options.
4
1712
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 the app is started and then assign them when the object is clicked on. The first few items in the menus will all be the same (Large Icons, Small Icons, etc.). I create all of those objects, then add them to the first context menu and all is...
0
1166
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 the day) where the menu item and the toolbar item is the same control. In other words, if you disable the toolbar item, the corresponding menu item also gets disabled. Also, a pointer to a good tutorial on using the toolbars/menus with tips...
1
3364
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 the database because I cannot delete anything. I do not have a database password set up, or users with security and rights. I cannot find an option for how I did this and cannot remember how I did it. Any ideas?????
6
3966
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 changes. How do I bring those back as I can't get to TOOLS STARTUP? Help!!!!
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.