1 HWND hwnd; 2 GetDlgItem(IDC_EDIT1,&hwnd); 3 if (hwnd != NULL) 4 { 5 ::SendMessage(hwnd,EM_SETPASSWORDCHAR, (WPARAM)"*", 0);//用*代替字符,但是并不改变字符,即将这几行代码放入对话框初始化中,可以将IDC_EDIT1编辑框设置为密码框 6 ::UpdateWindow(hwnd); 7 } 8 9 else10 {11 AfxMessageBox(_T("未找到!"));12 }