资源预览内容
第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
第9页 / 共11页
第10页 / 共11页
亲,该文档总共11页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
实验报告1 任务概述(任务说明) 设计一个计算器2设计思路(包括技术基础等) 先画出文本框EDIT,在画出按键BUTTON,接受数据后再转换成数据类型int,最后将运算后的结果又粘贴到文本框中。3程序结构描述4源码,文档化加法计算器.h#pragma once#include resource.hResource.h/NO_DEPENDENCIES/ Microsoft Visual C+ generated include file./ Used by 加法计算器.rc/#define IDS_APP_TITLE103#define IDC_EDIT1 1001#define IDC_EDIT2 1002#define IDC_EDIT3 1003#define IDC_BUTTON1 1004#define IDC_BUTTON2 1005#define IDC_BUTTON3 1006#define IDC_BUTTON4 1007#define IDR_MAINFRAME128#define IDD_MY_DIALOG102#define IDD_ABOUTBOX103#define IDM_ABOUT104#define IDM_EXIT105#define IDI_MY107#define IDI_SMALL108#define IDC_MY109#define IDC_MYICON2#ifndef IDC_STATIC#define IDC_STATIC-1#endif/ 新对象的下一组默认值/#ifdef APSTUDIO_INVOKED#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NO_MFC130#define _APS_NEXT_RESOURCE_VALUE129#define _APS_NEXT_COMMAND_VALUE32771#define _APS_NEXT_CONTROL_VALUE1000#define _APS_NEXT_SYMED_VALUE110#endif#endif#define IDI_CALWINAPI107#define IDI_SMALL108#define IDC_CALWINAPI109#define IDC_MYICON2#ifndef IDC_STATIC#define IDC_STATIC-1#define IDC_EDIT1 1001#define IDC_EDIT2 1002#define IDC_EDIT3 1003#define IDC_BUTTON1 1004#define IDC_BUTTON2 1005#define IDC_BUTTON3 1006#define IDC_BUTTON4 1007#endif加法计算器.cpp/ 加法计算器.cpp : 定义应用程序的入口点。/#include stdafx.h#include #include Resource.h#define MAX_LOADSTRING 100/ 全局变量:HINSTANCE hInst;/ 当前实例TCHAR szTitleMAX_LOADSTRING;/ 标题栏文本TCHAR szWindowClassMAX_LOADSTRING;/ 主窗口类名/ 此代码模块中包含的函数的前向声明:ATOMMyRegisterClass(HINSTANCE hInstance);BOOLInitInstance(HINSTANCE, int);LRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACKAbout(HWND, UINT, WPARAM, LPARAM);int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)UNREFERENCED_PARAMETER(hPrevInstance);UNREFERENCED_PARAMETER(lpCmdLine); / TODO: 在此放置代码。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, MAKEINTRESOURCE(IDC_MY);/ 主消息循环:while (GetMessage(&msg, NULL, 0, 0)if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)TranslateMessage(&msg);DispatchMessage(&msg);return (int) msg.wParam;ATOM MyRegisterClass(HINSTANCE hInstance)WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);wcex.| CS_VREDRAW;wcex.lpfnWndProc= WndProc;wcex.cbClsExtra= 0;wcex.cbWndExtra= 0;wcex.hInstance= hInstance;wcex.hIcon= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MY);wcex.hCursor= LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName= MAKEINTRESOURCE(IDC_MY);wcex.lpszClassName= szWindowClass;wcex.hIconSm= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL);return RegisterClassEx(&wcex);BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) HWND hWnd; hInst = hInstance; / 将实例句柄存储在全局变量中 hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) return FALSE; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE;LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)int wmId, wmEvent;PAINTSTRUCT ps;HDC hdc;static HWND hEdit1,hEdit2,hResult1,hButton1,hStatic1,hStatic2;static HWND hEdit3,hEdit4,hResult2,hButton2,hStatic3,hStatic4;static HWND hEdit5,hEdit6,hResult3,hButton3,hStatic5,hStatic6;static HWND hEdit7,hEdit8,hResult4,hButton4,hStatic7,hStatic8;switch (message)case WM_CREATE:hEdit1=:CreateWindowA(EDIT,NULL,WS_CHILD | WS_VISIBLE|WS_BORDER ,30,30,100,20,hWnd,(HMENU) IDC_EDIT1,hInst,NULL);hEdit2=:CreateWindowA(EDIT,NULL,WS_CHILD | WS_VISIBLE|WS_BORDER ,230,30,100,20,hWnd,(HMENU) IDC_EDIT2,hInst,NULL);hEdit3=:CreateWindowA(EDIT,NULL,WS_CHILD | WS_VISIBLE|WS_BORDER ,30,130,100,20,hWnd,(HMENU) IDC_EDIT3,hInst,NULL);hEdit4=:CreateWindowA(EDIT,NULL,WS_CHILD | WS_VISIBLE|WS_BORDER ,230,130,100,20,hWnd,(HMENU) IDC_EDIT1,hInst,NULL);hEdit5=:CreateWindowA(EDIT,NULL,WS_CHILD | WS_VISIBLE|WS_BORDER ,30,230,100,20,hWnd,(HMENU) IDC_ED
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号