只实现了外观,功能 还没有实现,有时间再把它补全
main.cpp文件如下:
#include <Windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
HWND hWnd;
WNDCLASS wndclass;
MSG msg;
static TCHAR szAppName[]= TEXT("我的世界");
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDC_ARROW);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszClassName = szAppName;
wndclass.lpszMenuName = NULL;
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
if (!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("窗口无法显示"), szAppName, MB_ICONERROR);
return 0;
}
hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, NULL);
ShowWindow(hWnd, iCmdShow);
while (GetMessage(&msg, hWnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//static BOOL bNewNumber = TRUE;
//static int iOperator = '=';
//static UINT iNumber, iFirstNum;
//HWND hButton;
//HDC hdc;
//HFONT hFont;
//设置字体
//LOGFONT lf;
//TEXTMETRIC tm;
// SaveDC(hdc);
switch (message)
{
case WM_SETFONT:
//hdc = GetDC(hwnd);
//GetTextMetrics(hdc, &tm);
//lf.lfHeight = 35;
//hFont = CreateFontIndirect(&lf);
//SelectObject(hdc, hFont);
//ReleaseDC(hwnd, hdc);
break;
case WM_INITDIALOG:
break;
case WM_KEYDOWN:
break;
case WM_CHAR:
break;
case WM_COMMAND:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
resource.rc 文件如下:
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Resource.rc 使用
//
#define IDD_DIALOG1 101
#define IDC_EDIT_RESULT 1001
#define IDC_BUTTON_PERCENT 1002
#define IDC_BUTTON2 1003
#define IDC_NUMBER_7 1004
#define IDC_NUMBER_4 1005
#define IDC_NUMBER_1 1006
#define IDC_BUTTON_PLUSMINUS 1007
#define IDC_BUTTON_ROOT 1008
#define IDC_BUTTON8 1009
#define IDC_NUMBER_8 1010
#define IDC_NUMBER_5 1011
#define IDC_NUMBER_2 1012
#define IDC_NUMBER_0 1013
#define IDC_BUTTON_RECIPROCAL 1014
#define IDC_BUTTON_DIV 1015
#define IDC_BUTTON_MUL 1016
#define IDC_BUTTON_MINUS 1017
#define IDC_BUTTON_PLUS 1018
#define IDC_BUTTON18 1019
#define IDC_BUTTON_EQUAL 1019
#define IDC_BUTTON_SQUARE 1020
#define IDC_BUTTON20 1021
#define IDC_NUMBER_9 1022
#define IDC_NUMBER_6 1023
#define IDC_NUMBER_3 1024
#define IDC_BUTTON24 1025
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
实现界面如图所示:
---------------------重新写了一个,大家可以移步到此
https://blog.csdn.net/celly20/article/details/89005992