#include "stdafx.h"
#include "resource.h"
#include <stdio.h>
#define MAX_LOADSTRING 100
HINSTANCE hInst;
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING];
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK win(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_MY, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY);
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwin;
switch (message)
{
case WM_CREATE:
hwin = CreateDialog(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)win);
ShowWindow(hwin,SW_SHOW);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK win(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int i;
static int a,b,c;
static char txt[9];
static char ct;
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_BUTTON1:
if(i==0)
sprintf(txt,"%d",1);
else
{
sprintf(txt,"%d%d",i,1);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON2:
if(i==0)
sprintf(txt,"%d",2);
else
{
sprintf(txt,"%d%d",i,2);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON3:
if(i==0)
sprintf(txt,"%d",3);
else
{
sprintf(txt,"%d%d",i,3);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON4:
if(i==0)
sprintf(txt,"%d",4);
else
{
sprintf(txt,"%d%d",i,4);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON5:
if(i==0)
sprintf(txt,"%d",5);
else
{
sprintf(txt,"%d%d",i,5);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON6:
if(i==0)
sprintf(txt,"%d",6);
else
{
sprintf(txt,"%d%d",i,6);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON7:
if(i==0)
sprintf(txt,"%d",7);
else
{
sprintf(txt,"%d%d",i,7);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON8:
if(i==0)
sprintf(txt,"%d",8);
else
{
sprintf(txt,"%d%d",i,8);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON9:
if(i==0)
sprintf(txt,"%d",9);
else
{
sprintf(txt,"%d%d",i,9);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON10:
if(i==0)
sprintf(txt,"%d",0);
else
{
sprintf(txt,"%d%d",i,0);
}
i=atoi(txt);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
break;
case IDC_BUTTON11:
a=atoi(txt);
ct='+';
SetDlgItemText(hWnd,IDC_EDIT1,"");
i=0;
break;
case IDC_BUTTON12:
a=atoi(txt);
ct='-';
SetDlgItemText(hWnd,IDC_EDIT1,"");
i=0;
break;
case IDC_BUTTON13:
a=atoi(txt);
ct='*';
SetDlgItemText(hWnd,IDC_EDIT1,"");
i=0;
break;
case IDC_BUTTON14:
a=atoi(txt);
ct='/';
SetDlgItemText(hWnd,IDC_EDIT1,"");
i=0;
break;
case IDC_BUTTON15:
b=atoi(txt);
switch(ct)
{
case '+':
c=a+b;
break;
case '-':
c=a-b;
break;
case '*':
c=a*b;
break;
case '/':
c=a/b;
break;
}
sprintf(txt,"%d",c);
SetDlgItemText(hWnd,IDC_EDIT1,txt);
i=0;
break;
case IDM_EXIT:
DestroyWindow(hWnd);
PostQuitMessage(0);
break;
}
}
return 0;
}
不知道怎么上传winzip文件只能贴代码