Re: Setting a small icon in CStatic...

From: Balboos (balboos_at_masonicbrother.com.No.Spam)
Date: 06/17/04


Date: Thu, 17 Jun 2004 09:44:18 GMT

Two comments:

I've attached member variable to CStatic in the past - and don't bother
anymore. Never has it been a problem, and the GetDlgItem(IDC...) is
fast, efficient, and allows easy handling of a group of static items
(such as captions for edit boxes) in loops.

CStatic items are also an easy way to make pseudo-buttons, since it has
the ability to capture mouse-clicks. Good-looking borderless (if
desired), easily colored (or iconed or bitmapped) buttons. Almost no
functionality beyond the click events, but rarely do I need more.

Balboos

GuitarBill wrote:
> There are some interesting comments in the docs relating to LR_SHARED and
> "non-standard" sizes etc... might be worth a look. Might be worth trying
> LR_DEFAULTCOLOR.
>
> Bill
>
> PS Please don't do ((CStatic *)GetDlgItem())-> it makes me sad (and will
> make you cry some day for sure). Attach a member variable of type CStatic to
> the control.
>
>
> "Dave" <davidp_au@nospam.yahoo.com> wrote in message
> news:%23UAgtxCVEHA.2816@TK2MSFTNGP11.phx.gbl...
>
>>Does anyone know how to set a small icon in the CStatic class?
>>
>>Normally I am fine doing this with my own icons, as I use ::LoadImage and
>>pass in the icon size of 16x16. However I want to do this with a system
>>icon, such as IDI_INFORMATION. For some reason LoadImage does not take
>>notice that I want the icon size to be 16x16, and instead uses the default
>>of 32x32.
>>
>>Heres a snippet of my code...
>>
>> HICON hInfo = (HICON) LoadImage(0,
>>
>>MAKEINTRESOURCE(IDI_INFORMATION),
>>
>
> IMAGE_ICON,
>
>> 16,
>> 16,
>>
>
> LR_SHARED);
>
>> // icon size should be 16x16, however, when set it uses the 32x32
>>size...
>> ((CStatic*) GetDlgItem(IDC_MYICON))->SetIcon(hInfo);
>>
>>Any help would be appreciated.
>>
>>Thanks.
>>--
>>
>>Dave
>>
>>Note: Spam-resistant e-mail address
>>
>>
>
>
>