EDN Admin
Well-known member
Hi, I have a problem here.<br/>
This is my code:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; case IDC_NC2:
<span style="color:Blue; int len1, len2, len3;
LPSTR nome, senha, rsenha;
<span style="color:Green; // Nome de Login
len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT2));
nome = (LPSTR)GlobalAlloc(GPTR, len1 + 1);
SendMessage(GetDlgItem(hwnd, IDC_EDIT2), WM_GETTEXT, len1 + 1, (LPARAM)nome);
<span style="color:Green; // Senha
len2 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT3));
senha = (LPSTR)GlobalAlloc(GPTR, len2 + 1);
<span style="color:Green; // Repita a Senha
len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT4));
rsenha = (LPSTR)GlobalAlloc(GPTR, len3 + 1 );
<span style="color:Green; // Nome ou senha menor que 4 dígitos, Senha errada:
<span style="color:Blue; if(len1 < 4 )
{
MessageBox(hwnd, L<span style="color:#A31515; "Seu nome tem que ser maior do que 4 dígitos!", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
<span style="color:Blue; else <span style="color:Blue; if (len2 < 4 )
{
MessageBox(hwnd, L<span style="color:#A31515; "Sua senha tem que ser maior do que 4 dígitos!", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
<span style="color:Blue; else <span style="color:Blue; if( (LPCWSTR)GetDlgItemText(hwnd, IDC_EDIT4, (LPWSTR)rsenha, len3 + 1) != (LPCWSTR)GetDlgItemText(hwnd, IDC_EDIT3, (LPWSTR)senha, len2 + 1) )
{
MessageBox(hwnd, L<span style="color:#A31515; "Repita sua senha corretamente", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
[/code]
Even if "senha" is dddd and "rsenha" ddds the MessageBox doesnt appears. It just appears when the number of characters are different.<br/>
I tried to use strcmp and it didnt work. Thanks for the help<br/>
View the full article
This is my code:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; case IDC_NC2:
<span style="color:Blue; int len1, len2, len3;
LPSTR nome, senha, rsenha;
<span style="color:Green; // Nome de Login
len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT2));
nome = (LPSTR)GlobalAlloc(GPTR, len1 + 1);
SendMessage(GetDlgItem(hwnd, IDC_EDIT2), WM_GETTEXT, len1 + 1, (LPARAM)nome);
<span style="color:Green; // Senha
len2 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT3));
senha = (LPSTR)GlobalAlloc(GPTR, len2 + 1);
<span style="color:Green; // Repita a Senha
len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT4));
rsenha = (LPSTR)GlobalAlloc(GPTR, len3 + 1 );
<span style="color:Green; // Nome ou senha menor que 4 dígitos, Senha errada:
<span style="color:Blue; if(len1 < 4 )
{
MessageBox(hwnd, L<span style="color:#A31515; "Seu nome tem que ser maior do que 4 dígitos!", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
<span style="color:Blue; else <span style="color:Blue; if (len2 < 4 )
{
MessageBox(hwnd, L<span style="color:#A31515; "Sua senha tem que ser maior do que 4 dígitos!", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
<span style="color:Blue; else <span style="color:Blue; if( (LPCWSTR)GetDlgItemText(hwnd, IDC_EDIT4, (LPWSTR)rsenha, len3 + 1) != (LPCWSTR)GetDlgItemText(hwnd, IDC_EDIT3, (LPWSTR)senha, len2 + 1) )
{
MessageBox(hwnd, L<span style="color:#A31515; "Repita sua senha corretamente", L<span style="color:#A31515; "Erro!", MB_OK | MB_ICONINFORMATION);
<span style="color:Blue; break;
}
[/code]
Even if "senha" is dddd and "rsenha" ddds the MessageBox doesnt appears. It just appears when the number of characters are different.<br/>
I tried to use strcmp and it didnt work. Thanks for the help<br/>
View the full article