Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 17204, CUSTOM ACTIONS ("pay it forward")

by Derrick Nel Email: Anonymous


3 Custom Actions, which wrap the messagedlg function
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 5.0  to 6.0 225 downloads
Copyright: No significant restrictions


Size: 11,059 bytes
Updated on Thu, 20 Dec 2001 23:47:30 GMT
Originally uploaded on Thu, 20 Dec 2001 23:49:57 GMT
SHA1 Hash: EBAE27A025443540B2BE67371CA4BEE4689E986F
MD5 Hash: 2AFED6CB4E1214385F466A1FD3FF325E

    Explore the files in this upload

Description
PAY IT FORWARD

The Delphi community is great! Tons of tutorials, articles, code snippets, experts and even full applications are posted onto the net by members of the Delphi community daily, and most are free. The unselfish sharing of knowledge by community members has always fascinated me. Color, religion, nationality, social standing and all the other trivial things that divide mankind are not important, no matter who you are, where you come from, there is a entire community willing to teach you Delphi, all you need is the desire.

For the past 2 years I have been an avid student of this community and now I too wish to contribute. It's been all one way thus far, take, take, take, and take, now its time to "pay it forward". First is my first posting of any kind and I hope someone can use this code, I do.

The code.
There are 2 packages, ksMsgActns50 (runtime) and ksMsgActnsDsgn50 (design time), OPEN ksMsgActns50.dpk, do a BUILD ALL, then OPEN ksMsgActnsDsgn50.dpk and INSTALL.

If all goes well you will have just installed 3 custom actions, namely:
· TMsgDlgAction,
· TMsgDlgPosAction,
· and TConfirmationAction.

They are basically actions that wrap the MessageDlg function, the first two allow you to specify the message, required mouse buttons and message dialog type (information, confirmation, warning, error and the custom type). There is an OnClick event that is triggered when the dialog is closed and the ModalResult of the dialog is passed as the second parameter in the event handler (first being SENDER). The MsgDlgPos action also allows you to specify the x and y co-ordinates of where the dialog should be displayed (MessageDlgPos function), the default x co-ordinate is -1, so too is the y co-ordinate, if either are still -1 when the action is invoked the dialog will be centered (MessageDlg function).

There are custom action classes, so creating specific descendants is a fairly simply procedure. The TConfirmationAction is an example of such a descendant, this action always invokes a confirmation dialog box, with a "Yes" and "No" mouse buttons, you can specify the message and pos if required. It has 2 events of note, an OnYesClick and an OnNoClick, useful for all those pesky questions, e.g. "Are you sure, you want to whatever ?". Unfortunately the MessageDlg functions don't support a "Don't ask me this question again." Checkbox with persistence, mmmmm, perhaps I'll look into that….

Some uses.
The confirmation action can be used on delete buttons, confirm the users intention to delete, and write the deletion code in the OnYesClick event handler. You could place an ActionList in a DataModule and all MessageDlg Actions in the ActionList, this would group all of them together in a central place, along with the code to execute on a yes, no, retry, ignore, whatever click.

Anyway, is not much but it is a start!
Constructive criticism is welcome, although not always enjoyed B-)
Here is a list of more actions I have written, but was informed that they now ship with Delphi 6, if anyone wants them drop me an email
· TOpenDialogAction (action invokes open dialog, open picture too),
· TSaveDialogAction (action invokes save dialog, save picture too),
· TFontDialogAction (action invokes font dialog),
· TColorDialogAction (action invokes color dialog),
· TPrintDialogAction (action invokes print dialog, printer setup dialog too),
· TFindDialogAction (action invokes find dialog, replace dialog too).

Derrick Nel (dnel@oldmutual.com)
"Programming in visual basic is like kicking a dead whale down a beach !!"

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03