前端之家收集整理的这篇文章主要介绍了
尼玛终于熬过头了从VB走过再次看见窗体的喜悦 SDK加法计算器,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#include "stdafx.h"
#include "iostream"
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include "MainDlg.h"
using namespace std;
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)
{
TCHAR name1[101];
TCHAR name2[101];
TCHAR name3[101];
int sum,n1,n2;
switch(id)
{
case IDC_OK:
GetDlgItemText(hwnd,IDC_EDIT1,name1,sizeof(name1));
GetDlgItemText(hwnd,IDC_EDIT2,name2,sizeof(name2));
n1=atoi(name1);
n2=atoi(name2);
sum=n1+n2;
wsprintf(name3,"%i",sum);
SetDlgItemText(hwnd,IDC_EDIT3,name3);
break;
default:
break;
}
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd,0);
}
原文链接:https://www.f2er.com/vb/259786.html