Solved

Configure Component Palette II

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now