(API) 老题了 圆面积

#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 ave[101];
	WCHAR line[101];
	int x;
	double n;
    switch(id)
    {
        case IDC_OK:
			{
				GetDlgItemText(hwnd,IDC_EDIT1,ave,sizeof(ave));
				x=atoi(ave);
				n=3.14*x*x;
				swprintf(line,L"%0.2lf",n);
				SetDlgItemTextW(hwnd,IDC_EDIT2,line);
				break;
			}
    }
}

void Main_OnClose(HWND hwnd)
{
    EndDialog(hwnd, 0);
}

你可能感兴趣的:((API) 老题了 圆面积)