Early Windows Experience

Source: Internet
Author: User

#include <windows.h>


LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain1 (hinstance hInst, hinstance, LPSTR szcmd, int nshow)
{
Wndclass Wndclass;
TCHAR *classname = TEXT ("MyClass");
HWND hwnd;//used to record window handles
MSG msg;//defines a message structure that is used to store the retrieved message
Wndclass.cbclsextra = 0;
Wndclass.cbwndextra = 0;
Wndclass.hbrbackground = (hbrush) (Color_window + 1);
Wndclass.hcursor = LoadCursor (NULL, Idc_arrow);
Wndclass.hicon = LoadIcon (NULL, idi_application);
Wndclass.lpfnwndproc = WndProc;
Wndclass.lpszclassname = classname;//class name
Wndclass.lpszmenuname = null;//temporarily do not menu
Wndclass.style = Cs_vredraw | Cs_hredraw;
RegisterClass (&wndclass);//Registration window
#define CREATEWINDOWW (Lpclassname, Lpwindowname, Dwstyle, X, Y,\nwidth, nheight, hWndParent, HMenu, HINSTANCE, LpParam )
hwnd = CreateWindow (
classname/* window class */,
TEXT ("Hello"/* Window name */),
ws_overlappedwindow/* window type */,
cw_usedefault/* Default window position of the horizontal axis */,
cw_usedefault/* default window Position ordinate */,
500/* the width of the window */,
The 300/* window is high */,
null/* Parent window: No parent window, default is desktop */,
null/* No Menu */,
hinst/* Program Instance handle */,
NULL);


ShowWindow (hwnd, nshow);//Display window
UpdateWindow (HWND);//Refresh Window


while (GetMessage (&msg, NULL, 0, 0)//If message 0 is sent to the window, exit the Loop End program
{
TranslateMessage (&msg);//Translation
DispatchMessage (&msg);//Send the message to the window program that handles the message
}
return 0;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM)
{
Switch (message)
{
Case Wm_destroy:
PostQuitMessage (0);//Send an exit message to the program exit value 0
return 0;
Default
Return DefWindowProc (HWND, message, WParam, lparam);//Do not process yourself, handing over to the system
}
}

Early Windows Experience

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.