<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 對話框按鈕簡單使用實例

          對話框按鈕簡單使用實例

          作者: 時間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

          需要先添加對話框,并且修改確定按鈕的ID值

          本文引用地址:http://www.ex-cimer.com/article/201609/303399.htm

          .h文件

          struct DecodeUint{
          UINT meesage;
          LONG (*fun)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
          };

          #define dim(x) (sizeof(x)/sizeof(x[0]))

          LONG OnInit(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
          LONG OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
          LONG OnClose(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
          LONG OnBtnClick(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

          BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

          .c文件

          #include
          #include
          #include Border.h
          #include resource.h
          #include

          struct DecodeUint DlgMessage[] = {
          WM_INITDIALOG,OnInit,
          WM_COMMAND,OnCommand,
          };

          struct DecodeUint DlgCommand[] = {
          IDBTN,OnBtnClick,
          IDCANCEL,OnClose,
          };

          HINSTANCE g_hInst;
          HWND hStatic;

          LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

          int WinMain(HINSTANCE hInstance,
          HINSTANCE hPrevInstance,
          LPTSTR lpCmdLine,
          int nCmdShow)
          {
          g_hInst = hInstance;
          DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,About);
          return 1;
          }

          BOOL CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          {
          for (int i = 0;i dim(DlgMessage);i ++)
          {
          if (DlgMessage[i].meesage == message)
          {
          (*DlgMessage[i].fun)(hDlg,message,wParam,lParam);
          }
          }
          return FALSE;
          }

          LONG OnCommand(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          {
          for (int i = 0;i dim(DlgCommand);i ++)
          {
          if (DlgCommand[i].meesage == LOWORD(wParam))
          {
          (*DlgCommand[i].fun)(hDlg,message,wParam,lParam);
          }
          }

          return TRUE;
          }

          LONG OnInit(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          {
          hStatic = CreateWindow(TEXT(static),TEXT(static text),WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER | SS_CENTERIMAGE,
          10,10,200,200,hDlg,(HMENU)101,g_hInst,NULL);
          return TRUE;
          }

          LONG OnClose(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          {
          EndDialog(hDlg,0);
          return TRUE;
          }

          LONG OnBtnClick(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          {
          //1 獲取文本內(nèi)容 修改對話框標(biāo)題
          //TCHAR * pc;
          //int count = Static_GetTextLength(hStatic);
          //pc = new TCHAR[count+1];
          //Static_GetText(hStatic,pc,count+1);
          //SetWindowText(hDlg,pc);
          //delete pc;

          //2 設(shè)置按鈕不可用
          Button_Enable(GetDlgItem(hDlg,IDCANCEL),FALSE);
          return 0;
          }



          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();