Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined(UNICODE) && !defined(_UNICODE)
- #define _UNICODE
- #elif defined(_UNICODE) && !defined(UNICODE)
- #define UNICODE
- #endif
- #include <tchar.h>
- #include <windows.h>
- #include <cmath>
- #include <string>
- #include <sstream>
- using namespace std;
- int calc(HWND text);
- HWND hText, hText2, hText3,g_hbutton,hwnd,hwnd1;
- HDC hdc;
- PAINTSTRUCT ps;
- /* Declare Windows procedure */
- LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
- /* Make the class name into a global variable */
- TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
- int WINAPI WinMain (HINSTANCE hThisInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpszArgument,
- int nCmdShow)
- {
- /* This is the handle for our window */
- MSG messages; /* Here messages to the application are saved */
- WNDCLASSEX wincl; /* Data structure for the windowclass */
- /* The Window structure */
- wincl.hInstance = hThisInstance;
- wincl.lpszClassName = szClassName;
- wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
- wincl.style = CS_DBLCLKS; /* Catch double-clicks */
- wincl.cbSize = sizeof (WNDCLASSEX);
- /* Use default icon and mouse-pointer */
- wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
- wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
- wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
- wincl.lpszMenuName = NULL; /* No menu */
- wincl.cbClsExtra = 0; /* No extra bytes after the window class */
- wincl.cbWndExtra = 0; /* structure or the window instance */
- /* Use Windows's default colour as the background of the window */
- wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
- /* Register the window class, and if it fails quit the program */
- if (!RegisterClassEx (&wincl))
- return 0;
- /* The class is registered, let's create the program*/
- hwnd = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- szClassName, /* Classname */
- _T("ACBR"), /* Title Text */
- WS_OVERLAPPEDWINDOW, /* default window */
- CW_USEDEFAULT, /* Windows decides the position */
- CW_USEDEFAULT, /* where the window ends up on the screen */
- 300, /* The programs width */
- 300, /* and height in pixels */
- HWND_DESKTOP, /* The window is a child-window to desktop */
- NULL, /* No menu */
- hThisInstance, /* Program Instance handler */
- NULL /* No Window Creation data */
- );
- hwnd1 = CreateWindowEx (
- 0, /* Extended possibilites for variation */
- szClassName, /* Classname */
- _T("ACBR"), /* Title Text */
- WS_OVERLAPPEDWINDOW, /* default window */
- CW_USEDEFAULT, /* Windows decides the position */
- CW_USEDEFAULT, /* where the window ends up on the screen */
- 800, /* The programs width */
- 800, /* and height in pixels */
- HWND_DESKTOP, /* The window is a child-window to desktop */
- NULL, /* No menu */
- hThisInstance, /* Program Instance handler */
- NULL /* No Window Creation data */
- );
- g_hbutton = CreateWindowEx( 0, "BUTTON", "paint", WS_CHILD | WS_VISIBLE,0, 0, 150, 30, hwnd, NULL, hThisInstance, NULL );
- //hText = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,0, 40, 150, 20, hwnd, NULL, hThisInstance, NULL );
- //hText2 = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,0, 61, 150, 20, hwnd, NULL, hThisInstance, NULL );
- //hText3 = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,0, 82, 150, 20, hwnd, NULL, hThisInstance, NULL );
- //SetWindowText( hText, " a" );
- //SetWindowText( hText2, " b" );
- //SetWindowText( hText3, " c" );
- /* Make the window visible on the screen */
- ShowWindow (hwnd, nCmdShow);
- /* Run the message loop. It will run until GetMessage() returns 0 */
- while (GetMessage (&messages, NULL, 0, 0))
- {
- /* Translate virtual-key messages into character messages */
- TranslateMessage(&messages);
- /* Send message to WindowProcedure */
- DispatchMessage(&messages);
- }
- /* The program return-value is 0 - The value that PostQuitMessage() gave */
- return messages.wParam;
- }
- //POCZATEK STRUKTUR
- struct Points
- {
- int pointsX,pointsY;
- Points *next;
- Points()
- {
- next = 0;
- }
- };
- struct Lists
- {
- Points *first;
- Points *actualy;
- int number;
- void addPoints(int pointsX,int pointsY)
- {
- Points *neww = new Points;
- neww->pointsX = pointsX;
- neww->pointsY = pointsY;
- if(first==0)
- {
- first = neww;
- }else{
- Points *temp = first;
- while(temp->next)
- {
- temp = temp->next;
- }
- temp->next = neww;
- neww->next = 0;
- }
- }
- Lists()
- {
- first = 0;
- }
- int parametr()
- {
- Points *temp = first;
- while (temp)
- {
- temp=temp->next;
- }
- }
- };
- Lists *datebase = new Lists;
- //KONIEC STRUKTUR
- /* This function is called by the Windows function DispatchMessage() */
- LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message) /* handle the messages */
- {
- case WM_DESTROY:
- PostQuitMessage (0); /* send a WM_QUIT to the message queue */
- break;
- case WM_COMMAND:
- {
- if(( HWND ) lParam == g_hbutton )
- {
- ShowWindow(hwnd,SW_HIDE);
- ShowWindow(hwnd1,5);
- int tabP[17][36][4];
- int tabP1[17][36][4];
- int Top[4], Bottom[4];
- int Top1[4], Bottom1[4];
- float a,a1,b,b1,c,z;
- int i,j;
- a=300;
- b=240;
- c=200;
- hdc=BeginPaint(hwnd1,&ps);
- Top[1]=0;
- Top[2]=0;
- Top[3]=round(c);
- for (i=16;i>=0;i--)
- {
- z=sin((i-8)*M_PI/18);
- b1=b*sqrt(1-z*z);
- a1=a*sqrt(1-z*z);
- z=c*z;
- for (j=0; j<=35; j++)
- {
- tabP[i][j][1]=round(a1*cos(j*M_PI/18));
- tabP[i][j][2]=round(b1*sin(j*M_PI/18));
- tabP[i][j][3]=round(z);
- }
- }
- Bottom[1]=0;
- Bottom[2]=0;
- Bottom[3]=-round(c);
- float alpha;
- alpha = M_PI/4;
- Top1[1] = Top[1];
- Top1[2] = round(Top[2]*cos(alpha)+Top[3]*sin(alpha));
- Top1[3] = round(-Top[2]*sin(alpha)+Top[3]*cos(alpha));
- for (i=16;i>=0;i--)
- {
- for (j=0; j<=35; j++)
- {
- tabP1[i][j][1]=tabP[i][j][1];
- tabP1[i][j][2]=round(tabP[i][j][2]*cos(alpha)+tabP[i][j][3]*sin(alpha));
- tabP1[i][j][3]=round(-tabP[i][j][2]*sin(alpha)+tabP[i][j][3]*cos(alpha));
- }
- }
- Bottom1[1] = Bottom[1];
- Bottom1[2] = round(Bottom[2]*cos(alpha)+Bottom[3]*sin(alpha));
- Bottom1[3] = round(-Bottom[2]*sin(alpha)+Bottom[3]*cos(alpha));
- alpha = M_PI/3;
- Top[1] = round(Top1[1]*cos(alpha)+Top1[2]*sin(alpha));
- Top[2] = round(-Top1[1]*sin(alpha)+Top1[2]*cos(alpha));
- Top[3] = Top1[3];
- for (i=16;i>=0;i--)
- {
- for (j=0; j<=35; j++)
- {
- tabP[i][j][1]=round(tabP1[i][j][1]*cos(alpha)+tabP1[i][j][2]*sin(alpha));
- tabP[i][j][2]=round(-tabP1[i][j][1]*sin(alpha)+tabP1[i][j][2]*cos(alpha));
- tabP[i][j][3]=tabP1[i][j][3];
- }
- }
- Bottom[1] = round(Bottom1[1]*cos(alpha)+Bottom1[2]*sin(alpha));
- Bottom[2] = round(-Bottom1[1]*sin(alpha)+Bottom1[2]*cos(alpha));
- Bottom[3] = Bottom1[3];
- Top1[1] = round(Top[1]+400);
- Top1[2] = round(Top[2]+400);
- Top1[3] = Top[3];
- for (i=16;i>=0;i--)
- {
- for (j=0; j<=35; j++)
- {
- tabP1[i][j][1]=round(tabP[i][j][1]+400);
- tabP1[i][j][2]=round(tabP[i][j][2]+400);
- tabP1[i][j][3]=tabP[i][j][3];
- }
- }
- Bottom1[1] = round(Bottom[1]+400);
- Bottom1[2] = round(Bottom[2]+400);
- Bottom1[3] = Bottom[3];
- Top[1] = Top1[1];
- Top[2] = Top1[2];
- Top[3] = 0;
- for (i=16;i>=0;i--)
- {
- for (j=0; j<=35; j++)
- {
- tabP[i][j][1]=tabP1[i][j][1];
- tabP[i][j][2]=tabP1[i][j][2];
- tabP[i][j][3]=0;
- }
- }
- Bottom[1] = Bottom1[1];
- Bottom[2] = Bottom1[2];
- Bottom[3] = 0;
- datebase->addPoints(Top[1],Top[2]);
- datebase->number=1;
- for(int i=0; i<=35; i++)
- {
- if(i%2==0)
- {
- for(int j=16;j>=0;j--)
- {
- datebase->addPoints(tabP[j][i][1],tabP[j][i][2]);
- datebase->number++;
- }
- datebase->addPoints(Bottom[1],Bottom[2]);
- datebase->number++;
- }
- else
- {
- for(int j=0;j<=16;j++)
- {
- datebase->addPoints(tabP[j][i][1],tabP[j][i][2]);
- datebase->number++;
- }
- datebase->addPoints(Top[1],Top[2]);
- datebase->number++;
- }
- }
- for(int i =16;i>=0;i--)
- {
- datebase->addPoints(tabP[i][0][1],tabP[i][0][2]);
- datebase->number++;
- for(int j=1;j<=35;j++)
- {
- datebase->addPoints(tabP[i][j][1],tabP[i][j][2]);
- datebase->number++;
- }
- datebase->addPoints(tabP[i][0][1],tabP[i][0][2]);
- datebase->number++;
- }
- datebase->actualy=datebase->first;
- MoveToEx(hdc,datebase->actualy->pointsX,datebase->actualy->pointsY,0);
- for(int i=1;i<datebase->number;i++)
- {
- datebase->actualy=datebase->actualy->next;
- LineTo(hdc,datebase->actualy->pointsX,datebase->actualy->pointsY);
- }
- delete datebase;
- EndPaint(hwnd1,&ps);
- }
- }
- break;
- default: /* for messages that we don't deal with */
- return DefWindowProc (hwnd, message, wParam, lParam);
- }
- return 0;
- }
- int calc(HWND text)
- {
- DWORD lengthh = GetWindowTextLength( text );
- LPSTR Bufor =( LPSTR ) GlobalAlloc( GPTR, lengthh + 1 );
- GetWindowText( text, Bufor, lengthh + 1 );
- int i;
- istringstream iss(Bufor);
- iss >> i;
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement