Board index » cppbuilder » Access Violation with Message Box Key Press

Access Violation with Message Box Key Press


2004-09-11 04:56:10 AM
cppbuilder94
I am getting an access violation with the standard message box, but
only if I press the "Y" key to respond to the box. If I click "Yes"
with the mouse, there is never an accesss violation. Furthermore, the
acces violation only occurs around 25% of the time the box is called.
Here is some of my code:
monitorRpt->Preview();
Application->NormalizeTopMosts();
ans = Application->MessageBox("Display next account?", "HIT message",
MB_YESNO);
Application->RestoreTopMosts();
if(ans == IDNO)
doNext = false;
The "monitorRpt->Preview()" line is calling a preview of a
QuickReport.
If I look at the CPU window at near the address of the violation, here
is what I see:
Wwdbigrd::__16442
mov edx,[Wwdbigrd::TwwCustomDbGrid::]
call rt160.System::__linkproc__ __ fastcall IsClass(System::TObject *,
System::TMetaClass *)
test al, al
jnz 0x46AEA7
mov ebx,[ebx+0x30]
test ebx,ebx
The "mov ebx,[ebx+0x30]" line causes the violation.
I would appreciate any suggestions on how to solve this problem.
 
 

Re:Access Violation with Message Box Key Press

"Robert Emmons" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
I am getting an access violation with the standard message box, but
only if I press the "Y" key to respond to the box. If I click "Yes"
with the mouse, there is never an accesss violation. Furthermore, the
acces violation only occurs around 25% of the time the box is called.

Here is some of my code:

monitorRpt->Preview();
Application->NormalizeTopMosts();
ans = Application->MessageBox("Display next account?", "HIT message",
MB_YESNO);
Application->RestoreTopMosts();
if(ans == IDNO)
doNext = false;
I don't know, but don't you want to call
NormalizeTopMosts before Preview?
Todd
 

Re:Access Violation with Message Box Key Press

On Fri, 10 Sep 2004 21:52:01 -0500, "Todd Brylski"
< XXXX@XXXXX.COM >wrote:
Quote
"Robert Emmons" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
>I am getting an access violation with the standard message box, but
>only if I press the "Y" key to respond to the box. If I click "Yes"
>with the mouse, there is never an accesss violation. Furthermore, the
>acces violation only occurs around 25% of the time the box is called.
>
>Here is some of my code:
>
>monitorRpt->Preview();
>Application->NormalizeTopMosts();
>ans = Application->MessageBox("Display next account?", "HIT message",
>MB_YESNO);
>Application->RestoreTopMosts();
>if(ans == IDNO)
>doNext = false;

I don't know, but don't you want to call
NormalizeTopMosts before Preview?
Thanks for the suggestion. I actually removed the
Application->NormalizeTopMosts(), and I am waiting to see if I still
get occasional access violations. If I do, I'll try some other
approaches.
 

{smallsort}

Re:Access Violation with Message Box Key Press

"Robert Emmons" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
On Fri, 10 Sep 2004 21:52:01 -0500, "Todd Brylski"
< XXXX@XXXXX.COM >wrote:
>"Robert Emmons" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
>>I am getting an access violation with the standard message box, but
>>only if I press the "Y" key to respond to the box. If I click "Yes"
>>with the mouse, there is never an accesss violation. Furthermore, the
>>acces violation only occurs around 25% of the time the box is called.
>I don't know, but don't you want to call
>NormalizeTopMosts before Preview?

Thanks for the suggestion. I actually removed the
Application->NormalizeTopMosts(), and I am waiting to see if I still
get occasional access violations. If I do, I'll try some other
approaches.
I would guess that that is not the problem.
NormalizeTopMosts would be the correct thing to do
before you call Preview, so your top mosts don't
obscure the preview form.
Maybe you know this but just in case you don't,
Preview does not return until the preview form is closed.
The application is still active though, so it is possible
that your code is being reentered and causing a problem.
Todd
 

Re:Access Violation with Message Box Key Press

Robert Emmons < XXXX@XXXXX.COM >wrote in message news:< XXXX@XXXXX.COM >...
Quote
Application->NormalizeTopMosts();
ans = Application->MessageBox("Display next account?", "HIT message",
MB_YESNO);
Application->RestoreTopMosts();
You don't need to call NormalizeTopMosts() or RestoreTopMosts()
yourself. TApplication::MessageBox() already does all of that
internaly.
Gambit