#include
using namespace std ;
LRESULT CALLBACK winproc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
string classname="123";
string titlename="My first window";
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_CROSS);
wndclass.hIcon=LoadIcon(NULL,IDI_ERROR);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=winproc;
wndclass.lpszClassName="123";
wndclass.lpszMenuName=NULL;
wndclass.style=0;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("123","My first windows.",WS_OVERLAPPEDWINDOW,0,0,500,500,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
// return 0;
}
return msg.wParam;
}
LRESULT CALLBACK winproc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_PAINT :
PAINTSTRUCT ps;
HDC hdc;
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,50,50,"where are you?",strlen("where are you?"));
EndPaint(hwnd,&ps);
break;
case WM_CREATE:
HDC hdc1;
hdc1=GetDC(hwnd);
TextOut(hdc1,0,0,"windows create.",strlen("windows create."));
ReleaseDC(hwnd,hdc1);
case WM_LBUTTONDOWN :
HDC hdc2;
hdc2=GetDC(hwnd);
TextOut(hdc2,0,0,"Left buttom down.",strlen("Left buttom down."));
ReleaseDC(hwnd,hdc2);
break;
case WM_CLOSE :
if (IDYES==MessageBox(hwnd,"是否确定关闭窗口?","message",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY :
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam) ;
}
return 0;
}