PDA

View Full Version : Overide Global Function?


thetford
02-18-2007, 11:57 PM
ok, this is a great function to prevent people from closing the app, but what do I do when I need to close the app without the users input i.e. not showing the dialog confirmation?

--This code asks user to "BE sure that they want to exit"
function QueryAllowProjectClose() --this function will be called when the program is exiting
if close_value
then Application.Exit(0);
else
confirmation = Dialog.Message("NOTICE", "WARNING! \r\ If you close this license manager you will not be able to run Credit Mechanic software.\r\Are you sure you want to Exit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
if confirmation == 6 then
-- The yes button was pressed, allow program to close (return true)
return true;

else
-- The yes button was NOT pressed, do NOT allow the program to close (Return false)
return false;
end
end
end

I just keep running into problems this weekend!
thanks in advance.

longedge
02-19-2007, 04:02 AM
You don't need to do anything at all really, at an appropriate point in your code use -

Application.Exit();

That doesn't call for any user interevention.

thetford
02-19-2007, 10:24 AM
Well, the code is in the "Global Function" area. So whenever the application closes, it displays the dialog.

Yes, i have tried the Application.Exit();

take a look a the sample project

longedge
02-19-2007, 12:07 PM
One approach would be to control whether the global function is 'activated' by using a variable as in my update to your example.

thetford
02-19-2007, 12:32 PM
Worked like a charm! thanks!:yes

I'll get the hang of this stuff one day!:cool