Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Exit a program using a button

Exit a program using a button

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebugging
5 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dreamerzz
    wrote on last edited by
    #1

    i would like to know the code for the exit button that i created on the window to close the application. I have tried OnExit() and it works fine when it runs on the pc at home.. but when i run this program and try to press the exit button to terminate the program. it will prompt for some kind of error message tat needs mi to press either "ok" to terminate the program or press "cancel" to debug the program To anyone that could help.. thanks :-O

    P D 2 Replies Last reply
    0
    • D dreamerzz

      i would like to know the code for the exit button that i created on the window to close the application. I have tried OnExit() and it works fine when it runs on the pc at home.. but when i run this program and try to press the exit button to terminate the program. it will prompt for some kind of error message tat needs mi to press either "ok" to terminate the program or press "cancel" to debug the program To anyone that could help.. thanks :-O

      P Offline
      P Offline
      Prakash Nadar
      wrote on last edited by
      #2

      use PostQuitMessage(exitcode)


      MSN Messenger. prakashnadar@msn.com

      1 Reply Last reply
      0
      • D dreamerzz

        i would like to know the code for the exit button that i created on the window to close the application. I have tried OnExit() and it works fine when it runs on the pc at home.. but when i run this program and try to press the exit button to terminate the program. it will prompt for some kind of error message tat needs mi to press either "ok" to terminate the program or press "cancel" to debug the program To anyone that could help.. thanks :-O

        D Offline
        D Offline
        deniz79s
        wrote on last edited by
        #3

        I don't know exactly you use which .NET application. I show you close a program completly on Visual C++ .NET: You add below code in your button::onClick(..) methot (exit button); Application::Exit();

        D 1 Reply Last reply
        0
        • D deniz79s

          I don't know exactly you use which .NET application. I show you close a program completly on Visual C++ .NET: You add below code in your button::onClick(..) methot (exit button); Application::Exit();

          D Offline
          D Offline
          dreamerzz
          wrote on last edited by
          #4

          Hi, I am using Visual C++ for my application but i am not very sure of the code u say. i have a function name: void CProjectGrid::OnExit() { OnExit(); } i tried on the above and it works fine with the pc at home.. but when i run this program in school, it prompt mi for some error. so for the coding that you showed me. Where should i place it in the function above? Thanks for your help :)

          D 1 Reply Last reply
          0
          • D dreamerzz

            Hi, I am using Visual C++ for my application but i am not very sure of the code u say. i have a function name: void CProjectGrid::OnExit() { OnExit(); } i tried on the above and it works fine with the pc at home.. but when i run this program in school, it prompt mi for some error. so for the coding that you showed me. Where should i place it in the function above? Thanks for your help :)

            D Offline
            D Offline
            dreamerzz
            wrote on last edited by
            #5

            Hi, Thanks for the help given.. I have solved my problems. thanks a million dreamerzz

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups