Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <math.h>
- //using namespace std;
- HPEN Piora[2];
- LRESULT CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
- switch(msg){
- case WM_PAINT:{
- PAINTSTRUCT PS;
- BeginPaint(hWnd,&PS);
- RECT R, E;
- GetClientRect(hWnd,&R);
- SetMapMode(PS.hdc,MM_ISOTROPIC);
- SetWindowExtEx(PS.hdc,(R.right-R.left),(R.bottom-R.top),NULL);
- SetViewportExtEx(PS.hdc,R.right,R.bottom,NULL);
- SetViewportOrgEx(PS.hdc,R.right/2,R.bottom/2,NULL);
- E.left = R.left + (R.right-R.left)/100;
- E.right = R.right - (R.right-R.left)/100;
- E.top = R.top + (R.bottom-R.top)/100;
- E.bottom = R.bottom - (R.bottom-R.top)/100;
- SelectObject(PS.hdc,Piora[0]);
- MoveToEx(PS.hdc,0, -(E.bottom-E.top)/2,NULL);
- LineTo(PS.hdc,0,(E.bottom-E.top)/2);
- MoveToEx(PS.hdc, -( ( E.right - E.left ) / 2 ), 0, NULL );
- LineTo( PS.hdc, ( E.right - E.left ) / 2, 0 );
- SelectObject(PS.hdc,Piora[1]);
- float ytan;
- float ytans;
- for(float punkt = -(E.right-E.left)/2; punkt <= E.right-E.left ; punkt++){
- ytan = 100 * tan(punkt*3.14/180);
- ytans = 100 * tan((punkt-4)*3.14/180);
- //MoveToEx(PS.hdc,punkt,ytan,NULL);
- //LineTo(PS.hdc,punkt-4,ytans);
- SetPixel(PS.hdc,punkt,ytan,RGB(0,255,0));
- }
- EndPaint(hWnd,&PS);
- } break;
- case WM_DESTROY:{
- PostQuitMessage(0);
- } break;
- default: return DefWindowProc(hWnd, msg, wParam, lParam); break;
- }
- return 0;
- }
- bool Rejestruj(){
- WNDCLASSEX w;
- w.cbClsExtra = w.cbWndExtra = 0;
- w.cbSize = sizeof(WNDCLASSEX);
- w.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
- w.hCursor = LoadCursor(NULL,IDC_ARROW);
- w.hIcon = w.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- w.hInstance = GetModuleHandle(NULL);
- w.lpfnWndProc = Proc;
- w.lpszClassName = L"Klasa";
- w.lpszMenuName = NULL;
- w.style = CS_HREDRAW | CS_VREDRAW;
- return(RegisterClassEx(&w)!=0);
- }
- int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE XXX, LPWSTR lpCmdLine, int nShowCmd){
- Rejestruj();
- Piora[0] = CreatePen(PS_SOLID,2,0x00AAAAAA);
- Piora[1] = CreatePen(PS_SOLID,1,RGB(0,255,0));
- HWND Okno = CreateWindowEx(0,L"Klasa",L"Okno_Glowne", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 30,30,600,400,0,0,hInst,0);
- MSG msg;
- while(GetMessage(&msg,0,0,0)>0){
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- UnregisterClass(L"Klasa",hInst);
- return msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement