#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK DzjProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HDC hdc;
PAINTSTRUCT ps;
switch (uMsg)
{
case WM_LBUTTONDOWN:
MessageBox(hwnd,"lbuttondown","junge",MB_OK);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"My home",strlen("My home"));
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"Whether to exit the program","Tips",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"My university",strlen("My university"));
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"dzj",0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wc;
char ClassName[]="No.1";
wc.style=CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc=DzjProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wc.hCursor=LoadCursor(NULL,IDC_SIZENESW);
wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName=ClassName;
RegisterClass(&wc);
HWND hwnd;
hwnd=CreateWindow(
"No.1","MyWindows",WS_OVERLAPPEDWINDOW& ~WS_MINIMIZEBOX,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL
);
ShowWindow(hwnd,SW_SHOWNA);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,NULL,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}