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.