Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

drausio

Icones através de .RES

Recommended Posts

Colega,Acho que vai uma ótima dica:

It's really simple, but takes some manual work:1. create a DLL project in Delphi2. create a text file with an .rc extension where you list all the filesthat should be included in the DLL. Each entry is on the form RESNAMERESTYPE FILENAME. You can make up the RESNAME and RESTYPE yourself (Windowsincludes a host of pre-defined RESTYPES you can use, like BITMAP, ICON,MENU, RCDATA etc) but they must be valid identifiers (same rules as Pascalidentifiers). Example:MYCOOLPIC1 BITMAP "SomeBitmap.bmp"MYCOOLPIC2 BITMAP "SomeBitmap2.bmp"ANICON ICON "MyCoolIcon.ico"MYJPEG JPEG "SomeJPEG.jpg"MOVIE AVI "Move.avi"MYLICENSE RCDATA "License.rtf"3. Compile the rc file with brcc32.exe - you will get a .res file instead.4. Include the res file in your DLL project:library MyDLL;    {$R MyRES.res}end.NOTE: do *not* name the rc file the same as your project because then the..res file might be overwritten each time you compile!5. At run-time, load the dll dynamically:  HandleToDLL := LoadLibrary('MyDLL.DLL');....or better yet:  HandleToDLL := LoadLibraryEx('MyDLL.DLL',0,LOAD_LIBRARY_AS_DATAFILE);6. To access a resource in the DLL, use TResourceStream. F ex to loadMYCOOLPIC1:  R := TResourceStream.Create(HandleToDLL,'MYCOOLPIC1','BITMAP');  You can now operate on R directly, copy it to anoher stream (i.eABitmap.LoadFromStream®) or do anything else you can come up with  If the resource is a bitmap (and is included in the rc with the standardBITMAP RESTYPE identifier), you can even load it directly like this:  ABitmap.LoadFromResourceName('MYCOOLPIC1');If you are using D5 or above, you can drag the rc file into the project (inthe project manager) and Delphi will create a special include directive thatautomatically compiles the rc when you compile the project so you can skipstep 3 and 4 above. Looks like this:{$R 'test.res' 'test.rc'}--Regards,Peter Thornqvist(JVCL Tech Coordinator)http://jvcl.sourceforge.net

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.