Is it possible to access the images in TImageCollection from the executable or the resource file. i.e. outside the IDE. How are these images held?
Yes, image list and image collection images are stored in the DFM files. You can see this if you go to the form or data module containing the image list or collection, and then press Alt+F12 to see the DFM code. Alternatively, you can simply open the DFM file in your favourite text editor.
And these DFMs are embedded into your EXE as RCDATA resources, so you can see them if you open your EXE in a resource editor.
At runtime, your EXE can access the images via the TImageCollection.Images property, which is a collection of TImageCollectionItem objects.
TImageCollectionItem has a SourceImages property, which is a collection of TImageCollectionSourceItem objects.
TImageCollectionSourceItem has an Image property of type TWICImage
Related
I complete a small demo to implement ole drag&drop.
My App looks like this:
when drag a item from TListView to system explorer can cause a copy.I use IDropSource,IDataObject and OLE
clipboard format CF_HDROP to implement,so I never need to kwon the destination path to copy to in my
code.
Is there any way to make me know the destination path?
I need a solution,thanks in advance!
Sorry, but there is no way to discover the destination, nor should you ever need to know it. OLE drag&drop does not expose that information. You provide the source data, the target decides what to do with it, and then tells you whether the result was a copy/move/link so you can cleanup the source data accordingly.
In this case, you are providing a filename as the source, and Explorer copies the file to the target folder for you. Think of what would happen if you dropped the file into a virtual folder that has no filesystem path. The file can still be copied (even more so if you provide CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENT in your source data). That is perfectly acceptable to OLE, and why the drag&drop is abstracted the way it is.
Does someone know how to display both the header and source file at once in the builder XE?
I know I can toggle between them, but I'd rather have a tab for each file.
Thanks
Further to the answer posted by Remy Lebeau, the "magic" form for the header file guard is <filename>H. For example, the source file pair Foo.cpp/Foo.h requires that the define be FooH in Foo.h.
For new forms, RAD Studio will take care of this naming for you, but for non-visual file units, you may need to make these changes manually. You may even need to edit the .cbprof file to add the <DependentOn>Foo.h</DependentOn> to the <CppCompile Include="Foo.cpp"> tag.
By design, the IDE should not be displaying the files side by side at the same time. Related files (such as .cpp, .h, and .dfm for a given Unit) are displayed as a group, where there is only 1 tab up top for the group, and separate tabs down below for the individual files of the group.
If you are able to display the individual files side by side with their own top-level tabs, then the files are likely not being grouped together correctly, such as if the file names do not match each other, or the header file guard in the .h file is named incorrectly.
Try going to View->New Edit Window
I've received source code for a utility I want to adapt, but it appears to have the .dfm files stored in binary format, and one of the .dfm files seems to be coRruPted.
I also have the compiled .exe file.
Is there any way to extract the form from the .exe?
I can see from the relevant .pas file the form type declaration and the components on the form. How do I go about recreating the form from scratch, and 'attaching' it to the original .pas file?
Try using XN Resource Editor to recover the DFM from the .exe.
All exes compiled can be decompiled (but with some hardship )
but delphi application forms are saved as dfms inside exe which can be seen easily (with reshacker) (soooo easily ) can i overcome these problems ,first i thought of copying dfm data to oncreate procedure so i can hide my form information .
tell me a good solution for this ,
i do not like to use compressors
and my application is bit large so i cant port resourese one by one to a dll. i need an effective solution.
.dfm files are not stored as txt when they're linked into the final PE file. They are converted to a tagged binary format that is placed into an RCDATA Windows resource. For the images, they are stored as the raw binary. While building your application, the .dfm files can be stored as text or binary (right click the form designer and there is a selection for choosing one or the other). This only affects the format of the .dfm file itself. It has zero affect on its format once it is linked into your final binary.
You can try to convert the images to constant arrays (there are many tools that will read a binary and write out an array decl in various language formats) and use it as an include file. Another thing is to encrypt the images using a one-way algorithm like RSA or PGP. This won't keep someone from decrypting the image, but it will keep someone from replacing it since they won't have the private key.
If this is about protecting your applications images you are already on the losing side:
https://stackoverflow.com/questions/455623/how-can-i-prevent-users-from-taking-screenshots-of-my-application-window
It is always possible to make screenshots of a running application.
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.