Associate icons in the title bar and taskbar for the dialog box

Source: Internet
Author: User

The login interface is often used when writing database programs. The login interface is usually displayed in a temporary dialog box. For example, most program operations are implemented based on a single document, but you need to call a dialog box before initializing the program as the login interface. I usually display it at the beginning of the initinstance () function, and then judge whether the entered account and password are correct. If the program is correctly executed, the system prompts that the user password is incorrect. If the user clicks the cancel button, exit (0) is called to exit the program.

At this time, I encountered a problem: the icons you designed won't be displayed in the title bar and taskbar of the logon interface, and will not be displayed when you press Alt + TAB to switch the program. This means that you have designed your own icons and replaced the. ICO icon in the original res folder, but it is not used on the login interface. Next, we can use several steps to display the replaced icon on the login interface.

1. Define a hicon variable in the class declaration of the dialog box.

Hicon m_hicon;

2. Add the following code to the class constructor in the dialog box:

M_hicon = afxgetapp ()-> loadicon (idr_mainframe );

3. Rewrite the oninitdialog () function for the dialog box and add the following code

// Todo: add additional initialization seticon (m_hicon, true) here; // set the big icon seticon (m_hicon, false); // set the small icon

For details about the seticon () function, refer to the following article:



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: 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.