Advertisement
krot

API 1

Feb 18th, 2013
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
  4. int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
  5.  
  6.     HWND hMainWnd;
  7.     char *szClassName="MYClass";
  8.     MSG msg;
  9.     WNDCLASSEX wc;
  10.  
  11.     wc.cbSize=sizeof(wc);
  12.     wc.style=CS_HREDRAW|CS_VREDRAW;
  13.     wc.lpfnWndProc=WndProc;
  14.     wc.cbClsExtra=0;
  15.     wc.cbWndExtra=0;
  16.     wc.hInstance=hInstance;
  17.     wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
  18.     wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  19.     wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
  20.     wc.lpszMenuName=NULL;
  21.     wc.lpszClassName=szClassName;
  22.     wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
  23.  
  24.     if(!RegisterClassEx(&wc))return 0;
  25.  
  26.     hMainWnd = CreateWindow(szClassName, "Application 1",
  27.     WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
  28.     (HWND)NULL, (HMENU)NULL, (HINSTANCE)hInstance, NULL );
  29.    
  30.     if(!hMainWnd)return 0;
  31.  
  32.     ShowWindow(hMainWnd,nCmdShow);
  33.  
  34.     while(GetMessage(&msg,NULL,0,0)){
  35.     TranslateMessage(&msg);
  36.     DispatchMessage(&msg);
  37.     }
  38.     return 0;
  39. }
  40. LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){
  41. HDC hDC;
  42. PAINTSTRUCT ps;
  43. RECT rect;
  44.  
  45. switch(uMsg){
  46. case WM_PAINT:
  47.     hDC=BeginPaint(hWnd,&ps);
  48.  
  49.     GetClientRect(hWnd,&rect);
  50.     DrawText(hDC,"hello",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
  51.     EndPaint(hWnd,&ps);
  52.     break;
  53. case WM_CLOSE:
  54.     DestroyWindow(hWnd);
  55.     break;
  56. case WM_DESTROY:
  57.     PostQuitMessage(0);
  58.     break;
  59. default:
  60.     return DefWindowProc(hWnd,uMsg,wParam,lParam);
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement