In the past, I have written custom components for Borland C++Builder. Some of these were derived from existing components, for example:
class PACKAGE TMyEdit : public TEdit
{
...
}
For some of these, I have also made custom bitmaps for the palette (.dcr files). I know how to create and edit them; that's not the point here.
Nowadays, I'm using a newer version of the IDE, Embarcadero C++Builder XE, and I notice a difference in behaviour for components without a .dcr file.
In the old days, the bitmap on the palette would be the same as the one where the component was derived from. Let's say the TMyEdit had the same bitmap as the TEdit.
But now, these components get a default icon. So all components without a .dcr file look alike on the palette.
I see 2 possible ways to solve this:
Is there perhaps some way to indicate in the source files that I want to inherit the bitmap of the original component?
If that isn't possible, I'll have to create new .dcr files for each new component. Is there a neat way to retrieve the original bitmaps? Perhaps there exists a resource file? Or an option in a wizard that I haven't found yet? If not, I'll have to resort to using Alt-PrtScn and MSPaint. That would work, but it would be tedious.
Related
I use the BitmapStyleDesigner.exe (shipped with delphi xe5) to edit vcl styles to my application.
How can i add a custom component to the styler palette? i want my TMyButton, which inherits TButton, have a different color, shape, etc than the standard TButton.
Can this be done only by editing the style, or do i have to edit the source of TMyButton?
The embarcadero wiki hadn't helped (so far).
Thanks in advance!
Editing the VCL Style file is not enough. Unfortunately the VCL Styles are not designed to be extensible on the manner which your describe, Even if is technical possible do that, what you describe will require a lot of work. because you must modify the source of the Vcl.Themes and the Vcl.Styles units. My recommendation is not modify the style file, instead create a new style hook for your button and implement the paint code your self loading the images from a resource file.
I've read THIS but it's for Delphi 7 and it's not working in 2009. There are a lot of changes between this two versions. In D7 icons are 24x24, in D2009 icons are 16x16... and in D2009 there is no Image Editor for resorces...
I have a unit SuperList.pas with TSuperList class inside and a separete TSuperList.ico (16x16 16 colors) that I want to use it as the tool palette icon for my component.
This is what I tried...
I start Delphi,
File->New->Pakage,
Add.. SuperList.pas,
Project->Resources...->Add.. TSuperList.ico,
I changed Resource Identifier to TSUPERLIST (two times! it seems it has a bug),
Install the pakage,
restart Delphi.
And the icon is still the default one !
Nothing much has changed since Delphi 7. You need to link a bitmap resource whose name is the same as the component. You can use many different tools to make bitmaps and compile resources. Your mistake here is that you've linked an icon rather than a bitmap.
This question has useful details and could possibly be considered a duplicate: Best way to make a component icon in Delphi XE using only the built in tools
I have hundreds of components in my Delphi 2006 installation, but I always have trouble finding those I haven't used before and that may be the solution for what I need at the moment. I have many undocumented packages, but by the name of the component you can have an idea of what it does.
For example:
I need a RadioButton, so I have TRadioButton, TElRadioButton or TAdvRadioButton to choose which one has the custom properties that I need.
But when I click the Filter Button of the Tool Palette, I have to Type from the beginning of the component name. If I could have a field editor where I could type only a part of the name and the Palette showed me the components that had that term in the middle of the name too, I would make my day!!!
Does anyone know how in Delphi 2006?
I know that Delphi XE2 has this filter field.
The DDevExtensions IDE extension (http://andy.jgknet.de/blog/ide-tools/ddevextensions/) has a Component Selector that does what you need
(also using D2006, so it definitely works)
In Delphi 2007, images are loaded in a TImageList at design time. This introduces the following problem:
I have a folder containing the graphics I'm using in my application
Whenever I want to change, say, the icon for 'save', I have to
Change the graphic in the folder (for my own purposes)
Iterate along all TImageLists in the application
Change the graphic in the TImageList
Is there any way (component, compile script, ...) to perform steps 2 and 3 automatically, that is, specify only paths of graphics at design time, creating a dependence on the actual graphic files?
You could create a descendant of TImageList and add that kind of logic there.
Since components referring to images inside a TImageList do that by index, it would be easiest to have your descendant to have a ImagePaths property of type TStrings that is formatted like this:
#=Filename
And maybe add a property BasePath of type string as well.
Then upon loading that component, it could automagically reload those images in memory.
You could even make it a design-time expert which loads the images in the designer.
--jeroen
Classes are never fully compiletime. Designtime classes are streamed from resources too.
I load the images into the TImagelist at runtime. For this very reason, I do not assign any images at design time. They are all added as a resource to the exe and I load them at runtime from there. This also means that the images can be changed without recompiling the exe.
In a Delphi Form, I would like to replace one visual component with another. Example: I want to replace a Panel component with an ElPanel from a 3rd party package.
I would like all identical properties and events of the first component to be transferred to the new one, and all the components that belong to the first component (e.g. Toolbars, memos,status bars, etc.) to end up placed on the new component exactly where they were on the first one.
Is there a best/easiest way to do this other than adding the new component to the form and meticulously transferring every property, event and component to it one-by-one?
I do it as following:
Right click on the form and choose (View as Text).
Press Ctrl + F to search for the Component class name like TPanel and replace it with TElPanel
Switch back to back to the form (View as form)
In the interface section replace the TPanel with TElPanel.
if you have many components using GExperts will be more feasible solutions.
You can use GExperts or you can do it by hand.
To do it by hand, open the .dfm in notepad and replace all the class names. (Replace TPanel with TElPanel for example). When you've made all your changes, open the .pas file with Notepad, and do the same thing.
Make sure you add the required units to your uses clause.
Then open the form in the IDE and clean up any mismatched events or unknown property problems.
If I recall the excellent free GExperts plugin does this. Right click your form and select "Replace Components". http://www.gexperts.org
IMHO, the big drawback of the Replace component GExpert is that it changes the order of the components in the source code. That is not very VCS friendly. :-)
If you have other components inside a container doing this replacement with GExperts will cause some ugly exceptions and possibly unexpected behaviour in the IDE.
So, the best solution is to edit the .dfm file where you want (inside or outside the IDE) and replace manually the types of the components that you want to change. Maybe it will cause some exceptions too, but the IDE will managed them.
If you do it inside the IDE, after switching to design view if you save the .dfm inmediately the IDE will ask you to change the type of the variables related to the components you touched, liberating you to do it.
To convert between text and binary dfm formats, use the convert.exe tool in the Delphi bin\ directory. – Tim Knipe (Oct 28 at 4:15)
You can also use the context menu of the form designer - at least with BDS 2006. It's the last menu item ("Text-DFM" in a German IDE).
In my project I had to convert few doezens forms from one set of components to another.
I have created small perl script to convert components and its properties and do all neccesary mapings.
The script is quick&dirty solution but it is highly configurable. It scanns all dfm and pas files in project direcotory and convert dfm components definitions according to rules that you should provide in ObjectBeginFound, PropertyFound, ObjectEndFound procedures/events.
DFM files should be in text mode. Tested on Delphi 5 files. I don't know if it will be compatible with newer versions. Please send posts if you find it out.
USAGE:
perl.exe cxdfm.pl > logfile.txt
DOWNLOAD LINK
http://dl.dropbox.com/u/15887789/cxdfm.pl