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#
  4. 3 state Button - weird behaviour

3 state Button - weird behaviour

Scheduled Pinned Locked Moved C#
question
3 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.
  • S Offline
    S Offline
    seq
    wrote on last edited by
    #1

    Hello, I wrote some code for using some buttons in my application which depending on the state can be one of the 3 images: - image_button_mouse_over.png (mouse is over my button) - image_button_mouse_norma.png (mouse left my button) - image_button_mouse_clicked.png (button clicked or mouse down) I used the events (mouse_enter/mouse_leave/mouse_up/mouse_down/mouse_clicked) and depding on that and appropiate image is set to the button. IT WORKS FINE untill.. I click a button which display any window/dialog/whatever, when I do this the button stays after the click in the normal state (LIKE IT SHOULD BE), but when I close the window/dialog it remains in the image_button_mouse_over state even when I put into my code button_clicked(object sender,eventargs e) { button1.Image=image_button_mouse_norma_handler; dialog.ShowDialog(); button1.Image=image_button_mouse_norma_handler; } I checked and the mouse_leave event is fired, right after the showdialog() is lunched, but It doesnt change anything... Any Ideas ?

    C I 2 Replies Last reply
    0
    • S seq

      Hello, I wrote some code for using some buttons in my application which depending on the state can be one of the 3 images: - image_button_mouse_over.png (mouse is over my button) - image_button_mouse_norma.png (mouse left my button) - image_button_mouse_clicked.png (button clicked or mouse down) I used the events (mouse_enter/mouse_leave/mouse_up/mouse_down/mouse_clicked) and depding on that and appropiate image is set to the button. IT WORKS FINE untill.. I click a button which display any window/dialog/whatever, when I do this the button stays after the click in the normal state (LIKE IT SHOULD BE), but when I close the window/dialog it remains in the image_button_mouse_over state even when I put into my code button_clicked(object sender,eventargs e) { button1.Image=image_button_mouse_norma_handler; dialog.ShowDialog(); button1.Image=image_button_mouse_norma_handler; } I checked and the mouse_leave event is fired, right after the showdialog() is lunched, but It doesnt change anything... Any Ideas ?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      First of all, you really should encapsulate this behaviour, so you can set the bitmaps on button1 ( please tell me it's not called that ), and it will draw itself properly. Second, perhaps your form needs to redraw itself, what if you call Invalidate() ?

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      • S seq

        Hello, I wrote some code for using some buttons in my application which depending on the state can be one of the 3 images: - image_button_mouse_over.png (mouse is over my button) - image_button_mouse_norma.png (mouse left my button) - image_button_mouse_clicked.png (button clicked or mouse down) I used the events (mouse_enter/mouse_leave/mouse_up/mouse_down/mouse_clicked) and depding on that and appropiate image is set to the button. IT WORKS FINE untill.. I click a button which display any window/dialog/whatever, when I do this the button stays after the click in the normal state (LIKE IT SHOULD BE), but when I close the window/dialog it remains in the image_button_mouse_over state even when I put into my code button_clicked(object sender,eventargs e) { button1.Image=image_button_mouse_norma_handler; dialog.ShowDialog(); button1.Image=image_button_mouse_norma_handler; } I checked and the mouse_leave event is fired, right after the showdialog() is lunched, but It doesnt change anything... Any Ideas ?

        I Offline
        I Offline
        Ilion
        wrote on last edited by
        #3

        I'm guessing here, but could it be that at some point in closing the window/dialog (which was opened by clicking the button) a mouse_enter message is getting set to the button, but since the mouse is not *actually* over the button, it never gets a mouse_leave message? Have you tried working the GotFocus and LostFocus events into your overall logic? -- modified at 16:06 Wednesday 4th October, 2006

        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