I've created a rich edit control in
IDD_DIALOG2
,
ThirdDlg.cpp. When I click button
void CSecondDlg::BtnNextThirdDlg()
to go to the next dialog
ThirdDlg.cpp, I can't go there because I have an error: "Services.exe has triggered a breakpoint". When I search Call Stack, I have this "> Services.exe!CSecondDlg::BtnNextThirdDlg() Line 542 C++". I have an arrow that is showing one of the lines of code
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
in this function:
void CSecondDlg::BtnNextThirdDlg()
{
CString strFirstPassword, strSecondPassword;
GetDlgItemText(IDC_EDIT1, strFirstPassword);
GetDlgItemText(IDC_EDIT2, strSecondPassword);
CButton* pRadExist = (CButton*)GetDlgItem(IDC_RADIO1);
int nChecked = pRadExist->GetCheck();
CString password;
GetDlgItemText(IDC_EDIT1, password);
bool containsSpecialCharacter = false;
bool containsNumber = false;
bool containsUppercase = false;
bool containsLowercase = false;
for (int i = 0; i < password.GetLength(); ++i)
{
if (!isalnum(password[i]) && !isspace(password[i]))
{
containsSpecialCharacter = true;
}
if (isdigit(password[i]))
{
containsNumber = true;
}
if (isupper(password[i]))
{
containsUppercase = true;
}
if (islower(password[i]))
{
containsLowercase = true;
}
}
CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_COMBO1);
int selectedIndex = pCombo->GetCurSel();
CString enteredPassword;
GetDlgItemText(IDC_EDIT1, enteredPassword);
if (nChecked == BST_CHECKED) {
CString username;
GetDlgItemText(IDC_EDIT3, username);
if (username.IsEmpty())
{
AfxMessageBox(_T("Użytkownik musi napisać
nazwę użytkownika."), MB_ICONWARNING);
}
CString password;
GetDlgItemText(IDC_EDIT1, password);
bool containsSpecialCharacter = false;
}
else if (enteredPassword != _T("xsw2!QAZ"))
{
AfxMessageBox(_T("Hasło jest nieprawidłowe"));
}
else if (IsDlgButtonChecked(IDC_RADIO2) != BST_CHECKED)
{
if (strFirstPassword != strSecondPassword) {
AfxMessageBox(_T("Hasła muszą być takie same."),
MB_ICONWARNING);
return;
}
}
else if (strFirstPassword.GetLength() < 8) {
AfxMessageBox(_T("Hasło musi mieć więcej lub
równe 8 znaków"), MB_ICONWARNING);
return;
}
else if (!containsSpecialCharacter || !containsNumber ||
!containsUppercase || !containsLowercase) {
AfxMessageBox(_T("Regulamin haseł: 1. Hasło musi mieć
chociaż jeden znak specjalny. 2.Hasło musi mieć chociaż
jedną liczbę. 3.Hasło musi mieć chociaż jedną dużą literę.
4.Hasło musi mieć chociaż jedną małą literę."), MB_ICONWARNING);
}
else
{
CDialog dlg(IDD_DIALOG1, this);
CRect rectSecondDlg;
m_thirdDlg.GetWindowRect(&rectSecondDlg);
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int dlgWidth = rectSecondDlg.Width();
int dlgHeight = rectSecondDlg.Height();
int dlgX = (screenWidth - dlgWidth) / 2;
int dlgY = (screenHeight - dlgHeight) / 2;
m_thirdDlg.SetWindowPos(NULL, dlgX, dlgY, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
ShowWindow(SW_HIDE);
m_thirdDlg.ShowWindow(SW_SHOW);
}
}
What I have tried:
In
ThirdDlg.cpp, I've added not many lines of code because I was thinking that maybe the control/light is empty, so I did this:
void CThirdDlg::OnEnChangeRichedit22()
{
int nLength = m_EditRich.GetWindowTextLength();
if (nLength > 0) {
CString strRichEditContent;
m_EditRich.GetWindowText(strRichEditContent);
SetDlgItemText(IDC_EDIT1, strRichEditContent);
}
else {
AfxMessageBox(_T("Kontrolka Rich Edit jest pusta."));
}
}