Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Debug and Release build

11 views
Skip to first unread message

Vivek

unread,
May 18, 2004, 12:46:26 AM5/18/04
to
Hi,
I am working on win2000 and VC6.0
I am using user defined messages WM_USER + X (in dialog base application)
Now problem is that to invoke my messages I am using SendMessage and
PostMessage functions.
It works fine when I am working in Debug built.
But when I shift to Release built it works only once i.e.
it gives me error : the instruction at "0x00426b1c" referenced memory at
"0x0000046c". The memory could not be "read".
and I have to restart the application.

But this does not happen in Debug mode I can invoke userdefined messages
many times without error.

Why this is happening or am I missing any logic of user defined messages.

Your reply is highly appriciated.
Thanx in advance

Vivek


Frank Kaehler

unread,
May 18, 2004, 1:27:50 AM5/18/04
to

Hi Vivek,

I think you have "found" an old problem (debug <-> release).

Your message-functions must return a value!

e.g.
//the define
#define MY_MESSAGE WM_USER + 1

//the message handler for MFC
//not required with WIN-API
ON_MESSAGE(MY_MESSAGE, myMessageFunc)

//the function (for WIN-API)
LRESULT myMessageFunc(WPARAM wp, LPARAM lp)
{
//do something
return 0;
}

//the function (for MFC)
LRESULT MyClass::myMessageFunc(WPARAM wp, LPARAM lp)
{
//do something
return 0;
}

HTH
Frank


Vivek

unread,
May 18, 2004, 2:03:11 AM5/18/04
to
Hi Frank,

Thanx for your reply but I am already using the same format.
my function prototype is:
#define UWM_SOLVERSA_SOFTWARES (WM_USER +5)

afx_msg LRESULT OnSolversaSoftware();
LRESULT CFirstTestDlg::OnSolversaSoftware()
{
if((m_btnCheckSI.GetState() && 0x0003)==1)
{
OnButtonsoftcheck();
}
else
{
SendMessage(UWM_SOLVERSA_SHARED,0,0);
}
return 0;

}
what else can be the reason?

Vivek


"Frank Kaehler" <AAAfktoz...@gmx.net> wrote in message
news:2gtl6dF...@uni-berlin.de...

Vivek

unread,
May 18, 2004, 2:15:13 AM5/18/04
to
Hi Frank,

Thanx alot
What u said is correct....
I was not using WPARAM wp, LPARAM lp
Now its working fine...
Once again thank you veru much....
Vivek.

"Vivek" <vivek.ku...@solversa.com> wrote in message
news:eTWZP3JP...@TK2MSFTNGP09.phx.gbl...

Joseph M. Newcomer

unread,
May 18, 2004, 1:56:01 AM5/18/04
to
You have made the classic error. You forgot to read the documentation. The documentation
says the only acceptable prototype for a user-defined message handler is
LRESULT name(WPARAM, LPARAM);
if you used anything else, you are wrong, and the manifestation is that your app crashes
in the way you describe.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages