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

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


Push Buttons with 16x16 Icons

Thomas Scholz -- Thomas.Scholz@datev.de
Wednesday, November 20, 1996

Environment: VC++ 4.2b, Win 95, NT 4.0

I need Pushbuttons with small icons (16x16) in a dialog.

I created a dialog template using the MSDEV dialog editor. 
In the Push Button Properties I checked the style 'Icon' for the buttons
which contain icons. In my code I load the icon into the buttons as
follows:

BOOL MyDialog::OnInitDialog ( VOID )
{
    CDialog::OnInitDialog();

    // ...

        MyPb.SetIcon( ::LoadIcon( MyInstanceHandle 
                    , MAKEINTRESOURCE ( IDI_MY_ICON ) ) ); 

    // ...
}

If the icon with resource ID IDI_MY_ICON is 16x16 it seems to get 
stretched to 32x32, so only a part of the icon is visible in the push
button.

The only solution I found so far was to use 32x32 icons, which contain
the desired 16x16 image in the upper left corner, and to set the button
properties 'Horizontal Alignment' to 'Left' and 'Vertical Alignment' 
to 'Top'.


That can't be the proper solution, or is it? Did I miss a style or
something similar, that must be set to get 16x16 icons showed without 
stretching?

Any help, tips or comments are welcome. Thanks in advance,  

Thomas Scholz

-- 
Tel. (++49/0)911 276-5305
E-Mail: Thomas.Scholz@datev.de



Dong Chen -- d_chen@ix.netcom.com
Thursday, November 21, 1996

[Mini-digest: 5 responses]

>From the loadicon() reference:

"LoadIcon can only load an icon whose size conforms to the SM_CXICON and
SM_CYICON system metric values. Use the LoadImage function to load icons of
other sizes."
The SM_CYICON and SM_CXICON are 32x32.
--
Dong
d_chen@ix.netcom.com

-----From: Jim Barry 

LoadIcon can only load an icon whose size conforms to the SM_CXICON and =
SM_CYICON system metric values. Use the LoadImage function to load icons =
of other sizes.

Jim Barry
Interactive Learning Productions
Newcastle upon Tyne, UK

-----From: Scott Andrew 

You need to use the load image call to load a 16x16 bitmap. Your call would
look like:

MyPb.SetIcon( ::LoadImage( MyInstanceHandle 
                         MAKEINTRESOURCE ( IDI_MY_ICON ) ,
                         IMG_ICON,
                         16,
                         16,
	          LR_DEFAULTCOLO);

Scott Andrew
-----From: Dicky Singh 

LoadIcon is pre 95 era.  Try using LoadImage(...IMAGE_ICON...16, 16)
typecast result to (HICON)

-----From: Vijai Singh 

Don't use Stretch to fit style




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