I've been working with a program someone else has made and I wanted to change the icon.
The icon I have is 256x256. I used http://converticon.com/ to create the icon (from a bmp I think). I used the icon in Inno Setup to create an installer and it worked fine
So I go to Options -> Application and attempt to load it. However, Delphi 2007 gives me an error 'The parameter is incorrect.' with this info: http://i.stack.imgur.com/vRCgs.png
When I do the same thing in Delphi XE, it works and loads the icon and changes it on compile. I can't use XE right now because the program uses a math parser that has a problem with unicode (thats something to fix for later haha)
So, what I did was open the project in XE, change the icon, save it, delete the dproj and open it in 2007. This works, compiles and displays the correct icon, but when I go to the project options, it gives me the same 'The parameter is incorrect' error.
The workaround isn't a big deal, but I shouldn't need to do it. Does anyone know why I can't change the icon in Delphi 2007?
Edit: I just used that same converticon site to convert the 256x256 icon to 192x192 and smaller and now it works perfectly. Thanks for the answers
The "icon" file is actually a collection of images, at different resolution and using different encodings. When I'm creating my icons I'm making sure they don't actually contain the 256x256 PNG-encoded version because development tools built before Windows Vista don't understand that. And that includes your Delphi 2007 and my Delphi 7. I also remove the alpha-encoded 256x256 icon because it simply makes the file needlessly large.
You've got two fixes possible:
Find an ICO editor and remove all of the larger formats until your Delphi accepts the icon. I personally never seen the 256x256 used in the real world, they'd take up huge amounts of space on user's Desktop or in Windows Explorer.
Use a dummy icon and replace the icon resource in the generated exe after Delphi is done with it. This way you can keep all of the larger image formats, including the 256x256 PNG image.
Edit to correct an error
If possible, always include the 256x256 image, Windows scales that down for everything above 64x64.
I always assumed Windows Explorer would show an image that's based on the closest matching image size available in the ICO. That is, if a 128x128 image is necessary, Windows would use the 128x128 image if available, or scale down the 256x256 image if that's available, or scale up the 96x96 image. Apparently that's not so. I've just made a test icon consisting of several image formats, including 32, 48, 72, 96, 128 and 256 consisting of simple blobs of color (using the flood-fill tool). In Windows Explorer I cycled throw the various Display Modes, and it became apparent that starting with "Large Icon" (and that's not very large) Windows will scale down the 256x256 icon, and if that's not available, use the 48x48 icon, unscaled! The result is truly ugly and unexpected. The 72x72, 96x96 and 128x128 icons were simply ignored.
Thank you David for pointing this out.
Older versions of Delphi don't support 256px Vista icons. I believe that 2010 does not support them so I guess the limitation was fixed in XE.
When working with an older Delphi you'll need to keep the 256px icon out of the IDE. You can still build an executable with a 256px icon from the command line compiler - I used to do just this before upgrading from Delphi 6. But to do this requires the use of a competent resource compiler, for example the Microsoft one.
2007 will let you select icons with a 256 pixel image. Here is what I tried:
The default icon for Delphi XE contains several image sizes, including a 256 pixel image.
If I extract the icon from a Delphi XE application using a resource editor, I can add that icon to a Delphi 2007 application using the IDE's project options. I don't get an error, and the icon images show as expected in Windows Vista/7 using Explorer at different sizes.
If I take the same icon that worked in Delphi 2007 and remove all of the image sizes other than the 256 pixel image using IcoFX, and try to select it again, then I get an error.
Try creating a .ico that includes other image sizes and see if that works for you.
Related
I have read this article by Paweł Głowacki and I have been able to display an icon for my component. The result is the following:
I can see the image in the Tool Palette and in the structure view. By the way in the designer I see the default icon:
How can I display the icon of my component in the designer as well?
I am using Delphi Tokyo 10.2 Update 2. I have followed the article I have linked to get the image shown. My component is the following:
type
TEquationSolver = class(TComponent)
//code...
end;
Basically, I have done the following:
I have created 3 bitmaps (16x16 24x24 32x32) and a png (128x128)
I have added them as resources going into Project > Resources and Images
I have called them TEquationSolver with the suffix that indicates the size. In this way they are properly displayed on the IDE.
What am I missing for the design time part? In this article I have read the following:
Our guide is: Use PNG if you want very easy backwards compatibility,
or small file (BPL) size; use bitmaps if you want fast loading. We
use bitmaps for 16, 24, and 32px icons, and PNG for the 128px icons.
In fact I have 16x16, 24x24, 32x32 bitmaps and the 128px png. Is there something else?
It seems that you have to create the files I have shown above plus the image for the Designer. The latter needs to match the name of the class that inherits from TComponent (in my case):
As you can see I have added another bitmap (it's the 32x32, I have just made a copy and changed the name) and I have used TEquationSolver as name. After a Build + Install I have the following result:
Note that I could have added only logo.bmp as resource (with the ID that matches the TComponent-derived class name) and it would have worked anyway. The problem is that the pictures won't be neat because they'll be resized and they may appear blurred, like in my case.
For this reason I think that it's good:
Put an image that will appear in the form designer
Put the 16x16, 24x24, 32x32 and 128x128 that will be used by the IDE
The difference is evident in my case. When I have only a single bitmap the quality of the image is low but when I provide the various sizes they look better.
We have a Delphi 7 program running on Windows 7 Professional SP1, developed approximately 10 years ago. On the current system, it became unusable as some form elements have incorrect size so the text they contain doesn't fit there or the graph overflows the bottom of the window:
Picture 1: Table rows have incorrect size (or the text is bigger than it should be)
Picture 2: There is a graph in the window but the bottom part of the graph isn't visible. And there are no scrollbars...
We have no source code nor we do we have contact with the people who developed the software. We think the software was built in Delphi 7 because it uses several xxxx70.bpl libraries.
We tried to change resolution of the screen and change compatibility mode used to run the program with no luck.
Is there anything we can try?
Your program is not DPI aware, and you are running with font scaling settings that mean the application is asked to scale. The application font is scaled automatically but your Delphi application does not adapt.
I can see some options for you:
Run your machine with 100% font scaling.
Run your machine with >125% font scaling. Then DPI virtualization will kick in which should fix the issue. Although the app may appear fuzzy as it will suffer aliasing when scaled.
Try to find a compat setting that forces DPI virtualization. Don't know if such a thing exists.
Edit the .dfm resources in the executable to set the Scaled property to true. This would require a resource editor that understands Delphi. For instance XN resource editor. I've no idea whether or not this will work. If it does work, each form will re-scale themselves according to the font scaling.
Update
Forcing DPI virtualization won't help, on second thoughts. The system will tell your app that the font scaling is 125% and scale from there. But your app won't even handle 125% scaling correctly it seems. So you have little option other than to disable all font scaling or perhaps try with the Scaled property.
I have an issue where the 16x16 bitmaps in an imagelist get corrupted and are displayed as monochrome black and white images. This tends to happen between sessions in the IDE, so that after saving the project to disk, exiting the IDE, and opening up the project once again, lo and behold the images have transformed! This requires rebuilding the imagelist and is very annoying. A before and after example image is attached.
This project is being developed (and shuttled between) WindowsXP and Windows 7 x64 using Delphi 4, which is installed on both operating systems. The problem occurs rarely in XP and frequently in Windows 7. Does anyone have a clue as to what is going on here?
What is the right way to define a win7-compatible icon set in a Delphi application ? ( variable size on desktop )
I have designed a 256*256 icon then made the 16*16, 24*24, 48*48 variants. ( in Microsoft UX guide, they seem to say that these sizes should be included for a correct display on the desktop).
I've put all icons variations in a multiple layer document in Gimp and exported the whole stuff as an ico. Then I've put it as the application icon in the project options, following the straight way to assign an icon to an application.
FInally I've put a shorcut on Win desktop (win7) but when making "Ctrl+Wheel" (resizing of desktop icons, if you don't know it yet...) on the desktop (Win 7), correct icon is not displayed, after 48*48 it keeps the same size ( I suspect that only the 48*48 version is used).
The 256px sized icon should be a compressed PNG icon. I suspect that the resource compiler shipped with Delphi 2007 won't like that format so you'll need to use the MS resource compiler, rc. The icon should be named MAINICON. That said, I suspect that a 256px bitmap will work, it will just be exceedingly large.
What's more, IIRC, the Delphi IDE doesn't like 256px PNG icons so it's no good adding the icon to the project through the IDE. You need to build the .res file yourself and link it with a {$R ...} directive.
Finally, its possible that your .ico file may not be correct. The 256px image is actually stored with width and height equal to 0 because that field is byte sized and 0 was formerly invalid. Perhaps this is what the IDE gags on. Check the .ico file out in a different tool, e.g. IcoFX.
There may be other problems—these are just the ones I can recall encountering over the years. If I had to guess as to which issue was biting you, I'd say it was the inability of the IDE to handle 256px icons.
I believe that the IDE has got progressively better in this area in more recent versions, but even in D2010 which I currently use, it's not perfect.
I want to use Vista Large Icon feature in my Delphi 2009 application, but I can only embed the normal 32x32 icon in my application. How can I make application have many sizes of Icons?
Thanks
Go download IcoFX. It's free and handles multiple sizes/colour depths AND proper alpha blending. Use that to create your ICO file, then add the ICO to your project. Can't give you a blow-by-blow of the steps for loading the ICO in 2009, because I'm stuck using Delphi 7...
If it's any consolation, Visual Studio has taken eons to get anywhere near decent icon editing too.
Hey, who remembers the Borland Resource Workshop ?
I would use a icon editor such as AWIcons which allows you to create an icon that contains many different formats. Windows will then decide, based on the current view and color depth, which icon to use.
Once you have created your SINGLE icon with many different embedded formats, just link it like you would your 32x32 icon. It might look funny in the IDE, but when you run the program it will look correctly.
Get a decent stock of icons, or make your own. I use an the icon library from Icon Experience - your pay, but all icon sizes 16x16 up to 256 x 256 are provided in ICO and PNG formats. I then use Icon Sushi to work with my own icons. Delphi 7 and 2009 both have limitations working with large icons, so I've moved to using PNG icons using the PNG components library. This gives you a TPNGImageList that just works where the Vista cacheing and other problems make using TImageList only really good for 16x16 and 32x32 sizes. I've also ported PNGComponents to D2009 where it works fine.
Brian
I can only embed the normal 32x32 icon
in my application
From my experience, Delphi 2009 lets you use any icon. I've used extra large Vista icons too, and it worked.
Solution:
There is a BETTER AND EASY way to add high resolution icons in your Delphi 7 application.
It doesn't involve hacking your exe file:
http://thesunstroke.blogspot.com/2010/10/how-to-add-high-resolution-icons-to.html
If your are wanting some free software to create icons then you can probably use GIMP. My very first video tutorial was using GIMP to create icons - it's available here.
Configure the project to use the Microsoft resource compiler.
Once you are done building your project, add all the needed icons your project needs at the post-build step with the resource editor as described here: http://www.heaventools.com/rtconsole-sample-script-guide.htm