https://pastein.ru/t/u6
скопируйте уникальную ссылку для отправки
#include <windows.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string.h>
#include <windowsx.h>
#include <stdio.h>
#define ID_EDIT 1
#define ID_EDIT1 2
#define ID_EDIT2 3
#define ID_LISTBOX 4
#define ID_BUTTMINY 5
#define ID_BUTTMAXY 12
#define ID_BUTSRY 7
#define ID_BUTRES 11
#define ID_EDIT3 8
#define ID_EDIT4 9
#define ID_EDIT5 10
#define CTLCOLOR_LISTBOX 15
double x, y;
double shag;
double a, b, d;
double min, max;
double sry;
double sum;
HWND hlist;
HDC hdc;
HINSTANCE hInst;
PAINTSTRUCT ps;
HWND hedit;
HWND hedit1;
HWND hedit2;
HWND hedit3;
HWND hedit4;
HWND hedit5;
HWND hButton1, hButton2, hButton3, hButton4;
void makeneww(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
hedit = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 10, 270, 30, hwnd, (HMENU)ID_EDIT, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА MIN X
hedit1 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 45, 270, 30, hwnd, (HMENU)ID_EDIT1, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА MAX X
hedit2 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 240, 80, 270, 30, hwnd, (HMENU)ID_EDIT2, NULL, NULL);//ЕДИТ ДЛЯ ВВОДА ШКОЛИЧЕСТВА ШАГОВ X
hlist = CreateWindow("listbox", "", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | WS_VSCROLL | WS_HSCROLL| LBS_NOTIFY, 10, 160, 500, 250, hwnd, (HMENU)ID_LISTBOX , NULL, NULL);
hButton1 = CreateWindow("button", "Узнать min Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 420, 150, 50, hwnd, (HMENU)ID_BUTTMINY, NULL, NULL);
hButton2 = CreateWindow("button", "Узнать max Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 180, 420, 160, 50, hwnd, (HMENU)ID_BUTTMAXY, NULL, NULL);
hButton3 = CreateWindow("button", "Узнать средний Y", WS_CHILD | WS_VISIBLE | WS_BORDER, 360, 420, 150, 50, hwnd, (HMENU)ID_BUTSRY, NULL, NULL);
hButton4 = CreateWindow("button", "ВЫВЕСТИ РЕЗУЛЬТАТ", WS_CHILD | WS_VISIBLE | WS_BORDER, 20, 110, 200, 40, hwnd, (HMENU)ID_BUTRES, NULL, NULL);
hedit3 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 10, 470, 150, 30, hwnd, (HMENU)ID_EDIT3, NULL, NULL); //ЕДИТ ДЛЯ ВЫВОДА min Y
hedit4 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 180, 470, 160, 30, hwnd, (HMENU)ID_EDIT4, NULL, NULL);//ЕДИТ ДЛЯ ВЫВОДА max Y
hedit5 = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | WS_BORDER, 360, 470, 150, 30, hwnd, (HMENU)ID_EDIT5, NULL, NULL);//ЕДИТ ДЛЯ ВЫВОДА средний Y Y
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
/* The 'main' function of Win32 GUI programs: this is where execution starts */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wc; /* A properties struct of our window */
HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */
MSG msg; /* A temporary location for all messages */
/* zero out the struct and set the stuff we want to modify */
memset(&wc,0,sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc; /* This is where we will send messages to */
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
/* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszClassName = "WindowClass";
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Курсовая Чистяков 1 вариант",WS_VISIBLE|WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, /* x */
CW_USEDEFAULT, /* y */
540, /* width */
550, /* height */
NULL,NULL,hInstance,NULL);
if(hwnd == NULL) {
MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK);
return 0;
}
while(GetMessage(&msg, NULL, 0, 0) > 0) { /* If no error is received... */
TranslateMessage(&msg); /* Translate key codes to chars if present */
DispatchMessage(&msg); /* Send it to WndProc */
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_CREATE:{
makeneww(hwnd,Message,wParam,lParam);
break;
}
case WM_COMMAND:{
if ((HWND)lParam == hButton4){
SendMessage(hlist, LB_RESETCONTENT, 0, 0);
char number1[10];
Edit_GetLine(hedit,0,number1,10);
a = atof(number1);
Edit_GetLine(hedit1,0,number1,10);
b = atof(number1);
Edit_GetLine(hedit2,0,number1,10);
shag = atof(number1);
d = (b - a) / shag;
y = ((a*a+pow(2.3,a))/(a*+log(pow(a,3)+1)))*(a+cos(a));
min = y;
max = y;
sum=0;
for (x = a; x<b; x+=d) {
char itogx[100] = {"x = "};
char resultx[100]={0};
sprintf(resultx,"%lf",x);
strcat (itogx,resultx);
y = ((x*x+pow(2.3,x))/(x*+log(pow(x,3)+1)))*(x+cos(x));
char itogy[100] = {" y = "};
char resulty[100]={0};
sprintf(resulty,"%lf",y);
strcat (itogy,resulty);
strcat (itogx,itogy);
SendMessage(hlist, LB_ADDSTRING, 0, (LPARAM) itogx);
if (y>max) {
max = y;
}
if (y<min) {
min = y;
}
sum=sum+y;
}
sry=sum/shag;
}
if((HWND)lParam == hButton1){
char minyy[100];
sprintf(minyy,"%lf",min);
SetWindowText(hedit3,minyy);}
if((HWND)lParam == hButton2){
char maxyy[100];
sprintf(maxyy,"%lf",max);
SetWindowText(hedit4,maxyy);}
if((HWND)lParam == hButton3){
char temp[100];
sprintf(temp,"%lf",sry);
SetWindowText(hedit5,temp);}
break;
}
/* Upon destruction, tell the main thread to stop */
case WM_DESTROY: {
PostQuitMessage(0);
break;
}
/* All other messages (a lot of them) are processed using default procedures */
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}