Windows program design icon

Source: Internet
Author: User

There are not many things to learn, just some methods to load resources.CodeIs also the callback function section in icondemo.

 
Lresult callback wndproc (hwnd, uint message, wparam, lparam) {static hicon; static int cxicon, cyicon, cxclient, cyclient; HDC; hinstance; paintstruct pS; int X, Y; Switch (Message) {Case wm_create: // obtain handle hinstance = (lpcreatestruct) lparam)-> hinstance; // load icon hicon = loadicon (hinstance, makeintresource (idi_icon1); // obtain the icon width, high cxicon = getsystemmetrics (sm_cxicon); cyicon = getsystemmetrics (sm_cyicon); Return 0; Case wm_size: cxclient = loword (lparam); cyclient = hiword (lparam); Return 0; Case wm_paint: HDC = beginpaint (hwnd, & PS); For (y = 0; y <cyclient; Y + = cyicon) for (x = 0; x <cxclient; x + = cxicon) // draw the icons drawicon (HDC, X, Y, hicon); endpaint (hwnd, & PS); Return 0; Case wm_destroy: postquitmessage (0); Return 0;} return defwindowproc (hwnd, message, wparam, lparam );}

Let's talk about makeintresource. This macro was previously writtenProgramIt is used, but it has never been checked.

First, this name indicates "Make An interger into a resource string", so it is easy to remember.

This macro converts a numeric type to a pointer type macro, which does not have the release issue ..

The main reason for using this macro is that some resources are defined by serial numbers rather than strings. therefore, you need to convert the number into a string pointer and pass it to functions such as loadresource to load the resource.

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.