Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
- HWND hMainWnd;
- char *szClassName="MYClass";
- MSG msg;
- WNDCLASSEX wc;
- wc.cbSize=sizeof(wc);
- wc.style=CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc=WndProc;
- wc.cbClsExtra=0;
- wc.cbWndExtra=0;
- wc.hInstance=hInstance;
- wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
- wc.hCursor=LoadCursor(NULL,IDC_ARROW);
- wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
- wc.lpszMenuName=NULL;
- wc.lpszClassName=szClassName;
- wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
- if(!RegisterClassEx(&wc))return 0;
- hMainWnd = CreateWindow(szClassName, "Application 1",
- WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
- (HWND)NULL, (HMENU)NULL, (HINSTANCE)hInstance, NULL );
- if(!hMainWnd)return 0;
- ShowWindow(hMainWnd,nCmdShow);
- while(GetMessage(&msg,NULL,0,0)){
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){
- HDC hDC;
- PAINTSTRUCT ps;
- RECT rect;
- switch(uMsg){
- case WM_PAINT:
- hDC=BeginPaint(hWnd,&ps);
- GetClientRect(hWnd,&rect);
- DrawText(hDC,"hello",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
- EndPaint(hWnd,&ps);
- break;
- case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd,uMsg,wParam,lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement