Solved

Configure Component Palette II

Posted on 2002-07-23
4
321 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

Technology Partners: 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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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