Make a button lose focus
-
Is it possible to make a button lose it's focus once a mouse has passed it? (i mean, if it's clicked and held down and then the mouse moves out of the button). for example, the buttons in Minesweeper are like that. so, is there any way to do so?
-
Is it possible to make a button lose it's focus once a mouse has passed it? (i mean, if it's clicked and held down and then the mouse moves out of the button). for example, the buttons in Minesweeper are like that. so, is there any way to do so?
Set the focus to something else.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website
-
Set the focus to something else.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website
but how would i know which button to set the focus to? (did you even look at minesweeper to see what i meant?)
-
Is it possible to make a button lose it's focus once a mouse has passed it? (i mean, if it's clicked and held down and then the mouse moves out of the button). for example, the buttons in Minesweeper are like that. so, is there any way to do so?
In Minewseeper they might look and act like buttons, but there's clearly some additional functionality built in, not to mention the actual Minesweeper "grid" itself. To emulate that, I think you're going to have to spend a bit of time developing your own custom control - although this will clearly take a bit more time, it will afford you much finer control (pun intended ;) )
"It was the day before today.... I remember it like it was yesterday." -Moleman
-
In Minewseeper they might look and act like buttons, but there's clearly some additional functionality built in, not to mention the actual Minesweeper "grid" itself. To emulate that, I think you're going to have to spend a bit of time developing your own custom control - although this will clearly take a bit more time, it will afford you much finer control (pun intended ;) )
"It was the day before today.... I remember it like it was yesterday." -Moleman
Well...i did make a custom control, a panel that has an array of rectangles in it into which i render images, but it was EXTREMELY flickery for some reason (even though i used a backbuffer) :/
-
but how would i know which button to set the focus to? (did you even look at minesweeper to see what i meant?)
sharpiesharpie wrote:
but how would i know which button to set the focus to?
Don't set focus to another button. Set it to a panel, or a label, or anything else. Panels and labels are good because they don't show as focused.
sharpiesharpie wrote:
(did you even look at minesweeper to see what i meant?)
Wow! Way to get pissy.
-
Well...i did make a custom control, a panel that has an array of rectangles in it into which i render images, but it was EXTREMELY flickery for some reason (even though i used a backbuffer) :/
In a situation with over one hundred controls, the obvious solution to flickering (and lack of performance about which you will complain later on) is the lightweight approach: forget Buttons, use a double-buffered Panel, draw everything yourself, and handle the necessary mouse events yourself. I guess that's how Microsoft did Minesweeper; they use 57 GDI objects, both in Beginners and in Expert mode, according to TaskInfo. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
In a situation with over one hundred controls, the obvious solution to flickering (and lack of performance about which you will complain later on) is the lightweight approach: forget Buttons, use a double-buffered Panel, draw everything yourself, and handle the necessary mouse events yourself. I guess that's how Microsoft did Minesweeper; they use 57 GDI objects, both in Beginners and in Expert mode, according to TaskInfo. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
i did draw everything myself, i drew images on a panel and overrided the mouse movements and added a basic collision detection...but it did flicker :/
-
i did draw everything myself, i drew images on a panel and overrided the mouse movements and added a basic collision detection...but it did flicker :/
Hi, when a Panel does not contain any other Control, has double-buffering set up correctly, and has all its drawing in its Paint handler, the only way I can think of to get flickering is by having a bug in either your animation logic or your paint logic (unless you are showing/hiding other stuff on top of it of course). I have several apps that work this way, including a complex text editor; all work just fine, not a single glitch to be seen. As most often, my advice is to include code for logging/tracing so you can check things happen when they should, and more importantly in this case, dont happen when they should not. :)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }