#include<windows.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define IDE_RESULT 101
#define IDB_NUM0 110
#define IDB_NUM1 111
#define IDB_NUM2 112
#define IDB_NUM3 113
#define IDB_NUM4 114
#define IDB_NUM5 115
#define IDB_NUM6 116
#define IDB_NUM7 117
#define IDB_NUM8 118
#define IDB_NUM9 119
#define IDB_NUMDEC 120
#define IDB_ADD 121
#define IDB_SUB 122
#define IDB_MUL 123
#define IDB_DIV 124
#define IDB_EQU 127
#define IDB_CE 129
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
HWND hWnd,
hEditResult,//编辑框;
hButton0,hButton1,hButton2,hButton3,
hButton4,hButton5,hButton6,hButton7,
hButton8,hButton9,hButtonDec,
hButtonAdd,hButtonSub,hButtonMul,hButtonDiv,
hButtonEqu,
hButtonCE;
HINSTANCE hInst;
char lpszAddItem[20]="";
char lpszResult[20]="";
char lpszResult1[20]="";
char lpszResult2[20]="";
char lpszOpt[]="N";
char *stop;
double nAddItem=0,nResult=0;
double nResult1=0,nResult2=0;
int nMax;
int nOptF=0;
bool bDec=false; LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
void EquResult();
void NumResult(char *NumData);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
char lpszClassName[]="编辑框";
char lpszTitle[]="计算器";
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"WinIcon");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClassName;
WndClass.lpszMenuName="Menu";
WndClass.style=0;
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
} hInst=hInstance;
hWnd=CreateWindow(
lpszClassName,
lpszTitle,
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
210,230,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
hEditResult=CreateWindow("EDIT", //建立文本框
NULL,
WS_CHILD | WS_VISIBLE | ES_RIGHT | WS_BORDER | ES_READONLY,
10,10,
185,24,
hwnd,
(HMENU)IDE_RESULT,
hInst,
NULL);
hButton7=CreateWindow("BUTTON", //建立按钮7
"7",
WS_CHILD | WS_VISIBLE,
10,40,
30,30,
hwnd,
(HMENU) IDB_NUM7,
hInst,
NULL);
SetWindowText(hEditResult,"0");
break;
case WM_SETFOCUS:
SetFocus(hEditResult);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
// 零至玖与点按钮
case IDB_NUM0:
if (nOptF==0)
break;
NumResult("0");
break;
case IDB_NUM1:
NumResult("1");
break;
case IDB_NUM2:
NumResult("2");
break;
case IDB_NUM3:
NumResult("3");
break;
case IDB_NUM4:
NumResult("4");
break;
case IDB_NUM5:
NumResult("5");
break;
case IDB_NUM6:
NumResult("6");
break;
case IDB_NUM7:
NumResult("7");
break;
case IDB_NUM8:
NumResult("8");
break;
case IDB_NUM9:
NumResult("9");
break;
case IDB_NUMDEC:
if (bDec==true)
break; //如果已按了点号就返回
NumResult(".");
nOptF=1; //按了操作符键
bDec=true; //按了点操作符;
break;
break;
// 加,减,乘,除
case IDB_ADD:
EquResult();
strcpy(lpszOpt,"+"); //设置按了操作符号+
break;
case IDB_SUB:
EquResult();
strcpy(lpszOpt,"-");
break;
case IDB_MUL:
EquResult();
strcpy(lpszOpt,"*");
break;
case IDB_DIV:
EquResult();
strcpy(lpszOpt,"/");
break;
case IDB_EQU:
//算出等于结果
EquResult();
strcpy(lpszOpt,"N");
break;
case IDB_CE:
SetWindowText(hEditResult,"0");
nResult=0;
nAddItem=0;
nResult1=0;
nResult2=0;
strcpy(lpszResult1,"0");
strcpy(lpszResult2,"0");
nOptF=0;
bDec=false;
strcpy(lpszOpt,"N"); //贮存操作符号
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}//-----------------------按下操作符(+,-,*,/,=)处理函数-----------------------
void EquResult()
{
//算出结果
if (strcmp(lpszOpt,"N")==0)
{
nResult1=strtod(lpszResult1,&stop);
}
else
{
switch(*lpszOpt) //比较上一次按的操作符后所得的结果
{
case '+':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1+nResult2;
break;
case '-':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1-nResult2;
break;
case '*':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1*nResult2;
break;
case '/':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
if (nResult2==0)
{
MessageBox(hWnd,"除数不能为零!","功能",MB_OK);
break;
}
nResult1=nResult1/nResult2;
break;
}
}
nResult1=nResult1*1.0;
_gcvt(nResult1,15,lpszResult1); //双精度转化为字符串
SetWindowText(hEditResult,lpszResult1);
nOptF=0;
bDec=false;
}//按下数字键(0~9和小数点)的操作处理函数
void NumResult(char *NumData)
{
if (nOptF==0)
SetWindowText(hEditResult,"");
nMax=GetWindowTextLength(hEditResult)+1;
GetWindowText(hEditResult,lpszAddItem,nMax);
strcat(lpszAddItem,NumData); ///字符串加该数字键的字符
if (strcmp(lpszOpt,"N")==0)
{
strcpy(lpszResult1,lpszAddItem);
SetWindowText(hEditResult,lpszResult1);
}
else
{
strcpy(lpszResult2,lpszAddItem);
SetWindowText(hEditResult,lpszResult2);
}
nOptF=1; //按下了数字键
}
inking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/JISUANQI.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.JISUANQI.exe - 1 error(s), 0 warning
怎么解决啊
急APIVC
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define IDE_RESULT 101
#define IDB_NUM0 110
#define IDB_NUM1 111
#define IDB_NUM2 112
#define IDB_NUM3 113
#define IDB_NUM4 114
#define IDB_NUM5 115
#define IDB_NUM6 116
#define IDB_NUM7 117
#define IDB_NUM8 118
#define IDB_NUM9 119
#define IDB_NUMDEC 120
#define IDB_ADD 121
#define IDB_SUB 122
#define IDB_MUL 123
#define IDB_DIV 124
#define IDB_EQU 127
#define IDB_CE 129
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
HWND hWnd,
hEditResult,//编辑框;
hButton0,hButton1,hButton2,hButton3,
hButton4,hButton5,hButton6,hButton7,
hButton8,hButton9,hButtonDec,
hButtonAdd,hButtonSub,hButtonMul,hButtonDiv,
hButtonEqu,
hButtonCE;
HINSTANCE hInst;
char lpszAddItem[20]="";
char lpszResult[20]="";
char lpszResult1[20]="";
char lpszResult2[20]="";
char lpszOpt[]="N";
char *stop;
double nAddItem=0,nResult=0;
double nResult1=0,nResult2=0;
int nMax;
int nOptF=0;
bool bDec=false; LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
void EquResult();
void NumResult(char *NumData);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
char lpszClassName[]="编辑框";
char lpszTitle[]="计算器";
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,"WinIcon");
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=WndProc;
WndClass.lpszClassName=lpszClassName;
WndClass.lpszMenuName="Menu";
WndClass.style=0;
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
} hInst=hInstance;
hWnd=CreateWindow(
lpszClassName,
lpszTitle,
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
210,230,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&Message,NULL,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
hEditResult=CreateWindow("EDIT", //建立文本框
NULL,
WS_CHILD | WS_VISIBLE | ES_RIGHT | WS_BORDER | ES_READONLY,
10,10,
185,24,
hwnd,
(HMENU)IDE_RESULT,
hInst,
NULL);
hButton7=CreateWindow("BUTTON", //建立按钮7
"7",
WS_CHILD | WS_VISIBLE,
10,40,
30,30,
hwnd,
(HMENU) IDB_NUM7,
hInst,
NULL);
SetWindowText(hEditResult,"0");
break;
case WM_SETFOCUS:
SetFocus(hEditResult);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
// 零至玖与点按钮
case IDB_NUM0:
if (nOptF==0)
break;
NumResult("0");
break;
case IDB_NUM1:
NumResult("1");
break;
case IDB_NUM2:
NumResult("2");
break;
case IDB_NUM3:
NumResult("3");
break;
case IDB_NUM4:
NumResult("4");
break;
case IDB_NUM5:
NumResult("5");
break;
case IDB_NUM6:
NumResult("6");
break;
case IDB_NUM7:
NumResult("7");
break;
case IDB_NUM8:
NumResult("8");
break;
case IDB_NUM9:
NumResult("9");
break;
case IDB_NUMDEC:
if (bDec==true)
break; //如果已按了点号就返回
NumResult(".");
nOptF=1; //按了操作符键
bDec=true; //按了点操作符;
break;
break;
// 加,减,乘,除
case IDB_ADD:
EquResult();
strcpy(lpszOpt,"+"); //设置按了操作符号+
break;
case IDB_SUB:
EquResult();
strcpy(lpszOpt,"-");
break;
case IDB_MUL:
EquResult();
strcpy(lpszOpt,"*");
break;
case IDB_DIV:
EquResult();
strcpy(lpszOpt,"/");
break;
case IDB_EQU:
//算出等于结果
EquResult();
strcpy(lpszOpt,"N");
break;
case IDB_CE:
SetWindowText(hEditResult,"0");
nResult=0;
nAddItem=0;
nResult1=0;
nResult2=0;
strcpy(lpszResult1,"0");
strcpy(lpszResult2,"0");
nOptF=0;
bDec=false;
strcpy(lpszOpt,"N"); //贮存操作符号
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}//-----------------------按下操作符(+,-,*,/,=)处理函数-----------------------
void EquResult()
{
//算出结果
if (strcmp(lpszOpt,"N")==0)
{
nResult1=strtod(lpszResult1,&stop);
}
else
{
switch(*lpszOpt) //比较上一次按的操作符后所得的结果
{
case '+':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1+nResult2;
break;
case '-':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1-nResult2;
break;
case '*':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
nResult1=nResult1*nResult2;
break;
case '/':
nResult1=strtod(lpszResult1,&stop);
nResult2=strtod(lpszResult2,&stop);
if (nResult2==0)
{
MessageBox(hWnd,"除数不能为零!","功能",MB_OK);
break;
}
nResult1=nResult1/nResult2;
break;
}
}
nResult1=nResult1*1.0;
_gcvt(nResult1,15,lpszResult1); //双精度转化为字符串
SetWindowText(hEditResult,lpszResult1);
nOptF=0;
bDec=false;
}//按下数字键(0~9和小数点)的操作处理函数
void NumResult(char *NumData)
{
if (nOptF==0)
SetWindowText(hEditResult,"");
nMax=GetWindowTextLength(hEditResult)+1;
GetWindowText(hEditResult,lpszAddItem,nMax);
strcat(lpszAddItem,NumData); ///字符串加该数字键的字符
if (strcmp(lpszOpt,"N")==0)
{
strcpy(lpszResult1,lpszAddItem);
SetWindowText(hEditResult,lpszResult1);
}
else
{
strcpy(lpszResult2,lpszAddItem);
SetWindowText(hEditResult,lpszResult2);
}
nOptF=1; //按下了数字键
}
inking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/JISUANQI.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.JISUANQI.exe - 1 error(s), 0 warning
怎么解决啊
急APIVC
解决方案 »
- vs2010 的mfc怎么转成2005版本?
- 程序运行错误
- 如何断开一台计算机的INTER网(外网),保持局域网
- [请教]一般用的数码产品如:MD,mp3,数码相机等里面的操作系统是什么?用什么语言来开发呢?
- 有人知道MAPI和CDO吗
- 为什么vc的窗体回车或按Esc就Close掉了,怎么把这个功能就干掉?
- 一个做FTP的问题...请各位大侠帮忙..谢了
- 谁知道为什么我的机器上不可以运行cl.exe可执行文件,但另一台可以
- ★决定改用BCB和Delphi,VC把我搞晕了什么MFC、STL去死!★
- 有没有学习vc++的好一点的方法呢。请大家指教!!
- RECT相关问题
- 怎么判断264帧是不是关键帧
1. C++ :CONSOLE 改为 WINDOWS
2. link:subsytem/console 改为 /windows