PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Ivan Iraola on November 03, 2009, 11:33:21 PM

Title: Recurring error on exit
Post by: Ivan Iraola on November 03, 2009, 11:33:21 PM
The program compiles without a glitch, works fine but everytime I close it I get the error on the attached picture.

The amount of code is minimun since the program is still in development.
Title: Re: Recurring error on exit
Post by: Paul Squires on November 04, 2009, 06:47:32 AM
Hi Ivan,

Are you able to send me the project? If you can then it may be easier for me to see why the GPF occurs and find a solution for you. If you can, then please email it to support@planetsquires.com and I will take a look at it today.
Title: Re: Recurring error on exit
Post by: Ivan Iraola on November 04, 2009, 09:32:49 AM
It's on its way.

Thank you.
Title: Re: Recurring error on exit
Post by: Paul Squires on November 04, 2009, 02:05:03 PM
Thanks Ivan, I got it. Will work on it tonight. I'll report back to you via email.
Title: Re: Recurring error on exit
Post by: Paul Squires on November 06, 2009, 08:58:14 AM
For those interested, myself and Ivan have solved this problem. Ivan was uding FF_FormClose statements in the WM_DESTROY and WM_CLOSE message handlers for the Form. The form is already closing at those points so asking it to close again must have triggered some invalid pointers. The GPF would show in WinXP but would not be reported in Win7.
Title: Re: Recurring error on exit
Post by: Ivan Iraola on November 06, 2009, 10:34:39 AM
One more thing, if you have a multi-form app (like in my case) you should make sure the child form (I guess that would be the term) do not have a CLOSE option on the SysMenu but a button to Exit the app, my problem was that since due to designing and functionality, I had to be able to close the application from either the main page or the child page, so I added the FF_FormClose to the WM_DESTROY and WM_CLOSE message handlers.

I appreciate Paul's help in this matter.

FF3 rules by the way.
Title: Re: Recurring error on exit
Post by: Paul Squires on November 06, 2009, 11:57:12 AM
Hi Ivan,

I think that in your case where you needed to close the main form (and therefore the entire application) from a different form (not a child form but rather an "owned" form), the best approach would be as follows:

Close the popup/owned/child form as normal but in the WM_DESTROY handler do a PostMessage to the main form asking it to close.

PostMessage HWND_FRMMAIN, %WM_CLOSE, 0, 0

The PostMessage ensures that the current form completely closes prior to the message hitting the message queue for the main form to close. A SendMessage would not work in this case.
Title: Re: Recurring error on exit
Post by: Mark Strickland on November 06, 2009, 12:43:00 PM
If I want to close a form from the CREATE_FORM event () will this PostMessage technique be the best solution?  In the past I have sometimes created a timer and set a flag.
Title: Re: Recurring error on exit
Post by: Paul Squires on November 06, 2009, 01:15:55 PM
The best solution in FF3 is this:


Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long

   Function = -1
   
End Function



Pretty simple now, right!  :D