1 / 4

讀取 / 設定 Edit Control 的字串

讀取 / 設定 Edit Control 的字串. 使用指標的方式. Reference: 1. p.p. 21-29, Chapter 21, 精通視窗程式設計 2. ms-help://MS.VSCC/MS.MSDNVS/vclib/html/_mfc_CWnd.3a3a.GetDlgItem.htm. 井民全製作. 使用 GetDlgItem 傳回來的位址 , 只是 暫時 的 , 你不應該將他存起來下次再用 :. 如何藉由 Control ID 得到 Control 本身的 位址. 我們知道 CDialog 繼承自 Wnd.

nerea-case
Download Presentation

讀取 / 設定 Edit Control 的字串

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 讀取 / 設定 Edit Control 的字串 使用指標的方式 Reference: 1. p.p. 21-29, Chapter 21, 精通視窗程式設計 2. ms-help://MS.VSCC/MS.MSDNVS/vclib/html/_mfc_CWnd.3a3a.GetDlgItem.htm 井民全製作

  2. 使用 GetDlgItem傳回來的位址,只是暫時的,你不應該將他存起來下次再用: 如何藉由 Control ID 得到 Control 本身的位址 • 我們知道 CDialog 繼承自 Wnd 利用 CWnd::GetDlgItem method 取出 Edit Control 指標 CEdit *wEdit1,*wEdit2; wEdit1=(CEdit*) GetDlgItem(IDC_EDIT1); wEdit2=(CEdit*) GetDlgItem(IDC_EDIT2); wEdit1->SetWindowText("就是甘藷粉+萬能餌(香) … "); 這時,你可以自由使用 CEdit 類別 提供的功能,操作 Control 了

  3. 讀取 wEdit1 的內容放到 wEdit2 中 void CEditControlDemoDlg::OnBnClickedOk() { CString strSource; wEdit1->GetWindowText(strSource); wEdit2->SetWindowText(strSource); } 讀取資料 設定資料 設定初值 BOOL CEditControlDemoDlg::OnInitDialog(){ … wEdit1=(CEdit*)GetDlgItem(IDC_EDIT1); wEdit2=(CEdit*)GetDlgItem(IDC_EDIT2); wEdit1->SetWindowText("就是甘藷粉+萬能餌(香).\r\n…"); … } 實際演練 IDC_EDIT1 IDC_EDIT2

  4. End

More Related