Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - Creating an About Box Plug-in
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Creating an About Box Plug-in
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-11-20

    Table of Contents:
  • Creating an About Box Plug-in
  • Continuing with our example
  • Creating a package
  • Adding some more code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating an About Box Plug-in - Creating a package


    (Page 3 of 4 )

    Now we need to create a package, so select File|New|Other and select the package icon. The package editor should appear. Add a form to the package. Then at the bottom of the unit, but before the "end," add the following:

    initialization
      RegisterClass(TForm2);
    finalization
      UnregisterClass(TForm2);

    This will register the Tform class. We do this because we are going to use a new function called "GetClass()" that requires the class to be registered, so that it can find the class when it is called. Form and component classes are automatically registered when the form is loaded. In our case the form is not loaded, so we need to register them in the package, as each unit is initialized when the package is loaded and finalized when the package is unloaded.

    Save the package as MyPlugin1, and then select the options button. You should now see a dialog with some tabs at the top. First, select the "Directories and Conditionals" tab and make sure that the output directory and DCP output directories point to the same directory as your project folder. Then go to the "Descriptions" tab and select "run-time only" in the usage options section. Click OK and you should now be back to the package editor. The form that you added to the package will be used as the "aboutbox" dialog, so try to make it look like one.

    Once you've decorated the form, you can now compile the package. Check that the .bpl file is located in your project folder, as this is now your plug-in. We now need to dynamically link the plug-in to the main application, so close the package editor completely and open up your host application.

    Remember that we are now dealing with a form and not just a routine as with our previous example. So we are going to use different methods to access the routines and forms contained in our plug-in. Our plug-in will expose a class, more specifically, the TForm2 class. So we use the "getclass()" function to retrieve it and then we will need to instantiate that class. This will enable us to call its methods, in other words we will be able to use all the usual methods that are available to a form. The getclass() function returns a registered persistent class, given its name, and has the following syntax:

    function GetClass(const ClassName: string): TPersistentClass;

    That's all we need to do to call the about form that is stored in the plug-in.

    More Delphi-Kylix Articles
    More By Leidago


       · This article explains how to use packages to built a plugin.
     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT