Disable Exit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • abnrange
    No longer a forum member
    • Feb 2006
    • 346

    Disable Exit

    Hello,

    Quick question - I have attached an image of an app i'm working on. I don't want my end user to be able t exit my application with out a password. I added the following code, but when the user right clicks on the icon running in the system try and click exit, it prompts for password it you click okay without entering a password it exits. Any thoughts? Thanks

    Code:
    --assume the user enters a bad password
    correct_password = false;
    
    -- the 'correct' password
    real_passwords = {"pwd1", "pwd2", "pwd3"};
    
    -- prompt the user to enter a password
    user_password = Dialog.PasswordInput("Password", "Please enter administrative password: ", MB_ICONQUESTION);
    
    -- compare the user's password to the 'correct' password.
    for j in real_passwords do
        if real_passwords[j] == user_password then
            correct_password = true;
            Application.Exit(); 
        end
    end
    
    --if the password was bad, exit
    if not correct_password then
      Application.ExitScript(); 
    end
    Attached Files
  • abnrange
    No longer a forum member
    • Feb 2006
    • 346

    #3
    Thanks for the quick replay - I tried modifying your code for password. It works fine when my app is maximized with an exit button. When you minimize it and right click the icon in system try and click exit - if you click okay no password it exits. is there a way to diable right click of system try menu or atleast the exit option? Thanks again

    Comment

    • Worm
      Indigo Rose Customer
      • Jul 2002
      • 3971

      #4
      hmmm.... works for me... make sure the function is in your Global functions

      Comment

      • abnrange
        No longer a forum member
        • Feb 2006
        • 346

        #5
        I do have it in Global functions... It must be something in my code. I tried changed the code a few different ways for password. This works with a button in the app when maximized. If i right click the icon it prompts for the passowrd but if i click okay (no pwd) it exits. The icon stays unless you mouse over it. Not sure if thats a bug or not.

        Code:
        function QueryAllowProjectClose()
        --assume the user enters a bad password
        correct_password = false;
        
        -- the 'correct' password
        real_passwords = {"pwd1", "pwd21", "pwd3"};
        
        -- prompt the user to enter a password
        user_password = Dialog.PasswordInput("Password", "Please enter administrative password: ", MB_ICONQUESTION);
        
        -- compare the user's password to the 'correct' password.
        for j in real_passwords do
            if real_passwords[j] == user_password then
                correct_password = true;
             
           result= Dialog.Message("Application Exit", "Are you sure that you want to quit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
           ---- --if they choose yes 
         if result == IDYES then
               ---- --allow the app to close
            return true;
         else
              -----  --cancel close
           --return false;
         --end
        end
            end
        end
        
        --if the password was bad, exit
        if not correct_password then
          Application.ExitScript(); 
        end
        end

        Comment

        • Worm
          Indigo Rose Customer
          • Jul 2002
          • 3971

          #6
          Try this:
          Code:
          function QueryAllowProjectClose()
          	--assume the user enters a bad password
          	Allow_Exit = false;
          	
          	-- the 'correct' password
          	real_passwords = {"pwd1", "pwd21", "pwd3"};
          	
          	-- prompt the user to enter a password
          	user_password = Dialog.PasswordInput("Password", "Please enter administrative password: ", MB_ICONQUESTION);
          	
          	-- compare the user's password to the 'correct' password.
          	for j in real_passwords do
          		if real_passwords[j] == user_password then
          			result= Dialog.Message("Application Exit", "Are you sure that you want to quit?", MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
          			---- --if they choose yes 
          			if result == IDYES then
          				---- --allow the app to close
          				Allow_Exit=true;
          				break;
          			end	
          		end
          	end
          	return Allow_Exit;
          end

          Comment

          • abnrange
            No longer a forum member
            • Feb 2006
            • 346

            #7
            That worked great Worm.... Thanks for yout time and help!!!

            Comment

            Working...
            X