Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.39 KB | None | 0 0
  1. #include <windows.h>
  2. #include <math.h>
  3.  
  4. //using namespace std;
  5.  
  6. HPEN Piora[2];
  7.  
  8. LRESULT CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
  9.     switch(msg){
  10.         case WM_PAINT:{
  11.             PAINTSTRUCT PS;
  12.             BeginPaint(hWnd,&PS);
  13.  
  14.             RECT R, E;
  15.             GetClientRect(hWnd,&R);
  16.  
  17.             SetMapMode(PS.hdc,MM_ISOTROPIC);
  18.             SetWindowExtEx(PS.hdc,(R.right-R.left),(R.bottom-R.top),NULL);
  19.             SetViewportExtEx(PS.hdc,R.right,R.bottom,NULL);
  20.             SetViewportOrgEx(PS.hdc,R.right/2,R.bottom/2,NULL);
  21.  
  22.             E.left = R.left + (R.right-R.left)/100;
  23.             E.right = R.right - (R.right-R.left)/100;
  24.             E.top = R.top + (R.bottom-R.top)/100;
  25.             E.bottom = R.bottom - (R.bottom-R.top)/100;
  26.  
  27.             SelectObject(PS.hdc,Piora[0]);
  28.  
  29.             MoveToEx(PS.hdc,0, -(E.bottom-E.top)/2,NULL);
  30.             LineTo(PS.hdc,0,(E.bottom-E.top)/2);
  31.  
  32.             MoveToEx(PS.hdc, -( ( E.right - E.left ) / 2 ), 0, NULL );
  33.             LineTo( PS.hdc, ( E.right - E.left ) / 2, 0 );
  34.  
  35.             SelectObject(PS.hdc,Piora[1]);
  36.             float ytan;
  37.             float ytans;
  38.  
  39.             for(float punkt = -(E.right-E.left)/2; punkt <= E.right-E.left ; punkt++){
  40.                 ytan = 100 * tan(punkt*3.14/180);
  41.                 ytans = 100 * tan((punkt-4)*3.14/180);
  42.  
  43.                 //MoveToEx(PS.hdc,punkt,ytan,NULL);
  44.                 //LineTo(PS.hdc,punkt-4,ytans);
  45.                 SetPixel(PS.hdc,punkt,ytan,RGB(0,255,0));
  46.                
  47.             }
  48.  
  49.  
  50.  
  51.             EndPaint(hWnd,&PS);
  52.                       } break;
  53.  
  54.         case WM_DESTROY:{
  55.             PostQuitMessage(0);
  56.                         } break;
  57.  
  58.         default: return DefWindowProc(hWnd, msg, wParam, lParam); break;
  59.     }
  60.     return 0;
  61. }
  62.  
  63. bool Rejestruj(){
  64.     WNDCLASSEX w;
  65.     w.cbClsExtra = w.cbWndExtra = 0;
  66.     w.cbSize = sizeof(WNDCLASSEX);
  67.     w.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
  68.     w.hCursor = LoadCursor(NULL,IDC_ARROW);
  69.     w.hIcon = w.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  70.     w.hInstance = GetModuleHandle(NULL);
  71.     w.lpfnWndProc = Proc;
  72.     w.lpszClassName = L"Klasa";
  73.     w.lpszMenuName = NULL;
  74.     w.style = CS_HREDRAW | CS_VREDRAW;
  75.     return(RegisterClassEx(&w)!=0);
  76. }
  77.  
  78. int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE XXX, LPWSTR lpCmdLine, int nShowCmd){
  79.  
  80.     Rejestruj();
  81.  
  82.     Piora[0] = CreatePen(PS_SOLID,2,0x00AAAAAA);
  83.     Piora[1] = CreatePen(PS_SOLID,1,RGB(0,255,0));
  84.  
  85.     HWND Okno = CreateWindowEx(0,L"Klasa",L"Okno_Glowne", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 30,30,600,400,0,0,hInst,0);
  86.  
  87.     MSG msg;
  88.     while(GetMessage(&msg,0,0,0)>0){
  89.         TranslateMessage(&msg);
  90.         DispatchMessage(&msg);
  91.     }
  92.  
  93.     UnregisterClass(L"Klasa",hInst);
  94.  
  95.     return msg.wParam;
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement