How to use different icon size on delphi? - delphi

Does anybody knows how to use diferent icons sizes on delphi,
I ask because the windows choose the best icon size when showing on explorer,
But how do I put many icons in different sizes on resource.
Thanks again

Here's how I do it:
Prepare an icon file with an icon editing program. This file is a .ico file and contains multiple versions of the same icon with different sizes and pixel formats.
Reference that icon file in a .rc file that is used as source to the resource compiler.
As part of the compilation, the .rc file is processed, resulting in a .res file.
Link the .res file to the executable with a $R directive.
At runtime load the appropriate version of the icon with one of the Windows API functions that loads images from resources.
I use these steps for all the icons that I use on toolbars and menus. That allows me to have a GUI that scales with the user's font scaling settings. The way that the Delphi IDE leads you to do it is to make a TImageList and fill it up with icons that are stored in the .dfm file. That's pretty hopeless because it doesn't readily allow you to have different sized icons. And it also means that your visual assets are stored in a .dfm file in a great big glob representing all icons. If you want to swap out a single icon, then you can do so but it's rather opaque. The history trail left in your VCS is meaningless beyond any comments you leave.
If you are just talking about the main program icon, then you can add your .ico file to the project in the Project | Options | Application dialog and the IDE will take care of the rest of the details.

Related

Custom Component Icons Not Showing in Delphi 10.3

I just moved from Delphi 7 to 10.3 and was trying to install some of my older (VCL) custom components. I was finally successful in getting the code to compile, but I'm having trouble with something that seems like it should be trivial. The icons for the custom component(s) in the palette show what looks like a default icon instead of the icon(s) I expected. There are lots of posts on here (most are over 5 yrs old) about component icon issues and I've tried self-compiling the .rc file, including the{ $R .rc} in the package source and using the Project/Resources and Images dialog to specify the icons. I've tried 8-bit, 16-bit, 24-bit icons that are 24x24. Then as a test, I followed the exact procedure shown here which included some of the more recent content on this issue that I could find. I tried with bitmap files at full resolution and 32bpp and 24x24 at 8bpp. In both cases, the default icon showed for this test component. I'm probably overlooking something simple, but I'm kind of at a loss on what to try next. Is there a different procedure for specifying icons for custom components in 10.3 compared to older versions?
Edit: An update - I reinstalled my custom component and then rebooted and then was able to see the correct icon reflected in the palette, but here's where it gets strange. The test component I linked above still shows a default icon even after reinstalling and rebooting, and even stranger, is that the second I use my custom component on a form, the icon in the palette reverts to a TEdit icon (the component is a descendant of TEdit). Closing Delphi and reopening restores the icon until it is used again.
I'm not sure whether I should answer my own question, but just wanted to update in case it helps someone later. I was finally able to get the sample test component icon to show by using the -nocache option as described here. I then cleared the registry cache for my own component (dclusr) as shown in the same post and then also changed the bitmaps from 8bpp to 32bpp and now everything seems to be working as expected. I then cleared the registry keys for the sample project, and I can run without the -nocache option and all icons show fine, so I am thinking it was mostly a cache issue which I never would have found without the referenced post.

How to use ttf / SVG icons in ios SWIFT 4.0

As in android, they can use any vector image formats. My designer gave my abc.ttf file which contains icons for the app. The interesting thing about TTF is, it is not stretched or pixelate while increasing the size. So plz help me to figure out, is there any way to use TTF or any other vector image format.
Thnks
Posted my solution at medium.
Refer SVG or TTF icons in iOS (Swift 4.0) without using any third party library.
Step 1: Get your ttf file from the designer or get it online. I am showing with fontAwesome icons.
Link where you get ttf file. : https://fontawesome.com/v4.7.0/
Download this and extract it. You will see the fonts folder in it. Go to fontawesome-webfont.ttf.
Step 2: Open this TTF file and install
After Installation
Step 3: Open to your iOS project, go to your storyboard/Xib file add an UILabel.
Step 4: Add/import TTF file (downloaded) to your project.
Step 5: Now in your attribute inspector, go fonts and choose custom and click on family, you will see a list of fonts.
Choose FontAwesome (or you ttf file name).
That is so easy man. :P
Wait your last step is remaining.
Step 6: (Last One): Open your font file, select icon which you want to use and copy it.
Paste in the text area of your UILable in your storyboard/Xib.
You can use any icon from this file and there is plenty of icons already available at https://fontawesome.com/cheatsheet?from=io. You just need to copy and paste in the text of your label.
Step 1, 2 and 3 are a one-time process for a project and if you want to use the same TTF file in another project as well skip step 1 and 2.
The same procedure goes with buttons.
You can use vector PDFs instead of images
Refer How to use vectors in Xcode

