15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Set icon for a popup CFrameWnd window

Patricio Burbano -- pburbano@nuthena.com
Monday, October 28, 1996

Environment: NT 4.0, MSVC 4.2b

Hi all,

I am trying to set the 16x16 icon for a popup frame window.  I load the
icon using 

	HICON myIcon = AfxGetApp()->LoadIcon(ICON_ID);
and then set it using 
	
	SetIcon(myIcon, FALSE);

However, when I run my application and display my popup window, the icon on
the upper left corner of the caption bar is the 32x32 icon reduced, and
looks bad.

I am sure I have an icon with both 16x16 and 32x32 formats in my resources.

Any insights on what is going on?





Eric Kenslow -- kenslowe@cdsnet.net
Tuesday, October 29, 1996

[Mini-digest: 3 responses]


Yes- you need to use LoadImage() to load the icon. CWinApp::LoadIcon() [as
the documentation states, BTW] will ONLY load icons that are SM_CXICON
pixels wide and SM_CYICON pixels high. LoadImage(), however, allows you to
load alternate icon sizes. Here's some code showing how to load the 16x16
image:

  ...
  hIcon = (HICON)::LoadImage( ::AfxGetInstanceHandle(), 
                                MAKEINTRESOURCE( IDR_MAINFRAME ),
                                IMAGE_ICON, 16, 16,
                                LR_DEFAULTCOLOR );

/* Eric Kenslow - Digital Lighthouse Inc.
 * webmaster@digilight.com
 * http://www.digilight.com
 */



----------
> From: Patricio Burbano 
> To: mfclist 
> Subject: Set icon for a popup CFrameWnd window
> Date: Monday, October 28, 1996 2:09 PM
> 
> Environment: NT 4.0, MSVC 4.2b
> 
> Hi all,
> 
> I am trying to set the 16x16 icon for a popup frame window.  I load the
> icon using 
> 
> 	HICON myIcon = AfxGetApp()->LoadIcon(ICON_ID);
> and then set it using 
> 	
> 	SetIcon(myIcon, FALSE);
> 
> However, when I run my application and display my popup window, the icon
on
> the upper left corner of the caption bar is the 32x32 icon reduced, and
> looks bad.
> 
> I am sure I have an icon with both 16x16 and 32x32 formats in my
resources.
> 
> Any insights on what is going on?
> 
> 
-----From: Mario Contestabile

Again, if memory serves me, this would be a doc. bug since it actually uses
the 32x32 icon...

mcontest@universal.com

-----From: Jim Barry 

CWinApp::LoadIcon will try to load the 32x32 icon in your ICON_ID =
resource first. You could either try doing LoadIcon on a icon resource =
containing only a 16x16 icon, or use LoadImage instead.

- Jim




| Вернуться в корень Архива |