編寫簡單的windows案頭計算機程式

來源:互聯網
上載者:User

標籤:==   cancel   bool   pcm   pie   ret   windows   技術   resource   

編譯環境:VS2017

主檔案為:

 1 #include "stdafx.h" 2 #include "WindowsProject5.h" 3 #include "Resource.h" 4 #define NULL 0 5  6  7 //回呼函數 8 BOOL CALLBACK    MainProc( 9     HWND hwndDlg, 10     UINT uMsg,11     WPARAM wParam, 12     LPARAM lParam)13 {14     //以下三行為調試語句,可去除15     char s[256];16     wsprintf((LPWSTR)s,L"uMsg=%d,wParam=%d,lParam=%d\n", uMsg, wParam, (int)lParam);17     OutputDebugStringW((LPWSTR)s);18 19     //對於菜單、加速鍵來說,點擊後發送WM_COMMAND訊息20     if (WM_COMMAND == uMsg)21     {    22         //如果點擊取消按鈕,關閉對話方塊23         if (LOWORD(wParam) == IDCANCEL)24         {25             EndDialog(hwndDlg, IDCANCEL);26             return TRUE;27         };28         //如果點擊計算按鈕,進行加法計算,得出結果29         if (LOWORD(wParam) == IDOK)30         {31             int nLeft = GetDlgItemInt(hwndDlg, IDC_LEFT, NULL, TRUE);32             int nRight = GetDlgItemInt(hwndDlg, IDC_RIGHT, NULL, TRUE);33             int nResult = nLeft + nRight;34             SetDlgItemInt(hwndDlg,IDC_RESULT,nResult,TRUE);35         }36     }37     return FALSE;38 }39 40 //win主函數41 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,42                      _In_opt_ HINSTANCE hPrevInstance,43                      _In_ LPWSTR    lpCmdLine,44                      _In_ int       nCmdShow)45 {46  47     DialogBox(hInstance,(LPWSTR)IDD_DIALOG1,0,(DLGPROC)MainProc);48     return 0;49  }

資源檔:

1 #define IDI_ICON2                       1312 #define IDD_DIALOG1                     1333 #define IDC_RESULT                      10044 #define IDC_RIGHT                       10055 #define IDC_LEFT                        10066 #define IDC_STATIC                      -1

對話方塊:

運行結果:

 

編寫簡單的windows案頭計算機程式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.