我做了一个计算器,计算>10的就出错怎么办
Win32Project1.c// Win32Project1.cpp : 定义应用程序的入口点。
//
#include"stdafx.h"
#include<windows.h>
#include<windowsx.h>
#include"Resource.h"
#include "Win32Project1.h"
#pragma comment(lib,"comctl32.lib")
BOOL WINAPI Main_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
HANDLE_MSG(hwnd, WM_INITDIALOG, Main_onlnicDialog);
HANDLE_MSG(hwnd, WM_COMMAND, Main_onCommand);
HANDLE_MSG(hwnd, WM_CLOSE, Main_Close);
}
return FALSE;
}
BOOL Main_onlnicDialog(HWND hwnd, HWND hwndm, LPARAM lParam)
{
return TRUE;
}
void Main_onCommand(HWND hwnd, int id, HWND hwndCTl, UINT codeNotify)
{
switch (id)
{
case IDOK:
{
TCHAR ONE[256], TWO[256];
GetDlgItemText(hwnd,IDC_EDIT1,ONE,sizeof(ONE));
GetDlgItemText(hwnd,IDC_EDIT2,TWO,sizeof(TWO));
int ao = atof(ONE);
int at = atof(TWO);
int atr = ao + at;
TCHAR thr[256];
wsprintf(thr,L"%d",atr);
SetDlgItemText(hwnd, IDC_EDIT3,thr);
break;
}
case IDC_OK:
{
TCHAR ONE2[256], TWO2[256];
GetDlgItemText(hwnd,IDC_EDIT4,ONE2,sizeof(ONE2));
GetDlgItemText(hwnd,IDC_EDIT5,TWO2,sizeof(TWO2));
int ao2 = atoi(ONE2);
int at2 = atoi(TWO2);
int atr2 = ao2 - at2;
TCHAR thr2[256];
wsprintf(thr2,L"%d",atr2);
SetDlgItemText(hwnd, IDC_EDIT6,thr2);
break;
}
default:
break;
}
}
void Main_Close(HWND hwnd)
{
EndDialog(hwnd, 0);
}
Main.c:
#include "stdafx.h"
#include "Win32Project1.h"
#include"Resource.h"
#include<COMMCTRL.H>
#pragma comment(lib,"comctl32.lib")
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow)
{
InitCommonControls();
DialogBox(hPrevInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, Main_Proc);
return 0;
}
Win32Project1.h:
#pragma once
#include "resource.h"
#ifndef __WIN32PROJECT_H__
#define __WIN32PROJECT_H__
BOOL WINAPI Main_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL Main_onlnicDialog(HWND hwnd, HWND hwndm, LPARAM lParam);
void Main_onCommand(HWND hwnd, int id, HWND hwndCTl, UINT codeNotify);
void Main_Close(HWND hwnd);
#endif