>My CleanUp procedure does not seem to run when I try to shutdown the application and I see an error that this application prevents shutdown...
Of course it doesn't - you reset the 'on shutdown' to default at the end ...
> on shutdown
> endif
>endif
>Hi Gregory,
>
>The _screen.ControlBox = .f.
>
>I'm going to add messagebox to shutdown procedure is it doesn't seem to happen at all.
>
>Do you know what is wrong in this code:
>
>
>if llStartApp
> on shutdown do CleanUp
> lcLogin = "YES"
> declare integer GetLastError in kernel32
> declare integer CloseHandle in kernel32 integer hObject
> declare integer CreateMutex in kernel32 integer lpMutexAttributes, integer lInitialOwner, string lpName
>
> hMutex = CreateMutex(0, .t., "AppName")
> if 0 != GetLastError()
> messagebox ("AppName is already running.")
> else
>
> do while m.lcLogin $ 'YES/SUPERUSER' and vartype(m.oAppObj) = 'O'
> if vartype(m.oAppObj) = 'O'
> do form Booking_Schedule with lcLogin to dummy
> else
> exit
> endif
>
> if _screen.releasetype > 1 and vartype(m.oAppObj) = 'O'
> oAppObj.write_log('Closing the application',program(),'1')
> exit
> endif
> if vartype(m.oAppObj) = 'O' AND _screen.ReleaseType <=0
> do form login with .f., "", .t. to llLogin
> else
> exit
> endif
>
> if vartype(m.llLogin) = 'L'
> lcLogin = iif(llLogin, "YES", "XXXX")
> else
> exit
> endif
>
> enddo
> if vartype(oAppObj) = 'O'
> oAppObj.SetScreenGeometry(oAppObj.cINIfile)
> endif
> if vartype(hMutex) <> 'U'
> CloseHandle(hMutex)
> endif
>
> on shutdown
> endif
>endif
>
>do CleanUp
>
>
>My CleanUp procedure does not seem to run when I try to shutdown the application and I see an error that this application prevents shutdown...
>
>
>>>>>>What is ReleaseType - when I tested in the on shutdown it was 0 and not 1
>>>>>
>>>>>From the form can you determine what caused the close?
>>>>
>>>>
>>>>Do you try to close the foms in the ShutDown() ?
>>>
>>>The shutdown procedure has this code at the end
>>>
>>>
>>>
>>>if m.llOkToExit
>>> on shutdown
>>> try
>>> clear windows
>>> clear events
>>> catch
>>>* retry
>>> endtry
>>>endif
>>>
>>>
>>>The application can be closed from the toolbar or menu (menu calls the toolbar button's click) or from the shutdown procedure.
>>>
>>>I'm thinking I set a property of the application object and then based on this property will ask or not ask the question about saving changes in that particular form. Does it sound like a good idea / solution or I should leave that application (and form) to its fate?
>>
>>
>>(1) dunno - I do not let the users leave the app if there's any form open
>>
>>(2) I do have a function that tries to close all the forms - calls a form's method (MakeSafeToClose() + QueryOnload() afterwards + Release()
>>
>>MakeSafeToClose() is very simple - for each workarea , if any changes - revert them
Gregory