Dynamic file type icon - delphi

I want to register a file type in windows and make a program with Delphi to draw the icon of file according to its contents (something like a custom icon format). How can I do this?

Thanks to Nortd and user539484 comments, I searched the internet for "shell icon handler Delphi" and found a good sample here, and also Shell+ components has a component to do this.

Related

Why won't Delphi XE2 let me embed a font resource as RCDATA?

I would like to embed a .ttf font resource into my EXE and dynamically load it. This particular method expects the resource to be of type RCDATA. So, I go to Project > Resources and Images... press Add..., and pick my .ttf file. The resource type FONT is automatically selected with an identifier of just 1. I change the type to to RCDATA and type in my own resource name.
Problem: When I press Ok I get an error that the identifier of a FONT resource must be a numeric value. But it wasn't FONT type anymore, I had changed it to RCDATA.
How do I get past this problem?
(asking and answering together because I'm sure others have seen this problem)
It seems to be just a small bug in the IDE. When you first select your .ttf file in this resource screen, change the type, press Ok without changing the identifier (leave it 1). Then, open the same screen back up, change the identifier to your own, and press Ok. It only works if you close and re-open the Resources and Images screen.
You could of course also write your own .rc file and do everything manually without this screen.
Unlike Jerry says, you can simply "load" the font file in the Resources and Images... dialog. Once you selected it, you can change the type to RCDATA (combobox an the lower right) and if you have done that, you can change the name to whatever valid name you choose.
There is no need to close and re-open the dialog.
I tried this in XE2 and in XE7, and it works as expected. The FONT type is merely the default for, well, font files. That can easily be changed in the dialog.
This doesn't look like a bug to me. Just plain default behaviour when you load a font file. Just like there is default behaviour when you load a .pas file in the editor.
If you want to use an .rc file, it is quite easy to generate one in the editor (new text file with extension .rc) and then you can add it to your project. The IDE will take care of the rest. No need to do anything manually there either, except of course editing the .rc file.

How do I save as certain file type in sublime text 2?

I am very new to programming and started using sublime text 2 as an editor for corona sdk and I am really liking it aside from one small problem.
My Problem:
When I open a new file in sublime text and then save it as a .lua file it does not save as a .lua. I use the drop down menu to select save as .lua. When I look at the file in my project folder the filetype is specified as only "file". This problem wont stop me from using sublime but it is very annoying. Any help would be appreciated.
Try just typing the full filename you want when you save it, e.g. filename.lua

Using a custom component

I'm making an application that has to do with World of Warcraft.
To keep it short; You can pick talents that give you certain skills, in my application I added a talent calculator. Here you can pick talents, each talent has a description.
This is shown, like all spells and items, in a tooltip. For an example check here and hover over one of the talents.
So I want to make these tooltips too.
To do this I created a custom component following 2 guides
Guide 1 here
Guide 2 here
Now I made my component based on a panel. Made a package and installed it which all works.
It also shows in the list of components at design time.
Then I drag it onto my form, it gets automaticly included in the uses however...
When I try to run/build/compile my application I get an error and it says:
Cannot resolve unit name 'Tooltip'
and I have no idea how to fix this.
There are plenty tutorials that show you how to make a custom component but none of them talks about this problem. Am I doing something wrong?
Any advice will be very welcome :)
You have to setup the common library path and search path.
Open from IDE-Menu Tools\Options
Walk to Environment Options\Delphi Options\Library
Edit Library Path and add the Path containing the component compiled libraries (.dcu files) or the path containing the component source files
Edit Search Path and add the Path containing the component source files (this is optional but helpful when debugging)
You have to repeat theses steps for all platforms your component will be used. But if you put the library path to compiled libraries, you have to ensure the right .dcu for the platforms.

How to set Document Types in XCode 4.2?

I have an iPhone app, and I would like it so that when a user clicks on a .pdf file as an email attachment, my App is one of the options to open it with. After some research, it seems that I need to add a Document Type in the info.plist. Problem is, I cannot find ANY tutorials explaining how to use the new Document Type GUI:
Image here:
Can anybody help me?
This "Document Types" editor feature may be so new (was it introduced in 4.2) that the documentation sloths haven't had time to write anything about it.
I did find this Technical Q&A document that describes "How do I get my application to show up in the 'Open in...' menu on iOS for a specific document type?", which basically introduces the Xcode developer to the Document Types editor.
And more low level documentation.
If you understand these basics and can figure out how to edit a raw Info.plist file, you should be good to go!
I hope this information helps you out.
It looks like there's still no official documentation on this. With the help of this SO answer describing how to write the info.plist file, I came up with this in Xcode 4.5.1:
This set of properties seems to be the minimum to get your app to run by tapping on an email attachment.
It should be sufficient to set the "Name" field to "Portable Document Format" and the types field to "com.adobe.pdf".

Is there a way to change the default EXE icon in Delphi

Embarcadero just released a whole bunch of neat looking icons that I'd like to use to make my Delphi 7 and 2009 apps look fancier. Is there a setting (or hack) in those IDEs that lets me change the default exe icon?
You could always use a resource editor to find the icon in the Delphi ide or bpl and change it to something else. That would be permanent for all new projects.
Apart from the fact that Andrey answered exactly what you asked I assume you want to add more icons to your executable than just the one you can set in the project option? This can be done by adding a *.rc file to the project. The following line should go into your project:
{$R 'Icons.res' 'Icons.rc'}
The rc file is a plain text file that Delphi compiles into a res. To the rc file add 1 icon per line like this:
XIcon01 ICON ".\Images\ico\ADDRESS2.ico"
XIcon02 ICON ".\Images\ico\ADDRESS3.ico"
XIcon03 ICON ".\Images\ico\ADDRESS4.ico"
The first part is the name of the icon. I chose names that come after Mainicon alphabetically with Mainicon being the icon that you define in the project options. I'm not sure (maybe somebody can confirm?) but I think that Delphi compiles the first icon as the application icon so I made sure my additional icons sort later.
In case you want to change the application's icon at runtime you can use the 2 Application.Icon.LoadFromResource routines.
Hope that helps

Resources