Mega Code Archive

 
Categories / Delphi / Forms
 

Design Time Component About Box Dialog

Title: Design-Time Component About Box Dialog Question: 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;