請問一下要如何將icon包在dll和exe檔案中呢 |
尚未結案
|
JS
一般會員 ![]() ![]() 發表:22 回覆:26 積分:9 註冊:2002-07-20 發送簡訊給我 |
|
China Join
中階會員 ![]() ![]() ![]() 發表:81 回覆:242 積分:89 註冊:2003-03-12 發送簡訊給我 |
|
RaynorPao
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:139 回覆:3622 積分:7025 註冊:2002-08-12 發送簡訊給我 |
引言: 請問一下各位先進,要如何把icon包在dll和exe檔中呢?可否寫一範例?謝謝 JS 你好: 據小弟我所知,應該至少有三種方法吧 (1)使用 TImageList,把你要用到的 Icon 放在裡面 (2)在你的 BCB 開發環境下按 Tools/Image Editor 然後載入 Project 的 res 檔案,把你要用到的 Icon 加入 (3)利用 VC 或其他的 RC 編輯工具,把你要用到的所有 Icon 放到一個 RC 檔案裡面,然你的 Project 再 add 這個 RC 檔案即可-- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! -- -- 欲知前世因,今生受者是;欲知來世果,今生做者是 -- -- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 -- |
JS
一般會員 ![]() ![]() 發表:22 回覆:26 積分:9 註冊:2002-07-20 發送簡訊給我 |
|
axsoft
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
JS您好:
方法一. 可用TimageList元件將Icons加入到ImageList中,C Builder中很多元件 都有支援ImangeList,這個方法在Dll或EXE中皆適用 方法二. 可使用Resource File將所需的Icon/Image/Wave/EXE....等等檔案加進Resource檔案然後含括在DLL或,中其作法參考如下: Using Borland’s C Builder to createResource DLLs by Jean-Pierre Martel, editor of the dBulletin 資料來源:http://www.dbase.com/Knowledgebase/dbulletin/bu15cb.htm -------------------------------------------------------------------------------- Introduction In a previous article, we saw how to use Borland's Resource Workshop to store images (icons and BMPs, exclusively) in a DLL. Unfortunately, as soon as the number of resources stored in a DLL created by Resource Workshop gets around 30, dBASE chokes on some of them. The images can be seen and selected when one tries to datalink a control to a resource. However, as soon as the OK button is pushed, an error message appears saying that the resource can't be found. In our 13th issue, Dan Howard wrote an article on how to use Borland's free C Compiler to create a resource DLL. Of course, what's possible with the compiler is also possible with the full application. In the present article, we will use version 4.0 of Borland's C Builder. The complete version of that application was given for free with the May 2000 issue of the PC Plus (anUK magazine). For those who missed the occasion, I wouldn't be suprised if Borland would repeat the experience in the future. To create a resource DLL, there is only one prerequisite: we need a .RC resource file. A .RC file is just a special ASCII file in which the names of the images to be included in the DLL are listed. Since the main module of that compiler is a DOS executable, the short name of the images must be used in that .RC file. To create a resource DLL, load C Builder. Select the menu item File|New… then, in the New Items dialog box, select the Console Wizard icon (not the DLL icon) and click the OK button. In the Console Application Wizard dialog box, select the DLL radiobutton and click the Finish pushbutton.![]() ![]() |
BGman
初階會員 ![]() ![]() 發表:28 回覆:85 積分:42 註冊:2003-01-10 發送簡訊給我 |
|
axsoft
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
How to hide BMPs and icons in a DLL using Borland's
Resource Workshopby Jean-Pierre Martel, editor of the dBASE Developers Bulletin 資料來源:http://www.dbase.com/Knowledgebase/dbulletin/bu09rw.htm -------------------------------------------------------------------------------- Introduction When the dBASE Scan Center was released (with our seventh issue), most of its pushbuttons needed custom-made BMPs since these buttons performed actions rarely done by standard dBASE applications. Thus the original version of the Scan Center came with about 30 BMPs. When I started making a shareware version out of it, I wanted to hide all these images inside a DLL. The only tool available to dBASE developers is Borland's Resource Workshop (RW). This 16-bit application can't create DLLs, but it is useful to create or add resources in an existing 16 bit or 32 bit DLL (note: VdB 5.x uses 16-bit DLLs while VdB 7.x uses 32-bit DLLs). If you don't have RW, you can buy the 4.5 version (the same version as the one included with the VdB 5.5 compiler) for 70 US$ from Borland or get it for free from the CD-ROM provided by some computer magazines. It was given with the May 2000 issue of the UK magazine 'PC Plus'. An alternative solution is Resource Builder by SiComponents which is more stable (Dan Howard, personal communication). In a previous issue of the magazine, Robert Bravery explained how to use RW to add string resources to a DLL; here we will see how to add images. Contrary to Resource Builder, BMPs and ICOs are the only images that RW can store in a DLL. Since I wanted as few as possible images left in the Scan Center directory, I applied different solutions to different image types. Thanks to a suggestion by Romain Strieff, one of the GIFs had its suffix renamed to '.sca'. Strangely, form.background = "filename cpyright.sca" will be executed without any problem. How dBASE can know that it is a GIF is a mystery to me. But it works, so who cares? The other GIFs were buried in the binary fields of a table (dScan.dbf). An icon and about thirty BMPs were the only images left to hide in the DLL. A minefield The RW should work fine if you follow strictly the thin path that I will suggest to you. There may be other ways to make a 32-bit DLL out of BMPs, but I couldn't find another. Each time I tried shortcuts, my well-know patience was severely challenged… Among its bugs, RW has a tendency to make a copy of each BMP (under a .~BM suffix) and screw the original. So:for i = 1 to 1000000 my_advice = "Never use RW on the only existing copies of your BMPs" next replicate("Never",10)1 — The first step is to create a new folder. 2 — The second step is to copy all the BMPs that have to be included in the DLL in this new folder. Since RW can't create a new 32-bit DLL, you will need an empty one. You may ask: “Where in the World can you find an empty DLL?” The answer: where else than in Ken Mayer's dUFLP (under EmptyRes.zip). Actually, we will use two empty DLLs (Empty.dll and Empty32.dll), both made by Bowen Moursund. To make things easier, they can be downloaded from a link at the end of this article. 3 — Copy Empty.dll and Empty32.dll to the folder you have just created. 4 — From the Explorer, right-click on each of them and select “Properties” to take off of their read-only property. If you don't, RW will refuse to add new images to them. 5 — Optional: Rename Empty.dll to MyApp.dll, and Empty32.dll to MyApp32.dll (the name of your application). 6 — Run Resource Workshop. 7 — Follow these instructions to open MyApp.dll — the 16-bit one — even if your goal is to create a 32-bit DLL: From the File menu, select 'Open project…'. The first time you are using RW, the combobox displays 'RC resource script' as the file type by default. Use the combobox to select 'DLL, VBX, CPL library' as illustrated in the image below. In the lower right rectangle, double-click on the appropriate drive and folder until you get to the folder where you stored the DLL created in the first step. Select 'MyApp.dll' in the lower left rectangle and click the OK button. |
axsoft
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
Creating Resource DLLsh2 for dB2Kby Dan Howard 資料來源:http://www.dbase.com/Knowledgebase/dbulletin/bu13dll.htm -------------------------------------------------------------------------------- Introduction dB2K is a rich and powerful software but one utility it sadly lacks is a resource builder. Back in the days of 16 bit dBASE we had Borland’s Resource Workshop. This was a good product and worked well for 16 bit development but it has some shortcomings in the 32 bit world. Unfortunately this product has problems when you try to save your work in a 32 bit format. Either the dll simply won’t work at all or worse - it will make your application become unstable. The good news is that there is an excellent shareware 32 bit resource builder out there called Resource Builder. It can be downloaded from the following URL: http://www.sicomponents.com/. The author, Igor Siticov is very helpful with question about the product. Resource builder also supports JPEG files which is very useful. The only downside to Resource Builder is that it works with RC (resource script) files. These are simple ASCII files which describe the resources in text format. Although Resource Builder allows you to compile your resource files in to RES files, it does not go that extra step and make the DLL for you. Fortunately there is a solution to this. To make the DLL we’ll need the help of Borland’s free C++ compiler. Borland recently released it core C++ compiler to the public for free. This is a bare bones software. No GUI, no drag & drop, only a DOS command line interface but it’s fully functional and can be used to write any C or C++ program you want. It can be downloaded from this URL: http://www.borland.com/bcppbuilder/freecompiler/. Once you’ve download this fairly hefty file (8 meg!) install it on your computer. I normally install it to c:\borland\bcc55 but you can specify other locations if you want but be careful not to use paths with spaces. In the install folder is a readme.txt file. This contains some configuration instructions which I’ll review for you. Configuring Borland C++ Borland’s compiler requires only a few settings to get it to work. First you’ll need to set the path to the compiler itself. This will be in the BIN folder where you installed it. If you’re using Windows 9x you have to set this in your autoexec.bat file and then reboot. The entry might look like this: PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\Borland\BCC55\BIN For Windows NT or 2000 you can set the path by modifying the system environment variables. Right click on “My Computer” Choose “Properties” Choose the “Advanced” Tab Click “Environment Variables”Parameter Meaning -Tpd This tells the linker the type of file you want to create. You can use -Tpe to create an exe. -aa This tells the linker that this will be a 32 bit Windows application. -V4.0 This specifies the target Windows version that this DLL will be used for. 4.0 represents Windows 95 and later. -c This tells the linker that you want case sensitive symbols. I'm not sure that this is critical but since C is case sensitive it's a good idea to include it. -x This suppresses the creation of a MAP file. A MAP file is a text file which list all the memory locations of the symbols of a C program. Since this is simply a resource file we're making, it's not that useful to have a MAP file. c0d32.obj This object file is required to link into the dll. It allows the DLL to be loaded into memory only when needed. myresource.dll This is the output DLL file that will be created. import32.lib and cw32i.lib These libraries are needed for the DLL. They're used to access the Windows API. myresource.res This is your compiled RES file that will be linked.Notice in the command line that there are items seperated by commas. One part of the command line has 2 commas with nothing in between. This part of the command line is for dependency files (.DEP) which we don’t need for a dll. Conclusion Well, I hope this helps you with building your own dlls. I think you’ll find that a C compiler can be very useful for you and fun to experiment with! To download the code of the MakeDLL batch file, click here (it's a 306 byte zipped file) -------------------------------------------------------------------------------- Note: The author would like to thank John Staub, his proof-reader, for the improvements he brought to this text. About the Author: Dan Howard is an independent software developer and a member of dBVIPS. You can usually find him lurking around the dBASE newsgroups. HAVE A NICE DAY FOR YOU 發表人 - axsoft 於 2003/06/13 10:20:01 |
axsoft
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
引言: axsoft 桑你好! 看到你圖文並茂解說,覺得你很用心。 小弟公司最近需要撰寫產品說明書, 所以想要請教你,在你的圖片中的數字, 紅色圈圈中間有數字的這種表示方法很棒, 不知道是用哪一種應用軟體做出來的呢? 小弟想要提昇台灣軟體產品說明書的品質! 讓國際了解我們台灣也是很棒的!BGman您好: 您可以試試SnagIt v6.22可以達到您要的功能,但如果真的要像上頭這麼漂亮建議用Ulead PhotoImpact或Adobe PhotoShop來做 http://www.techsmith.com/products/snagit/default.asp ![]() |
JS
一般會員 ![]() ![]() 發表:22 回覆:26 積分:9 註冊:2002-07-20 發送簡訊給我 |
|
RaynorPao
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:139 回覆:3622 積分:7025 註冊:2002-08-12 發送簡訊給我 |
引言: 謝謝大家的熱情回應,不過可否問一個笨問題啊!如果我做好一個包含icon的dll或exe file,那我該如何使用其它的應用程式去取用它呢?JS 你好: 你可以利用 Win32 API Resource Functions 達到目的 LoadLibrary, LoadLibraryEx, FindResource, FindResourceEx, LockResource, LoadResource, FreeLibrary,....... http://delphi.ktop.com.tw/topic.php?TOPIC_ID=22599 -- Enjoy Researching & Developing --
------
-- 若您已經得到滿意的答覆,請適時結案!! -- -- 欲知前世因,今生受者是;欲知來世果,今生做者是 -- -- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 -- |
BGman
初階會員 ![]() ![]() 發表:28 回覆:85 積分:42 註冊:2003-01-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |