#include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);HINSTANCE hInstance;class CWndFrame{public: void RegisterClass() { WNDCLASS wc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); wc.hCursor=LoadCursor(NULL,IDC_ARROW); wc.hIcon=LoadIcon(NULL,IDI_APPLICATION); wc.hInstance=hInstance;// wc.lpfnWndProc=WndProc;// wc.lpszClassName="liyanfei"; wc.lpszMenuName=NULL; wc.style=CS_VREDRAW|CS_HREDRAW; ::RegisterClass(&wc); } void CreateWindow1() { m_hWnd=::CreateWindow("liyanfei","李艳飞",WS_OVERLAPPED,20,10,500,400,NULL,NULL,hInstance,NULL); } void UpdateWindow() { ::UpdateWindow(m_hWnd); } void ShowWindow() { ::ShowWindow(m_hWnd,SW_SHOW); }private: HWND m_hWnd;};class CWndApp{public: void InitInstance() { CWndFrame *p=new CWndFrame; p->RegisterClass(); p->CreateWindow1(); p->ShowWindow(); p->UpdateWindow(); delete p; } void Run() { MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } }//private:// CWndFrame *p;};int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd){ CWndApp theApp; theApp.InitInstance(); theApp.Run(); return 0;}LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam){ switch(message) { case WM_LBUTTONDOWN: MessageBox(hWnd,"nihao","liyanfei",0); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd,message,wParam,lParam); } return 0;}
目前暂无任何回答
- 0 回答
- 0 关注
- 1330 浏览
添加回答
举报
0/150
提交
取消