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. Exception Handling

Exception Handling

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 4 Posters 0 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.
  • K Offline
    K Offline
    Kash
    wrote on last edited by
    #1

    Hi, I am trying to catch a user exception. The user presses two buttons. But the second button should only be pressed if the first one has else i should warn the user of an incorrect action. any ideas> kash

    A J D 3 Replies Last reply
    0
    • K Kash

      Hi, I am trying to catch a user exception. The user presses two buttons. But the second button should only be pressed if the first one has else i should warn the user of an incorrect action. any ideas> kash

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Hmmmm, I wouldn't consider that an "exception" per se... I see an "exception" as an error that occurs programatically, like a FileNotFound or the like. This is more of a UI issue. Anyway, I would simply set a bool value somewhere in your code, inside the Form class if you are using Windows Forms for example. Upon program initialization, set the bool to false. Everytime the user presses the first button, set the bool to true. When the user presses the second button, check whether the bool is true. If it isnt, show the user a MessageBox or echo the error somewhere where the user is gonna see it. Hope this helps.

      K 1 Reply Last reply
      0
      • A Anonymous

        Hmmmm, I wouldn't consider that an "exception" per se... I see an "exception" as an error that occurs programatically, like a FileNotFound or the like. This is more of a UI issue. Anyway, I would simply set a bool value somewhere in your code, inside the Form class if you are using Windows Forms for example. Upon program initialization, set the bool to false. Everytime the user presses the first button, set the bool to true. When the user presses the second button, check whether the bool is true. If it isnt, show the user a MessageBox or echo the error somewhere where the user is gonna see it. Hope this helps.

        K Offline
        K Offline
        Kash
        wrote on last edited by
        #3

        Good idea, cheers

        1 Reply Last reply
        0
        • K Kash

          Hi, I am trying to catch a user exception. The user presses two buttons. But the second button should only be pressed if the first one has else i should warn the user of an incorrect action. any ideas> kash

          J Offline
          J Offline
          John M Drescher
          wrote on last edited by
          #4

          Kash wrote: But the second button should only be pressed if the first one has Then disable the second button until after the user pressed the first. John

          1 Reply Last reply
          0
          • K Kash

            Hi, I am trying to catch a user exception. The user presses two buttons. But the second button should only be pressed if the first one has else i should warn the user of an incorrect action. any ideas> kash

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            John D. has provided you with the correct solution. If a control is not supposed to be interacted with until a certain condition exists, then disable the control, period. Don't clutter your code with variables that just makes maintenance harder. It sounds great now, but you must always consider the code in the future.

            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