473,756 Members | 8,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is C#'s analogue of Delphi's TAction ?

What is C#'s analogue of Delphi's TAction ?

If there is no one, how to implement the same functionality >

Oleg Subachev
Jan 13 '06 #1
7 8898
Oleg Subachev wrote:
What is C#'s analogue of Delphi's TAction ?

If there is no one, how to implement the same functionality


It would help if you could say what TAction does - otherwise you've
limited yourself to those who know both Delphi and C#.

Joanna? :)

Jon

Jan 13 '06 #2
> It would help if you could say what TAction does

TAction is a class that mainly has two events:
OnExecute - where some real job may be done
and
OnUpdate - where the instance may be enabled/disabled.

Then the TAction instance may be assigned to the special
property of different controls, such as menu item, button,
speed button etc. So that all these controls will perform
the same job on clicking. Also these controls will be
simultaneously enabled/disabled and may share common
Caption, Hint and other properties.

Oleg Subachev
Jan 13 '06 #3
Oleg Subachev wrote:
It would help if you could say what TAction does


TAction is a class that mainly has two events:
OnExecute - where some real job may be done
and
OnUpdate - where the instance may be enabled/disabled.

Then the TAction instance may be assigned to the special
property of different controls, such as menu item, button,
speed button etc. So that all these controls will perform
the same job on clicking. Also these controls will be
simultaneously enabled/disabled and may share common
Caption, Hint and other properties.


I don't believe there's anything similar in the .NET framework.
However, you could create a class which aggregated a list of controls,
and allowed you to manipulate them (enable/disable etc) as a group
(just by looping through the list when you asked the instance to do
something).

Jon

Jan 13 '06 #4
"Jon Skeet [C# MVP]" <sk***@pobox.co m> a écrit dans le message de news:
11************* *********@o13g2 00...legr oups.com...

| It would help if you could say what TAction does - otherwise you've
| limited yourself to those who know both Delphi and C#.
|
| Joanna? :)

You rang ?

TAction is a non-visual component that can be added to a TActionList using a
component editor. Basically, controls like buttons and menu items have an
Action property and a TAction provides a RAD way of specifying what happens
when button or menu item is clicked. It provides an OnHint event where the
Hint value can be supplied as an when required and an OnExecute and OnUpdate
where you can specify what happens when the control is clicked and what how
to alter the client controls' state when things like Enabled or Checked
change. A TAction can be attached to several controls so that there is a
single place where code for a single "Action" like Copy, Cut or Paste, etc
can react to a button, popup menu and main menu for the same action.

To set up a TAction, place a TActionList on a form and then use the
component editor to add TActions to it. Add code to the event handlers and
then hook up whatever controls need to call that Action by setting the
Action property of those controls to one of the Actions in the list.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 13 '06 #5
"Jon Skeet [C# MVP]" <sk***@pobox.co m> a écrit dans le message de news:
11************* *********@g14g2 00...legr oups.com...

| I don't believe there's anything similar in the .NET framework.
| However, you could create a class which aggregated a list of controls,
| and allowed you to manipulate them (enable/disable etc) as a group
| (just by looping through the list when you asked the instance to do
| something).

Oleg, take a look at creating a Component derivative that implements
IExtenderProvid er. Make sure that it is capable of capturing the Click event
of Control. This will set you in a similar direction; I suggest that you
look at the source for TControl, TActionLink and TActionList to see how
Delphi works, and then simplify what you see.

Here's a starter :

