想做一个计算器,首先实现在编辑框输入数字,编了以下程序,结果自己定义的函数出错,求高手解答
#include "stdafx.h"#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include "MainDlg.h"
#include <stdlib.h>
#include <string.h>
TCHAR Num[256];
BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}
return FALSE;
}
BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
return TRUE;
}
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_BUT0:
ShowNumber(hwnd,0);
break;
case IDC_BUT1:
ShowNumber(hwnd,1);
break;
case IDC_BUT2:
ShowNumber(hwnd,2);
break;
case IDC_BUT3:
ShowNumber(hwnd,3);
break;
case IDC_BUT4:
ShowNumber(hwnd,4);
break;
case IDC_BUT5:
ShowNumber(hwnd,5);
break;
case IDC_BUT6:
ShowNumber(hwnd,6);
break;
case IDC_BUT7:
ShowNumber(hwnd,7);
break;
case IDC_BUT8:
ShowNumber(hwnd,8);
break;
case IDC_BUT9:
ShowNumber(hwnd,9);
break;
default:
break;
}
}
void ShowNumber(HWND hwnd,int i)
{
TCHAR iNum[256];
itoa(i,iNum,10);
strcat(Num,iNum);
SetDlgItemText(hwnd,IDC_EDIT,Num);
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}
error C2065: 'ShowNumber' : undeclared identifier
error C2373: 'ShowNumber' : redefinition; different type modifiers