Firemonkey default Windows style?

Delphi XE6
When I create a new Firemonkey Desktop Application, and drop a TGrid on the form, and edit the default style, it shows the TImage as:
"StyleBook1Windows 7style.png"
Where is the *.vsf file for this image. I would like to export the PNG from it and modify it and create a new style.
If you are trying to create your own style, you can get the bitmap used by an existing style using the following steps.
Launch the Bitmap Style Designer from the Delphi IDE menu - Tools |
Bitmap Style Designer.
Then from the Style Designer, select File | Open followed by selecting the .vsf file you wish to extract the bitmap from. You'll find a bunch of these in your c:\users\public\documents\embarcadero\studio\17.0\Styles directory. Change the 17.0 in the directory name to 14.0 for Delphi 6.
From the list of objects on the left, select Images. Expand images and you should see style.png
Now select Export (which is above the bitmap) which allows you to save the bitmap to a file
You don't really need the original file. If you click on the SourceLink property (click on the (TBitmapLinks)--not on the '...' button)) the Bitmaplinks Editor opens. There you can upload your own png file and define the areas you want to use in the style.

Delphi XE5, how do I get frames defined in a package into th component palette

2 things are my problem
1) a have a TMyframe=class(TFrame) defined in a package, but this frame is not listed in the frame palette.
So I registered my class from a designtime package using several methods none of which appeared to do what I want. (RegisterCOmponent, RegisterClass and RegisterCustomModule)
2) The biggest problem since Delphi does not 'know' my frame, it is handled as a regular component, and when using it inline, the (sub) objects defined in it appear in the form resource as 'object' rather than 'inherited' causing 'object blahblah already exists' when the form is created later on.
The same behaviour happens in the IDE's form designer.
When I move this frame unit from my runtime components package to the main module (my "kernel" bpl) then object/inherited problem is gone, and everything appears to work normally. Probably because knows how to resolve "TMyCustomFrame".
So... How can I define frames in one package and use them in forms (in other packages or exe) during designtime without delphi messing up my form resource.
Using XE5, Update1, VCL
(I will have come up with some simple example, meanwhile I already wanted the question out there)
TIA
From the documentation, it appears that this is not possible (emphasis added):
Adding frames to the Tool Palette
Frames are added to the Tool Palette as component templates. To add a frame to the Tool Palette, open the frame in the Form Designer (you cannot use a frame embedded in another component for this purpose), right-click the frame, and choose Add to Palette. When the Component Template Information dialog box opens, select a name, a palette page, and an icon for the new template.
It appears to be confirmed here:
Sharing Frames
You can share a frame with other developers in two ways:
Add the frame to the Object Repository.
Distribute the frame's unit (.pas) and form (.dfm or .fmx) files.
To add a frame to the Object Repository, open any project that includes the frame, right-click the Form Designer, and choose Add to Repository. For more information, see Using the Object Repository.
If you send a frame's unit and form files to other developers, they can open the files and add the frames and forms to the Tool Palette. If the frame has other frames embedded in it, it can only be opened as part of a project.

how to add to the media library in xcode?

I'm a beginning programmer, so sorry if this sounds stupid. I understand that I have to put the image into Xcode through the media library... but where is the media library? I threw the image file into the folder I made when I created the project but it's not showing up. I have the same image in there in 2 formats: PNG and JPEG. Where is the location of the "Media Library"?
What do you mean with Media Library? The pane in Interface Builder on the bottom right? That just lists all the media items that are part of your current project or workspace.
You have to add the images to your project, if you want to use them in your app. The easiest way is to drag them in one of the Groups in Xcode's Project Navigator tab on the left side. Make sure you check your target (this will make Xcode copy the images into your app's resources on compile time).
If you have the png or jpg, first, you need to create an imageset and then restart xcode, it would be available inside the media library.
To create an image set, you need to select the Assets.xcassets in the left navigation pane, and then in the tool bar select the editor -> Add Assets -> New Image Set. Give a name to your image and select render as Template Image.

Resources