Microsoft
Software
Hardware
Network
Question : Error "Cannot Quit Visual FoxPro" when closing form with embedded OLE MapPoint control
I have a Visual FoxPro 9 form with an embedded OLE MapPoint 2006 control. Sometimes after launching this form in my main app, closing, then closing the main app, I will get a "Cannot Quit Visual FoxPro" error, and the app will need to be forcibly closed with the task manager. The vast majority of the time this does not happen, but I have been unable to determine what specific circumstances lead to it happening. Our application allows for saved form layouts (which determine size, some saved settings, etc). Only one of my saved layouts will cause this error, while none of the others do, even though they're all launching the exact same form with the same initial parameters (the layout's settings only get applied after init).
I have done a lot of research on this error, and found lots of cases of people fixing it by clearing/releasing elements upon closing the app. Every non-local variable used in the app's execution is RELEASE'd, and the OLE map is calling its CloseMap() method on the close of the form. I have also tried doing all of the following on the close of the application itself to no avail (the app being closed with either CANCEL or QUIT with the same results):
CLOSE ALL
CLEAR ALL
CLEAR EVENTS
CLEAR RESOURCES
CLEAR DLLS
CLEAR PROGRAM
RELEASE ALL
RELEASE ALL EXTENDED
TABLEREVERT
ROLLBACK
END TRANSACTION
I have also tried killing the app with:
Declare ExitThread in Win32API
ExitThread()
but this only seems to hide the app, it's still running when I look in task manager.
Here's where I gets weird. Originally, this error would happen every single time I launched the form with the OLE map and closed the app. After much debugging, I discovered that I could prevent it by changing the TabIndex property of a listbox control on the form. Both the OLE map and the listbox had a TabIndex of 2, and apparently removing this "conflict" fixed the problem for me for every case except for when the form is launched via this one particular saved layout. This leads me to think that the error is being caused by a bug in Foxpro itself.
Does anyone have any ideas for a fix or even a workaround to prevent this error from happening?
Answer : Error "Cannot Quit Visual FoxPro" when closing form with embedded OLE MapPoint control
Try to add
ON SHUTDOWN QUIT
into your code.
Random Solutions
Server 2008 R2 DC File Permissions
Calendar Control in Excel 2003 VBA
Installing MAPI CDO on Exchange 2007
CKEditor: How to update textarea using javascript?
Inserting image in Word 2007 table
Private WAN
using window.open want to get rid of url bar in new window within IE7
user rights and administrative rights problems on domain
How to undelete public folder content on MS Exchange Server 2000
Send/receive mails in Exchange 2010