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. .NET (Core and Framework)
  4. Difference between Form.Deactivate and Form.Leave

Difference between Form.Deactivate and Form.Leave

Scheduled Pinned Locked Moved .NET (Core and Framework)
question
7 Posts 3 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.
  • D Offline
    D Offline
    Dewald
    wrote on last edited by
    #1

    I'm not sure I understand the difference between these two events (Form.Deactivate and Form.Leave). Could someone enlighten me please?

    L 1 Reply Last reply
    0
    • D Dewald

      I'm not sure I understand the difference between these two events (Form.Deactivate and Form.Leave). Could someone enlighten me please?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Form.Deactivate[^]

      Occurs when the form loses focus and is no longer the active form.

      (When the title-bar of the form changes from blue to gray)

      Form.Leave[^]

      Occurs when the input focus leaves the control.

      (When the cursor focusses another control/window)

      Bastard Programmer from Hell :suss:

      D 1 Reply Last reply
      0
      • L Lost User

        Form.Deactivate[^]

        Occurs when the form loses focus and is no longer the active form.

        (When the title-bar of the form changes from blue to gray)

        Form.Leave[^]

        Occurs when the input focus leaves the control.

        (When the cursor focusses another control/window)

        Bastard Programmer from Hell :suss:

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

        Alright thanks, but isn't that pretty much the same thing? I'm talking specifically about a form, not just any control. So "when the cursor focusses another form", isn't that precisely when the form's title-bar changes from blue to grey?

        L D 2 Replies Last reply
        0
        • D Dewald

          Alright thanks, but isn't that pretty much the same thing? I'm talking specifically about a form, not just any control. So "when the cursor focusses another form", isn't that precisely when the form's title-bar changes from blue to grey?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yup. The active form is usually the one with input-focus (fails sometime when apps modify the z-order). Hence, if the input-focus moves to a different form, the new form will should be activated. Even if the validation would fail and the focus retained - the active form would be the one with focus.

          Bastard Programmer from Hell :suss:

          D 1 Reply Last reply
          0
          • L Lost User

            Yup. The active form is usually the one with input-focus (fails sometime when apps modify the z-order). Hence, if the input-focus moves to a different form, the new form will should be activated. Even if the validation would fail and the focus retained - the active form would be the one with focus.

            Bastard Programmer from Hell :suss:

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

            OK, thanks. So, am I correct that, as regards Forms, there is no difference between Form.Deactivate and Form.Leave?

            L 1 Reply Last reply
            0
            • D Dewald

              OK, thanks. So, am I correct that, as regards Forms, there is no difference between Form.Deactivate and Form.Leave?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Well, there is, otherwise one of both would be redundant. Imagine you open a form, has focus. Now I click once on a tray-icon. Just tried it, and the form raises the Deactivate event, not the Leave event; the form still has the input-focus (for your app, and will continue there when it's activated again).

              Bastard Programmer from Hell :suss:

              1 Reply Last reply
              0
              • D Dewald

                Alright thanks, but isn't that pretty much the same thing? I'm talking specifically about a form, not just any control. So "when the cursor focusses another form", isn't that precisely when the form's title-bar changes from blue to grey?

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                No, it's not. It's entirely possible to have a form deactived, but the focus never really leaves the confines of the form. I know, it's rare, but it happens... It's also possible to have the focus leave the form, but never deactivate the form by clicking on someone outside of it. What you do with those events is up to you.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                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