//Copyrifht (C) 20 LUN 2004 Keisuke Kigawa All Rights Reserved. #include #include "stcwnd.h" #include "edtwnd.h" #include "btnwnd.h" //定数 #define MY_WNDCLASS "MYWNDCLASS" #define MY_CAPTION "償却率" //グローバル変数 HINSTANCE g_hInst; HWND g_hWnd; //関数のプロトタイプ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR lpCmdLine, int nCmdShow); LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASSEX wc; HWND hWnd; g_hInst = hInst; //ウィンドウクラス登録 ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = (WNDPROC)WndProc; wc.hInstance = hInst; wc.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); wc.lpszClassName = MY_WNDCLASS; RegisterClassEx(&wc); //ウィンドウ作成 hWnd = CreateWindowEx(0, MY_WNDCLASS, NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 430, 210, NULL, NULL, hInst, NULL); //g_hWnd = hWnd; //ウィンドウ描画 ShowWindow(hWnd, nCmdShow); while(GetMessage(&msg, NULL, 0, 0)){ TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int ans; switch(uMsg){ case WM_CREATE: SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)MY_CAPTION);//ウィンドウタイトル StcWnd(g_hInst, hWnd);//スタティックウィンドウ EdtWnd(g_hInst, hWnd);//エディタウィンドウ BtnWnd(g_hInst, hWnd);//ボタンウィンドウ SetEdtText();//エティタウィンドウ初期化 break; case WM_COMMAND: switch(wParam){ case ID_BUTTON1://求める ans = GetEdtText(); if(ans == 0) MessageBox(hWnd, "数値を入力してください。", "注意", MB_ICONWARNING|MB_OK); break; case ID_BUTTON2://閉じる //子ウィンドウ破棄 DesStcWnd(); DesEdtWnd(); DesBtnWnd(); //ウィンドウ破棄 DestroyWindow(hWnd); break; default: break; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; }