# include & lt; Windows. H>
#include
LRESULT a CALLBACK WinSunProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM);
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShoe)
{
WNDCLASS WNDCLS;
WNDCLS. CbClsExtra=0;
WNDCLS. CbWndExtra=0;
WNDCLS. HbrBackground=(HBRUSH) GetStockObject (BLACK_BRUSH);
WNDCLS. HCursor=LoadCursor (NULL, IDC_CROSS);
WNDCLS. HIcon=LoadIcon (NULL, IDI_ERROR);
WNDCLS. HInstance=hInstance;
WNDCLS. LpfnWndProc=WinSunProc;
WNDCLS. LpszClassName="sunxin2006";
WNDCLS. LpszMenuName=NULL;
WNDCLS. Style=CS_HREDRAW | CS_VREDRAW;
RegisterClass (& amp; WNDCLS);
The HWND HWND;
HWND=CreateWindow (" sunxin2006 ", "http://www.sunxin.org", WS_OVERLAPPEDWINDOW, 0, 0, 600, 400, NULL, NULL, hInstance, NULL);
ShowWindow (HWND, SW_SHOWNORMAL);
UpdateWindow (HWND);
MSG MSG.
While (GetMessage (& amp; MSG, NULL, 0, 0))
{
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
Return MSG. WParam;
}
LRESULT a CALLBACK WinSunProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
The switch (uMsg)
{
Case WM_CHAR:
Char szChar [20].
Sprintf (szChar, "char code is % d", wParam);
MessageBox (HWND szChar, "char", 0).
break;
In case the WM_PAINT:
HDC HDC.
PAINTSTRUCT ps;
HDC=BeginPaint (HWND, & amp; Ps);
TextOut (hDC, 0, 0, "http://www.sunxin.org", strlen (" http://www.sunxin.org "));
EndPaint (HWND, & amp; Ps);
break;
Case WM_CLOSE:
If (IDYES==MessageBox (HWND, "is it really over?" , the "message", MB_YESNO))
{
The DestroyWindow (HWND);
}
break;
Case WM_DESTROY:
The PostQuitMessage (0);
break;
Default:
Return DefWindowProc (HWND, uMsg wParam, lParam);
}
return 0;
}
CodePudding user response:
.c files are generally on the function of a variable declaration before statement execution, can change the file to. CPP can be declared at any time, at any time using c + +It is recommended to use TCHAR LPCTSTR LPTSTR and _t _st t function, can use UNICODE and non UNICODE compiled environment
CodePudding user response:
In a{
}
The
{
Char a, [0 x40].
What do a
}
CodePudding user response:
//delete1. CPP: Defines the entry point for the application. The
//
# include "stdafx. H"
#include
#include
LRESULT a CALLBACK WinSunProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM);
Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShoe)
{
WNDCLASS WNDCLS;
WNDCLS. CbClsExtra=0;
WNDCLS. CbWndExtra=0;
WNDCLS. HbrBackground=(HBRUSH) GetStockObject (BLACK_BRUSH);
WNDCLS. HCursor=LoadCursor (NULL, IDC_CROSS);
WNDCLS. HIcon=LoadIcon (NULL, IDI_ERROR);
WNDCLS. HInstance=hInstance;
WNDCLS. LpfnWndProc=WinSunProc;
WNDCLS. LpszClassName="sunxin2006";
WNDCLS. LpszMenuName=NULL;
WNDCLS. Style=CS_HREDRAW | CS_VREDRAW;
RegisterClass (& amp; WNDCLS);
The HWND HWND;
HWND=CreateWindow (" sunxin2006 ", "http://www.sunxin.org", WS_OVERLAPPEDWINDOW, 0, 0, 600, 400, NULL, NULL, hInstance, NULL);
ShowWindow (HWND, SW_SHOWNORMAL);
UpdateWindow (HWND);
MSG MSG.
While (GetMessage (& amp; MSG, NULL, 0, 0))
{
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}
Return MSG. WParam;
}
LRESULT a CALLBACK WinSunProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM)
{
The switch (uMsg)
{
Case WM_CHAR:
{
Char szChar [20].
Sprintf (szChar, "char code is % d", wParam);
MessageBox (HWND szChar, "char", 0).
}
break;
In case the WM_PAINT:
{
HDC HDC.
PAINTSTRUCT ps;
HDC=BeginPaint (HWND, & amp; Ps);
TextOut (hDC, 0, 0, "http://www.sunxin.org", strlen (" http://www.sunxin.org "));
EndPaint (HWND, & amp; Ps);
}
break;
Case WM_CLOSE:
If (IDYES==MessageBox (HWND, "is it really over?" , the "message", MB_YESNO))
{
The DestroyWindow (HWND);
}
break;
Case WM_DESTROY:
The PostQuitMessage (0);
break;
Default:
Return DefWindowProc (HWND, uMsg wParam, lParam);
}
return 0;
}
CodePudding user response:
The