📄 call.cpp
字号:
return 1;
}
return 1;
}
return 0;
}
BOOL CALLBACK ArrayCarryDialog3(HWND hdwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
static float array[3][3];
int i,j;
char p[10];
float d,dx,dy,dz,cx,cy,cz,tx,ty,tz;
switch(message)
{
case WM_INITDIALOG:
for(i=0;i<12;i++)
SetDlgItemText(hdwnd,1000+i,"");
SetDlgItemText(hdwnd,X_RESULT,"");
SetDlgItemText(hdwnd,Y_RESULT,"");
SetDlgItemText(hdwnd,Z_RESULT,"");
return 1;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
for(i=0;i<12;i++)
SetDlgItemText(hdwnd,1000+i,"");
SetDlgItemText(hdwnd,X_RESULT,"");
SetDlgItemText(hdwnd,Y_RESULT,"");
SetDlgItemText(hdwnd,Z_RESULT,"");
return 1;
case IDOK:
for(j=0;j<3;j++)
for(i=0;i<3;i++)
{
GetDlgItemText(hdwnd,1000+j*3+i,p,10);
sscanf(p,"%g",&array[i][j]);
}
GetDlgItemText(hdwnd,IDC_EDIT12,p,10);
sscanf(p,"%g",&cx);
GetDlgItemText(hdwnd,IDC_EDIT11,p,10);
sscanf(p,"%g",&cy);
GetDlgItemText(hdwnd,IDC_EDIT10,p,10);
sscanf(p,"%g",&cz);
d=getanswer(array);
tx=array[0][0];
ty=array[0][1];
tz=array[0][2];
array[0][0]=cx;
array[0][1]=cy;
array[0][2]=cz;
dx=getanswer(array);
array[0][0]=tx;
array[0][1]=ty;
array[0][2]=tz;
tx=array[1][0];
ty=array[1][1];
tz=array[1][2];
array[1][0]=cx;
array[1][1]=cy;
array[1][2]=cz;
dy=getanswer(array);
array[1][0]=tx;
array[1][1]=ty;
array[1][2]=tz;
array[2][0]=cx;
array[2][1]=cy;
array[2][2]=cz;
dz=getanswer(array);
if(d)
{
sprintf(p,"%g",dx/d);
SetDlgItemText(hdwnd,X_RESULT,p);
sprintf(p,"%g",dy/d);
SetDlgItemText(hdwnd,Y_RESULT,p);
sprintf(p,"%g",dz/d);
SetDlgItemText(hdwnd,Z_RESULT,p);
}
else
{
if(dx || dy || dz)
MessageBox(hdwnd,"此方程组无解","结果",MB_OK);
else
{
for(j=0;j<3;j++)
for(i=0;i<3;i++)
if(array[i][j])
{
MessageBox(hdwnd,"此方程组有无穷多个解","结果",MB_OK);
return 1;
}
if(cx || cy ||cz)
MessageBox(hdwnd,"此方程组无解","结果",MB_OK);
else
MessageBox(hdwnd,"此方程组有无穷多个解","结果",MB_OK);
}
}
return 1;
}
return 1;
}
return 0;
}
BOOL CALLBACK DropLineDialog(HWND hdwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
float a,b,c,h,k;
char p[10];
switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hdwnd,IDC_A,"");
SetDlgItemText(hdwnd,IDC_B,"");
SetDlgItemText(hdwnd,IDC_C,"");
SetDlgItemText(hdwnd,A,"");
SetDlgItemText(hdwnd,H,"");
SetDlgItemText(hdwnd,K,"");
return 1;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
if(!GetDlgItemText(hdwnd,IDC_A,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&a))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
if(!a)
{
MessageBox(hdwnd,"二次项系数不能为零!","错误",MB_OK);
return 1;
}
if(!GetDlgItemText(hdwnd,IDC_B,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&b))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
if(!GetDlgItemText(hdwnd,IDC_C,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&c))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
h=b/(2*a);
k=(4*a*c-b*b)/(4*a);
sprintf(p,"%g",h);
SetDlgItemText(hdwnd,H,p);
sprintf(p,"%g",k);
SetDlgItemText(hdwnd,K,p);
sprintf(p,"%g",a);
SetDlgItemText(hdwnd,A,p);
return 1;
case IDCANCEL:
if(!GetDlgItemText(hdwnd,A,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&a))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
if(!a)
{
MessageBox(hdwnd,"二次项系数不能为零!","错误",MB_OK);
return 1;
}
if(!GetDlgItemText(hdwnd,H,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&h))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
if(!GetDlgItemText(hdwnd,K,p,10))
{
MessageBox(hdwnd,"系数未输入完整!","错误",MB_OK);
return 1;
}
if(!sscanf(p,"%g",&k))
{
MessageBox(hdwnd,"系数输入错误!","错误",MB_OK);
return 1;
}
b=2*a*h;
c=a*h*h+k;
sprintf(p,"%g",b);
SetDlgItemText(hdwnd,IDC_B,p);
sprintf(p,"%g",c);
SetDlgItemText(hdwnd,IDC_C,p);
sprintf(p,"%g",a);
SetDlgItemText(hdwnd,IDC_A,p);
return 1;
}
return 1;
}
return 0;
}
BOOL CALLBACK PandCDialog(HWND hdwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
int i;
char *temp;
UINT pa,pb,ca,cb;
UINT pResult=1,cResult=1;
switch(message)
{
case WM_INITDIALOG:
SetDlgItemInt(hdwnd,PABOVE,1,0);
SetDlgItemInt(hdwnd,PBELOW,1,0);
SetDlgItemInt(hdwnd,CABOVE,1,0);
SetDlgItemInt(hdwnd,CBELOW,1,0);
SetDlgItemInt(hdwnd,PRESULT,1,0);
SetDlgItemInt(hdwnd,CRESULT,1,0);
case WM_COMMAND:
switch(LOWORD(wParam))
{
case PEQUA:
temp=(char *)malloc(180);
pResult=1;
pa=GetDlgItemInt(hdwnd,PABOVE,NULL,0);
pb=GetDlgItemInt(hdwnd,PBELOW,NULL,0);
if(pa<=0 || pb<=0)
MessageBox(hdwnd,"数值必须为正!","错误",MB_OK);
else
{
for(i=0;i<pa;i++)
pResult*=(pb-i);
if(pResult==0 && pa<=pb)
SetDlgItemText(hdwnd,PRESULT,"数据过大");
else
SetDlgItemText(hdwnd,PRESULT,_ui64toa(pResult,temp,10));
}
free(temp);
return 1;
case CEQUA:
temp=(char *)malloc(180);
cResult=1;
ca=GetDlgItemInt(hdwnd,CABOVE,NULL,0);
cb=GetDlgItemInt(hdwnd,CBELOW,NULL,0);
if(cb<=0)
MessageBox(hdwnd,"数值必须为正!","错误",MB_OK);
else
{
if(ca>cb)
{
SetDlgItemInt(hdwnd,CRESULT,0,0);
return 1;
}
if(ca>cb-ca)
ca=cb-ca;
for(i=0;i<ca;i++)
cResult*=(cb-i);
for(i=1;i<=ca;i++)
cResult/=i;
if(cResult==0 && ca<=cb)
SetDlgItemText(hdwnd,CRESULT,"数据过大");
else
SetDlgItemText(hdwnd,CRESULT,_ui64toa(cResult,temp,10));
}
free(temp);
return 1;
case IDCANCEL:
cResult=pResult=1;
SetDlgItemInt(hdwnd,PABOVE,1,0);
SetDlgItemInt(hdwnd,PBELOW,1,0);
SetDlgItemInt(hdwnd,PRESULT,1,0);
SetDlgItemInt(hdwnd,CABOVE,1,0);
SetDlgItemInt(hdwnd,CBELOW,1,0);
SetDlgItemInt(hdwnd,CRESULT,1,0);
return 1;
}
return 1;
}
return 0;
}
BOOL CALLBACK DivLineDialog(HWND hdwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
float x0,y0,x1,y1,bia,bib,xr,yr;
char p[10];
switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hdwnd,X_RAY,"");
SetDlgItemText(hdwnd,Y_RAY,"");
SetDlgItemText(hdwnd,X_RAY2,"");
SetDlgItemText(hdwnd,Y_RAY2,"");
SetDlgItemText(hdwnd,X_RAY3,"");
SetDlgItemText(hdwnd,Y_RAY3,"");
SetDlgItemText(hdwnd,BIA,"");
SetDlgItemText(hdwnd,BIB,"");
return 1;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
GetDlgItemText(hdwnd,X_RAY,p,10);
sscanf(p,"%g",&x0);
GetDlgItemText(hdwnd,Y_RAY,p,10);
sscanf(p,"%g",&y0);
GetDlgItemText(hdwnd,X_RAY2,p,10);
sscanf(p,"%g",&x1);
GetDlgItemText(hdwnd,Y_RAY2,p,10);
sscanf(p,"%g",&y1);
GetDlgItemText(hdwnd,BIA,p,10);
sscanf(p,"%g",&bia);
GetDlgItemText(hdwnd,BIB,p,10);
sscanf(p,"%g",&bib);
xr=(x0+bia/bib*x1)/(1+bia/bib);
yr=(y0+bia/bib*y1)/(1+bia/bib);
sprintf(p,"%g",xr);
SetDlgItemText(hdwnd,X_RAY3,p);
sprintf(p,"%g",yr);
SetDlgItemText(hdwnd,Y_RAY3,p);
return 1;
}
return 1;
}
return 0;
}
BOOL CALLBACK RotatePixelDialog(HWND hdwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
float tx,ty,ax,ay,x0,y0,rad;
char p[10];
switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hdwnd,X_RAY,"");
SetDlgItemText(hdwnd,Y_RAY,"");
SetDlgItemText(hdwnd,AROUNDX,"");
SetDlgItemText(hdwnd,AROUNDY,"");
SetDlgItemText(hdwnd,ROTATEDEG,"");
SetDlgItemText(hdwnd,ROTATERAD,"");
SendDlgItemMessage(hdwnd,ZERO_ZERO,BM_SETCHECK,1,0);
SendDlgItemMessage(hdwnd,AROUNDPIXEL,BM_SETCHECK,0,0);
SendDlgItemMessage(hdwnd,DEG,BM_SETCHECK,1,0);
SendDlgItemMessage(hdwnd,RAD,BM_SETCHECK,0,0);
return 1;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ROTATE:
x0=y0=tx=ty=ax=ay=rad=0;
GetDlgItemText(hdwnd,X_RAY,p,10);
sscanf(p,"%g",&x0);
GetDlgItemText(hdwnd,Y_RAY,p,10);
sscanf(p,"%g",&y0);
if(SendDlgItemMessage(hdwnd,AROUNDPIXEL,BM_GETCHECK,0,0))
{
GetDlgItemText(hdwnd,AROUNDX,p,10);
sscanf(p,"%g",&ax);
GetDlgItemText(hdwnd,AROUNDY,p,10);
sscanf(p,"%g",&ay);
x0-=ax;
y0-=ay;
}
tx=x0;
ty=y0;
if(SendDlgItemMessage(hdwnd,DEG,BM_GETCHECK,0,0))
{
GetDlgItemText(hdwnd,ROTATEDEG,p,10);
sscanf(p,"%g",&rad);
rad=rad*(3.14159265/180);
}
else
{
GetDlgItemText(hdwnd,ROTATERAD,p,10);
sscanf(p,"%g",&rad);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -