[HELP] - Weird Access Violation... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

[HELP] - Weird Access Violation...

Hi, I'm french programmer,

This is a peace of my code :

Effect=1;
SetDlgItemText(hDlg, IDC_EFFET, "E");
SendDlgItemMessage(hDlg, IDC_TYPE, CB_RESETCONTENT, NULL, NULL);
SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Virement");
SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Chque");
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, "");
SetDlgItemText(hDlg, IDC_DESC, "");
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, "");

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, "");

Generate an error too. That is weird is that a friends, in this house, have not this errors. What to do ?

Thanks...

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : Hi, I'm french programmer,
    :
    : This is a peace of my code :
    :
    : Effect=1;
    : SetDlgItemText(hDlg, IDC_EFFET, "E");
    : SendDlgItemMessage(hDlg, IDC_TYPE, CB_RESETCONTENT, NULL, NULL);
    : SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Virement");
    : SendDlgItemMessage(hDlg, IDC_TYPE, CB_ADDSTRING, NULL, (LPARAM)"Chque");
    : 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, "");
    : SetDlgItemText(hDlg, IDC_DESC, "");
    : 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, "");
    :
    : 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, "");
    :
    : Generate an error too. That is weird is that a friends, in this house, have not this errors. What to do ?
    :
    : Thanks...
    :
    [blue]First of all - you do not need to terminate every constant string with '' - 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.
    [code]
    _ASSERT (IsWindow (hDlg)); // Test if handle is REALLY a valid HWND
    SetDlgItemText (hDlg, IDC_MONTANT, "");
    [/code]
    #2.
    [code]
    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).
    [/code]
    That is, probably, all I can advise.[/blue]
Sign In or Register to comment.