mfc文件中顯示對話方塊內容的函式?
使用者8561832946998 發表于 文化2022-11-30
1:獲取編輯框的數值:GetDlgItemInt(IDC_EDIT2)
例子:int a = GetDlgItemInt(hwndDlg,IDC_a,NULL,TRUE);///註釋:用GetDlgItemInt函式獲取hwndDlg視窗中的IDC_a控制元件中輸入的整數值並賦給變數a。
UpdateData(TRUE);
CString Str_pos;
m_PlanPosition。GetWindowText(Str_pos);m_PlanPosition型別為Cedit
long m_position=_ttol(Str_pos);//將字串轉成長整型,類似,可以將字串型轉成需要的。
2:將資料顯示到編輯框中:
法一:此時編輯框關聯的變數型別為CEdit時
int i = GetDlgItemInt(IDC_EDIT2);
CString str;
str。Format(“%d”, i);
m_edit2。SetWindowText(str);