Solved

Configure Component Palette II

Posted on 2002-07-23
4
311 Views
Last Modified: 2010-04-04
Hello,

This was my first question:
In Delphi 6 main menu I choose:
Component --> Configure Palette
Does anybody know how you can export this information
to a file or database?

But I'd like to do more:
Can I get more information about components? (like picture and package information)?

Or is there already a tool to do this?

Greetings,

Wim Baaijens
0
Comment
Question by:wimbaaijens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 100 total points
ID: 7172843
Hi, I've created a sample Delphi 6 wizard just for the fun. Add the following unit to a designtime-only package, compile and install the package. (You'll have to add designide.dcp and vcljpg.dcp to the requires clause in order to compile.)
After successful installation, a new menu item 'Package info...' should appear under 'Help' menu.
Selecting the menu will save component images to .jpg files and produce a .htm file showing the packages, components and component images. HTH, TOndrej

unit PkgInfo;

interface

uses
  Classes, SysUtils, ToolsAPI;

type
  TPackageInfoWizard = class(TNotifierObject, IOTAWizard, IOTAMenuWizard)
  private
    { IOTAWizard }
    procedure Execute;
    function GetIDString: string;
    function GetName: string;
    function GetState: TWizardState;
    { IOTAMenuWizard }
    function GetMenuText: string;
  end;

procedure Register;

implementation

uses
  Windows, Forms, Controls, Dialogs, Graphics, JPEG, ShellAPI;

procedure Register;
begin
  RegisterPackageWizard(TPackageInfoWizard.Create);
end;

{ TPackageInfoWizard private: IOTAWizard}

procedure TPackageInfoWizard.Execute;
var
  I, J: Integer;
  F: TextFile;
  PackageHandle: HMODULE;
  ComponentBitmap: TBitmap;
  ComponentJPEG: TJPEGImage;
  BitmapDir: string;
begin
  ForceCurrentDirectory := True;
  with TSaveDialog.Create(nil) do
    try
      DefaultExt := 'txt';
      Filter := 'HTML files (*.htm)|*.htm|All files (*.*)|*.*';
      FilterIndex := 0;
      Options := [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing];
      Title := 'Save Delphi package information';
      if Execute then
      begin
        Screen.Cursor := crHourglass;
        try
          BitmapDir := ChangeFileExt(FileName, '.');
          Delete(BitmapDir, Length(BitmapDir), 1);
          BitmapDir := BitmapDir + '_files';

          AssignFile(F, FileName);
          Rewrite(F);
          try
            Writeln(F, '<html>');
            Writeln(F, '<title>Delphi package information</title>');
            Writeln(F, '<body>');
            with BorlandIDEServices as IOTAPackageServices do
              for I := 0 to PackageCount - 1 do
                if ComponentCount[I] > 0 then
                begin
                  PackageHandle := GetModuleHandle(PChar(PackageNames[I] + '.bpl'));
                  Writeln(F, '<br><b>', PackageNames[I], '</b><br>');
                  for J := 0 to ComponentCount[I] - 1 do
                  begin
                    if PackageHandle <> 0 then
                    begin
                      ComponentBitmap := TBitmap.Create;
                      try
                        try
                          ComponentBitmap.LoadFromResourceName(PackageHandle, UpperCase(ComponentNames[I, J]));
                          ComponentJPEG := TJPEGImage.Create;
                          try
                            ComponentJPEG.Assign(ComponentBitmap);
                            ForceDirectories(BitmapDir);
                            ComponentJPEG.SaveToFile(IncludeTrailingPathDelimiter(BitmapDir) + ComponentNames[I, J] +
                              '.jpg');
                          finally
                            ComponentJPEG.Free;
                          end;
                        except
                          // suppress error when resource bitmap not found
                        end;
                        Writeln(F, '<img src=".\', IncludeTrailingPathDelimiter(ExtractFileName(BitmapDir)),
                          ComponentNames[I, J], '.jpg', '"> ', ComponentNames[I, J], '<br>');
                      finally
                        ComponentBitmap.Free;
                      end;
                    end;
                  end;
                end;
            Writeln(F, '</body>');
            Writeln(F, '</html>');
          finally
            CloseFile(F);
          end;
          ShellExecute(Application.Handle, 'open', PChar(FileName), nil, PChar(ExtractFilePath(FileName)),
            SW_SHOWNORMAL);
        finally
          Screen.Cursor := crDefault;
        end;
      end;
    finally
      Free;
    end;
end;

function TPackageInfoWizard.GetIDString: string;
begin
  Result := 'TOndrej.PackageInfoWizard';
end;

function TPackageInfoWizard.GetName: string;
begin
  Result := 'Package Info Wizard';
end;

function TPackageInfoWizard.GetState: TWizardState;
begin
  Result := [wsEnabled];
end;

{ TPackageInfoWizard private: IOTAMenuWizard }

function TPackageInfoWizard.GetMenuText: string;
begin
  Result := 'Package Info...';
end;

end.
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7173269
Now that is very cool :)
0
 

Author Comment

by:wimbaaijens
ID: 7173828
Thanks!
It's a very good sample!
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 7173834
I'm glad you liked it :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question