Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3711
Number of posts: 9173

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
[HELP] - Weird Access Violation... Posted by 69VobD3PH on 20 Jan 2003 at 7:09 AM
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...
Report
Re: [HELP] - Weird Access Violation... Posted by AsmGuru62 on 20 Jan 2003 at 7:54 AM
: 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.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.