Introduction to WIN32 Development (3) redrawing the window

Source: Internet
Author: User
Tags win32

Let's take a look at the window redraw today, and before we start bragging, we're going to write a simple Win32 application in the way we mentioned in the previous blog post. The code is as follows:

#include <Windows.h>//First declare the message handler function Lresult CALLBACK Mywindowproc (HWND hwnd, UINT MSG, WPARAM WPARAM, LPA     

RAM LParam); Entry point int CALLBACK WinMain (hinstance hinstance, hinstance hprvinstance, LPSTR Lpcommandl     
    ine, int cmdshow) {wchar* CLN = L "MyApp";     
    Design window class Wndclass WC = {};     
    Wc.hinstance = hinstance;     
    Wc.lpszclassname = CLN;     
    Wc.lpfnwndproc = Mywindowproc;     
    Registration window class registerclass (&AMP;WC);     
        Create window HWND hmainwind = CreateWindow (CLN, L "Draw Window", Ws_overlappedwindow, 450, MB, NULL, NULL, h     
    Instance, NULL);     
    Display window if (hmainwind = NULL) return 0;     
    ShowWindow (Hmainwind,sw_normal);     
    message loop msg msg; while (GetMessage (&msg,null,0,0)) {translatemessage (&msg);     
    DispatchMessage (&AMP;MSG);     
return 0; }//Window message Handler lresult CALLBACK Mywindowproc (HWND hwnd, UINT MSG, WPARAM WPARAM, LPARAM LPARAM) {SWITC     
    H (msg) {case wm_paint:break;     
    Case Wm_destroy:postquitmessage (0);//exit program return 0;     
    Default:return DefWindowProc (Hwnd,msg,wparam,lparam); }     
}

This program can be normal operation, we first to run, to see what effect, of course, no effect, because it is just a blank window.

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.