Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
497 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (4)


Design-Time Component About Box DialogFormat this article printer-friendly!Bookmark function is only available for registered users!
Delphi 6 Solution to a dsgnintf problem
Product:
Delphi 6.x (or higher)
Category:
VCL-General
Skill Level:
Scoring:
Last Update:
06/10/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet dsgnintf DesignIntf DesignEditors Design-Time Run-Time
Times Scored:
1
Visits:
3266
Uploader: Mike Heydon
Company: EOH
Reference: mheydon@eoh.co.za
 
Question/Problem/Abstract:
When I write a component I like to add an "About" property that displays an info dialog box diplaying the component version number and a brief description. In Delphi 5 I achieved this by using a Property Editor and Registering it within the component. Converting to Delphi 6 gave me a problem. Firstly the unit "dsgnintf" is no longer part of Delphi and secondly the supplied replacments "DesignIntf" and "DesignEditors" compile to a non-distributable EXE file. ("proxies.dcu" is part of the design-time non-distributable package).

What now ?

Surfing the web came up with solutions of creating BOTH run-time and design-time units. Whilst this is fine for a serious or complicated property editor, I did not wish to go these lengths for a simple about property.

The solution I have now adopted does the trick for me and is implemented as follows ..

Declare a property of boolean.
Display the info dialog box when set to true. (set to false after display)

This allows double clicking the false/true value (or selecting true) at design time, and if needed can be set at run-time by

MyComponent.About := true;
Answer:




Stripped down skeleton example ....

interface
uses Dialogs;

type
  TLogFile = class(TComponent)
  private
    { Private declarations }
    ...
    FAbout : boolean;
    ...
    ...
    procedure SetAbout(Value : boolean);
    ...
  protected
    { Protected declarations }
    ...
  public
    { Public declarations }
    ...  
  published
    { Published declarations }
    ...
    property About : boolean read FAbout write SetAbout;
    ...
  end;


implementation


procedure TLogFile.SetAbout(Value : boolean);
const CrLf = #13#10;
var msg : string;
begin
  if Value then begin
    // Display your dialog message here
    msg := 'TLogFile v1.2' + CrLf  + CrLf  +
           'ASCII Log File Component.' + CrLf  +
           'Logs to EXEPATH/.log' + CrLf  +
           'Automatically Truncates and moves to Archive' + CrLf  +
           'Log File (Extention .olg) after MaxLogSize.' + CrLf  +
           '(32 bit version - DELPHI VI)' + CrLf  + CrLf  +
           'Copyright © 2002 Mike Heydon';
    MessageDlg(msg, mtInformation, [mbOK], 0);
  end;

  FAbout := false;
end;








Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
A better approach.
    Abdulaziz Jasser (Jun 10 2002 6:33PM)

I personally prefer to use Windows Standard About box.  Example:

.......................................................................................................
var
          oIcon : TIcon;
begin
          oIcon := TIcon.Create;

          //Get the icon from an ImageList.
          ImageList1.GetIcon(0,oIcon);
          //or Load the icone from a file.
          oIcon.LoadFromFile('MyLogo.ico');

          //Now display the Windows standard About Box.
          ShellAbout(self.Handle, PChar('My Product Name'),PChar('Copyright (C) 1991-2000 MyCompany Est.'), HICON(oIcon.Handle));

          //NOTE: If you do not have an icon to show, pass it as nil.

          oIcon.Free;
.......................................................................................................

Abdulaziz Jasser
Respond

RE: A better approach.
sdvf xvbb (Feb 2 2008 4:56PM)

yes
Respond

WARNING: BE AWARE OF THE FOLLOWING
    César Nicolás Peña Núñez (Jun 10 2002 12:15PM)

If you use this method this about code will compile to your executable, if you accidentally try to change the property you will display the about box.

Also as another side effect this about code will be streamed to the .DFM file if used as a component
Respond

RE: WARNING: BE AWARE OF THE FOLLOWING
Mike Heydon (Jun 10 2002 12:38PM)

I am aware of the above. The components I use the "About Box" in tend to be on the large size and the extra code compared to the actual component code size is normally minimal. I suppose one could put this information as a comment in the component source, but I am looking for a way for the DCU to contain version and other info. I am busy trying to implement a design-time class (TAboutProperty), but have not got my mind around sepparating the run-time and design-time code yet.

I anyone uses the sepparated code method I would appreciate a simple example.
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
R. Lefter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)