Voila mon probleme, je creer un programme dessinant des courbes (fonction,point par point).
Mais j'ai un probleme, lors ce que je teste et je rentre les valeur mini, maxi rien ne se passe et dés que je met des static à la place de simple int le programme plante dés le demarrage.
Pouvait vous m'aider ?
Voici le code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
RECT rcClient;
POINT Poly [4] = {425,10,
425,310,
775,310,
775,10
};
int firstx = 425;
int secondx = 775;
int firsty = 10;
int secondy = 310;
int x;
int y;
int refx;
int refy;
int paint;
int dist = 0;
int xmin = 0,xmax = 0;
HPEN absord = (HPEN) CreatePen (PS_SOLID,2,RGB(0,0,0));
HPEN courbee = (HPEN) CreatePen (PS_SOLID,2,RGB(255,55,16));
switch (message) /* handle the messages */
{
case WM_CREATE:
CreateFirst(hwnd);
CreateSecond (hwnd);
CreateThird(hwnd);
CreateFourth(hwnd);
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDE_DIST && HIWORD(wParam) == EN_CHANGE)
{
GetWindowText (hdist,egal,10);
dist = atoi(egal);
GetClientRect(hwnd, &rcClient);
InvalidateRect(hwnd, &rcClient, false);
}
if (LOWORD(wParam) == IDE_XMAX && HIWORD(wParam) == EN_CHANGE)
{
GetWindowText (hxmax,egal,10);
xmax = atoi(egal);
GetClientRect(hwnd, &rcClient);
InvalidateRect(hwnd, &rcClient, false);
}
if (LOWORD(wParam) == IDE_XMIN && HIWORD(wParam) == EN_CHANGE)
{
GetWindowText (hxmin,egal,10);
xmin = atoi(egal);
GetClientRect(hwnd, &rcClient);
InvalidateRect(hwnd, &rcClient, false);
}
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
POINT pos;
hDC = BeginPaint (hwnd,&ps);
Polygon (hDC,Poly,4 );
MoveToEx (hDC,425,10,&pos);
SelectObject (hDC,absord);
LineTo(hDC,425,310);
LineTo(hDC,775,310);
//---
MoveToEx (hDC,firstx,secondy,&pos);
refx = (secondx - firstx) / xmax;
refy = (secondy - firsty) / 10;
for (paint = 0; paint <= xmax;paint+=dist)
{
MoveToEx (hDC,firstx,secondy,&pos);
x = firstx + (paint*refx);
MoveToEx (hDC,x,310,&pos);
LineTo (hDC,x,305);
MoveToEx (hDC,firstx,secondy,&pos);
y = secondy - (paint*refy);
MoveToEx (hDC,425,y,&pos);
LineTo (hDC,430,y);
}
SelectObject (hDC,courbee);
MoveToEx (hDC,firstx,secondy,&pos);
for (paint = 0; paint <= xmax;paint+=dist)
{
x = firstx + (paint*refx);
y = secondy - (paint*refy);
if( y < 10)
break;
LineTo (hDC,x,y);
}
//---
EndPaint (hwnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}