[ProvideProperty ("InvokeAction" , typeof(Control) )]
public class ActionProvider : Component, IExtenderProvid er
{
private class Properties
{
private bool invokeAction = false;

public bool InvokeAction
{
get { return invokeAction; }
set { invokeAction = value; }
}
}

private Hashtable properties = new Hashtable();

private EventHandler execute;

public event EventHandler Execute
{
add { execute += value; }
remove { execute -= value; }
}

public ActionProvider( IContainer parent)
{
parent.Add(this );
}

bool IExtenderProvid er.CanExtend(ob ject obj)
{
return obj is Control;
}

private Properties EnsurePropertie sExists(object key)
{
Properties p = (Properties) properties[key];

if (p == null)
{
p = new Properties();

properties[key] = p;
}

return p;
}

[Category("Behav iour")]
[Description("Ca lls centralised event handler for Click event of linked
controls")]
[DefaultValue(fa lse)]
public bool GetInvokeAction (Control c)
{
return EnsurePropertie sExists(c).Invo keAction;
}

public void SetInvokeAction (Control c, bool value)
{
EnsurePropertie sExists(c).Invo keAction = value;

if (value)
c.Click += HandleClick;
else
c.Click -= HandleClick;
}

private void HandleClick(obj ect sender, EventArgs args)
{
if (!DesignMode)
{
Control control = (Control) sender;
if (control != null && execute != null)
{
execute(this, EventArgs.Empty );
}
}
}
}
Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 13 '06 #6
>TAction is a non-visual component that can be added to a TActionList using a
component editor. Basically, controls like buttons and menu items have an
Action property and a TAction provides a RAD way of specifying what happens
when button or menu item is clicked.


Very convenient way of doing things, which is - unfortunately - sorely
lacking from the .NET framework. Makes you wonder why.....

There are a number of free and commercial "replacemen ts" for this
annoyance.

There are a number of pretty straightforward "Delphi-to-C#"
translations up on CodeProject - see these for instance:

Simplifying GUI development with Actions
http://www.codeproject.com/csharp/ac...stprovider.asp

ActionLists for Windows.Forms
http://www.codeproject.com/cs/miscctrl/actionlist.asp

Or there's the commercial package by some former Delphites called
"CommandMas ter" which can be found here:
http://www.componentscience.net/Prod...3/Default.aspx

No personal experience with any of those, though.

Marc
Jan 14 '06 #7
Sergio
2 New Member
nxSharp Actions for .NET - fully functional analog of Delphi ActionList with additional features.

http://nxsharp.com/
Mar 22 '06 #8

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

Similar topics

8
4030
by: achrist | last post by:
I'm aving some trouble getting callbacks from a Delphi DLL back to python working through ctypes. The call from python to the DLL works fine. In the Delphi(5) code: type TCallbackFunc = function(x: Integer): Integer; stdcall;
29
2028
by: noid droid | last post by:
Hi. I've not used C# yet but just ran across a premonition from 2 years ago saying that C# would render C++ obsolete by this time. Has it? Have most corporate developers migrated to C#? Is C++ used for new development or just legacy apps? What about non corporate developers? Microsoft really likes to hype the hell out of their stuff and often they let it fall by the wayside. Like MFC.
6
3167
by: Erva | last post by:
Hi, Is there someone who has moved from Delphi to VS.NET? I'am using Delphi currently but seriously considering to moving VS.NET. I would like to hear if someone has already done that, is it worth of it or should i continue to ude Delphi for new projects. I'am developing mostly desktop apps but in th future also ASP.NET apps. -erva
1
3981
by: BlackTiger | last post by:
How to create analogue of Delphi's 'DataModule'? DataModule is non-visual form, which contains connections to DB, queries, tables, field definitions and relations between tables. All this objects are available for all project's forms and procedeures. Can i implement this in .NET?
10
3170
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; Function SearchPort (Prm1:LongWord) :LongWord; cdecl; External RFID_103_485IO name 'SearchPort';
9
6107
by: Chazza | last post by:
I would like to override a method from an inherited class, but the new method has a different signature to the inherited class. Example: class A { private void Init() { // code } } class B : A {
3
2368
by: lukeharpin | last post by:
Currently I have been developing applications in Delphi 7. Recently I meet up with a friend of mine who previously developed in Delphi, from version 1 - 7. When Delphi 8 .net was release he found too many bugs and switch to C# and loves it. I hope to do the same. However, I have a few hurdles to jump. Firstly my boss is a Delphi nut. I have heard the guy who originally developed Delphi worked on the development of C# ? If so this maybe...
7
6513
by: ray | last post by:
Ah well, it had to happen. Create a new form, minimum size 14cm by 14cm. Anywhere on the form, place 3 lines of any length called scrLineSecond, scrLineMinute and scrLineHour. Set the form's TimerInterval to 1000. In the OnTimer event, past the following:
184
7107
by: jim | last post by:
In a thread about wrapping .Net applications using Thinstall and Xenocode, it was pointed out that there may be better programming languages/IDEs to use for the purpose of creating standalone, single executable apps. My goal is to create desktop applications for use on Windows XP+ OSs that are distributed as single executables that do not require traditional install packages to run. I would like to use a drag and drop UI development...
0
9456
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
9275
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,...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
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
8713
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
7248
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...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.