Windows and application icons in Win32 programs

Source: Internet
Author: User

To set the icon file, take these steps: first, define the icon file, which is an ico file of 32*32 or 16*16 size. Define in the. RC file of the program:

# Define idi_app_icon100 (ID of the icon file)

Idi_app_icon
Icon "icon file location"

We usually put the icon file in the resource folder. Then we need to define in the header file: idi_app_icon
Equ 100.

Step 3: load the icon file in the definition window structure:

Invoke loadicon, null, idi_app_icon
MoV WND. hicon, eax
MoV WND. hiconsm, eax

The first is to load the icon file. Both hicon and hiconsm are the icon handles. The first one is to specify the large icon, and the last one is to specify the small icon. According to the msdn instructions, the icon set in hicon is the window icon in the upper left corner of the window. hiconsm is only a small icon, but in actual application, movwnd. hicon and eax are dispensable. No matter whether they exist, the application icons and window icons are not affected, but hiconsm is indispensable. (I really don't understand it at the moment. If you know anything, please let me know. Thank you)

After the preceding three steps, the program icon can be changed. To set the window icon, you must send the wm_seticon message to the window when the window is created:

. If eax = wm_initdialog

Create an icon for this window

Invoke loadicon, hinstance, idi_wain_icon
Invoke sendmessage, hwnd, wm_seticon, icon_big, eax

Note that if it is a window file generated by createjavaswex, you can directly use the icon file variables defined above. However, if it is a dialog box created by createdialogparam, you must redefine an icon file variable, the icon file can be the same, but the ID and variable name must be changed. To put it simply, the program icon variables and window icon variables in the window file can be defined. The dialog box must be defined separately. The icon files can be the same and the variable names must be different. Icon_big is 32*32, and icon_small is 16*16

In this way, the two icons of the program are OK.

In RadAsm, we don't need to define it in the. RC file. We just need to add it through the project --- resource and then add it with a moderate value in the header file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.