as an update, i can make it tell me that theres no text in the dialog
Code:
case ID_ENC_ENCRYPT:
{
char algorithm[31] = "Az!By@Cx#Dw$Ev%Fu^Gt&Hs*Ir(Js)";
TCHAR *buf;
char *converted_int;
int i, len;
HWND hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
len = GetWindowTextLength(hEdit);
buf = (TCHAR *)malloc(len+1);
if (len <= 0) { MessageBox(hwnd, "There is no text to encrypt.", "Error.", MB_OK | MB_ICONERROR); return FALSE; }
GetDlgItemText(hwnd, IDC_CHILD_EDIT, buf, len);
for (i = 0; i <= len; i++)
{
buf[i] = buf[i] ^ algorithm[i % 30];
}
SendMessage(hEdit, WM_SETTEXT, 0, (LPARAM)buf);
free(buf);
}
break;
that codes give me the "a programmer f*d up and Microsoft wants to hear about it " message.
*bites tongue*
uhm.......for some reason its working.?.this time...all i did was remove some comments and some MessageBox's that were telling me how far into the function the program got.
mm..it seems i found the problem to be trying to have a messagebox display an int. the var "len" was an int, but i had the code:
Code:
MessageBox(hwnd, (LPCSTR)len, "Contents of: len", MB_OK | MB_ICONINFORMATION);
and that freaked things out. hmm..explanation?
but i'm still getting a "there's no text entered" in a dif function.
Code:
BOOL CALLBACK SetPassProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_PASSBTN:
{
int TxtLen;
HWND hEdit = GetDlgItem(hwnd, ID_PWDPROMPT);
TxtLen = SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0);
TCHAR *buf = (TCHAR *)malloc (TxtLen+1);
GetWindowText(hEdit, buf, TxtLen);
if (TxtLen <= 0)
{ MessageBox(hwnd, "There is no text entered.", "Error.", MB_OK | MB_ICONERROR); return FALSE; }
GetDlgItemText(hwnd, ID_PWDPROMPT, buf, TxtLen);
/* other code that doesn't get executed. */
}
break;
}
break;
default:
return FALSE;
break;
}
return TRUE;
}