: Hi, I'm french programmer,
:
: This is a peace of my code :
:
: Effect=1;
: SetDlgItemText(hDlg, IDC_EFFET, "E\0");
: SendDlgItemMessage(hDlg, IDC_TYPE, CB_RESETCONTENT, NULL, NULL);
: SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Virement\0");
: SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Chque\0");
: SendDlgItemMessage(hDlg, IDC_TYPE, CB_SETCURSEL, 0, NULL);
: SendDlgItemMessage(hDlg, IDC_JOURS, CB_SETCURSEL, 0, NULL);
: SendDlgItemMessage(hDlg, IDC_FIN_MOIS, CB_SETCURSEL, 0, NULL);
: SendDlgItemMessage(hDlg, IDC_FIN_ANNEE, CB_SETCURSEL, 0, NULL);
: SetDlgItemText(hDlg, IDC_MONTANT, "\0");
: SetDlgItemText(hDlg, IDC_DESC, "\0");
: SetFocus(GetDlgItem(hDlg, IDC_DESC));
:
: This code is in one of my projects since somes days, but, since yesterday morning, the line :
:
: SetDlgItemText(hDlg, IDC_DESC, "\0");
:
: Generate an exception :
:
: First-chance exception in FFbudget.exe: 0xC0000005: Access Violation.
:
: So, thinking that it's coming from error in my code, i search since yesterday, i have change nothing, and this morning the line
:
: SetDlgItemText(hDlg, IDC_MONTANT, "\0");
:
: Generate an error too. That is weird is that a friends, in this house, have not this errors. What to do ?
:
: Thanks...
:
First of all - you do not need to terminate every constant string with '\0' - the compiler does it for you. So, "" - means empty string.
As for the problem - you have to make sure that dialog resource refenced by 'hDlg' really has the text box with ID='IDC_MONTANT'.
Try also these things:
#1.
_ASSERT (IsWindow (hDlg)); // Test if handle is REALLY a valid HWND
SetDlgItemText (hDlg, IDC_MONTANT, "");
#2.
SetDlgItemText (hDlg, IDC_MONTANT, "");
DWORD dwErrCode = GetLastError ();
// ^^^ See if this 'dwErrCode' is not zero and if it is map this
// value to the Win32 error code map (available in MSDN).
That is, probably, all I can advise.