Article View: borland.public.cppbuilder.nativeapi
Article #16130Problems with LoadIcon and MAKEINTRESOURCE
From: Mike Collins
Date: Sat, 31 May 2003 22:42
Date: Sat, 31 May 2003 22:42
56 lines
4060 bytes
4060 bytes
Hi everyone, just wondering if anyone could help me out with a small problem. It's small, but it takes some explaining so here goes: Under Explorer (the desktop) when you change the colour depth of the screen, explorer reloads all the images (icons) that it is displaying so that it displays them correctly. When I examine the resource files for the system i.e. shell32.dll I can see that each icon actually consists of many sub icons, one for each size (48x48, 32x32 and 16x16) and one for each colour (16 bit and 256 bit). So I assume that explorer simply calls MAKEINTRESOURCE with the numeric ID for the icon and inturn MAKEINTRESOURCE returns a string ID which relates to the icon. In turn this is passed to LoadIcon which loads the relevant icon which most suites the screen resolution and icon size. This is described in the help file, thus: "LoadIcon loads the icon resource only if it has not been loaded; otherwise, it retrieves a handle to the existing resource. The function searches the icon resource for the icon most appropriate for the current display." Now I'm trying to achieve the same thing. I have many icons in a resource file. Under each icon is all the relevent sub icons of different sizes and colours. At run time I load up the icons using the LoadIcon API, i.e. imgOpt->Picture->Icon->Handle = LoadIcon(HInstance, MAKEINTRESOURCE(101)); - Now this workes fine. If I set my screen resolution to 256 colour and then run my application, I see the correct icon being displayed for 256 colours. If I close my application, change the screen resolution down to 16 bit colour and then run my app again, I see the correct icon being displayed for the 16 bit colour. However the problem occures when I try to reload the icons, at run-time, in responce to the screen resolution being changed WHILST the application is running. In order to do this I create a Message Map and look for the message WM_DISPLAYCHANGE. I check the values and then call my Image load function. However I see the same icon (in this case, for the higher screen resolution) being displayed. I assume this is because LoadIcon has already loaded the icon once and so it simply retures the existing handle. It doesn't matter what I do. I've tried to NULLify the Handle, I've tried creating a secondard dialog and loading the icons in there, then closing and explisitly destroying it - just to test the problem. When I re-display the dialog and get the oringinal icon being displayed. I really need to resolve this problem, I have a LoadGraphics method in each of my forms and I need to recall it in responce to the screen changing. I need some way to 'reset' LoadIcon. Any ideas would be excellent (except splitting all my icons up and then checking the screen resoloution in order to determine which one to load, manually). I hope I've explained this problem correctly. I've written a test applicaton that demonstrates this perfectly - I can upload it or e-mail it to where ever - if someone can tell me where. Many, Many thanks in advance, Mike C
Technical Details
Message-ID:
<3ed92ef0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a5f9b48171f835bf,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-31 15:41:20 PST Reply-To: "Mike Collins" <mikec@kr8.co.uk> From: "Mike Collins" <mikec@kr8.co.uk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Problems with LoadIcon and MAKEINTRESOURCE Date: Sat, 31 May 2003 23:42:34 +0100 Lines: 60 Organization: kr8 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 81.2.78.34 Message-ID: <3ed92ef0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054420720 81.2.78.34 (31 May 2003 15:38:40 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail