ColonelNV

karkas

Nov 1st, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <tchar.h>
  3. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  4. TCHAR WinName[]=_T("MainFrame");
  5. int APIENTRY WinMain (HINSTANCE This, HINSTANCE Prev, LPSTR cmd, int mode)
  6. {
  7.  HWND hWnd;
  8.  MSG msg;
  9.  WNDCLASS wc;
  10.  wc.hInstance=This;
  11.  wc.lpszClassName=WinName;
  12.  wc.lpfnWndProc=WndProc;
  13.  wc.style= CS_HREDRAW;
  14.  wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
  15.  wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  16.  wc.lpszMenuName=NULL;
  17.  wc.cbClsExtra=0;
  18.  wc.cbWndExtra=0;
  19.  wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
  20.  if(!RegisterClass(&wc))return 0;
  21.  hWnd= CreateWindow (WinName,
  22.   _T("каркас Windows приложения"),
  23.   WS_OVERLAPPEDWINDOW,
  24.   CW_USEDEFAULT,
  25.   CW_USEDEFAULT,
  26.   CW_USEDEFAULT,
  27.   CW_USEDEFAULT,
  28.   HWND_DESKTOP,
  29.   NULL,
  30.   This,
  31.   NULL);
  32.  ShowWindow(hWnd,mode);
  33.  while(GetMessage(&msg,NULL,0,0))
  34.  {TranslateMessage(&msg);
  35.  DispatchMessage(&msg);
  36.  } return 0;
  37. }
  38. LRESULT CALLBACK WndProc(HWND hWnd, UINT message ,WPARAM wParam, LPARAM lParam)
  39. {
  40.  PAINTSTRUCT ps;
  41.  HDC hdc; int x,y;
  42.  
  43.  static int sx,sy;
  44.  switch(message)
  45.  {
  46.  case WM_SIZE:{
  47.   sx= LOWORD(lParam);
  48.   sy= HIWORD(lParam);
  49.   break;
  50.      }
  51.  case WM_PAINT:
  52.   hdc=BeginPaint(hWnd,&ps);
  53.   for(x=0;x<sx;x+=sx/10)
  54.   {
  55.    MoveToEx(hdc,x,0,NULL);
  56.    LineTo(hdc,x,sy);
  57.   }
  58.   for(y=0;y<sy;y+=sy/10)
  59.   {
  60.    MoveToEx(hdc,0,y,NULL);
  61.    LineTo(hdc,sx,y);
  62.   }
  63.    
  64.   MoveToEx(hdc, 0,0,NULL);
  65.   Ellipse(hdc, 200 , 200, 500 , 600);
  66.   LineTo(hdc, sx, sy);
  67.  
  68.   EndPaint(hWnd,&ps);
  69.   break;
  70.  case WM_DESTROY: PostQuitMessage(0);
  71.   break;
  72.  default:
  73.   return DefWindowProc(hWnd,message,wParam,lParam);
  74.  }
  75.  return 0;
  76. }
Add Comment
Please, Sign In to add comment