Quick question, is there an easy way to get rid of the little dotted rectangle buttons get when you're clicking them (and after being clicked)? "Easy" being something quick like intercepting a message or setting a certain style. 8-T

Thanks


ex:
Posted on 2003-07-10 22:11:45 by jcsn
I have lost a good amount of hair trying to figure that one out and never managed to do it. I would be very interested in an answer as well.
Posted on 2003-07-11 03:01:49 by donkey
windows provides an api to draw focus rects. they xor every second pixel of the rect-lines by 0x00ffffff (i.e. create the negative). if you intercept the painting message you let the normal button to be drawn and if you have a focus on your button you draw such a focus rect in same size and position on the button in order to create the negative of the negative (one pixel is xored by 0x00ffffff twice -> the result is the same color like before) of the pixels and the focus rect should be disappeared.
Posted on 2003-07-11 03:47:57 by hartyl
That dotted rectangle also serves as a marker for tab selection, so taking it out might confuse and alienate those users whom prefer to navigate with the keyboard when possible. Make sure you have a good reason for removing it other than aesthetic.
Posted on 2003-07-11 04:34:43 by iblis
Well apparently there are enough people out there who find them distracting/annoying since there is an option in win2k to turn that focus rectangle off.
Posted on 2003-07-14 09:20:24 by Will
That's for the user to decide, not the program.
Posted on 2003-07-14 10:07:33 by iblis
let's settle for the middleground:

1. Draw the buttons using GDI or DX or GL or whatever... by doing this, you allow greater flexibility and control.
2. Create a settings window/whatever that will allow the user to choose whether to have the dotted lines or not. Depending on the settings is how you will draw the button states...

of course it will be much harder(more code: loading/drawing images, determining the states of the button...). Sometimes there is no *easy* solution to everything. ;)

Once you get the hang of it, manuallly doing everything would be a breeze. Just remember PtInRect is your favorite API function on this quest.

:grin:
Posted on 2003-07-14 10:12:28 by arkane
I'm just fantasing here so i do not know if its a good solution. But it's faster than Arkane's solution as i think. So when u click the button it gaines focus and this doted rectangle is appearing. So u just have to unfocus (or focus on youre main window) it but make some varible thet remember whitch button if any was clicked, It could be usefull for future use.
Posted on 2003-07-14 13:52:04 by AceEmbler
Whoops, forgot about my post. :) Quotes!


windows provides an api to draw focus rects. they xor every second pixel of the rect-lines by 0x00ffffff (i.e. create the negative). if you intercept the painting message you let the normal button to be drawn and if you have a focus on your button you draw such a focus rect in same size and position on the button in order to create the negative of the negative (one pixel is xored by 0x00ffffff twice -> the result is the same color like before) of the pixels and the focus rect should be disappeared.


I'll give that a try. 8u)


That dotted rectangle also serves as a marker for tab selection, so taking it out might confuse and alienate those users whom prefer to navigate with the keyboard when possible. Make sure you have a good reason for removing it other than aesthetic.


Yeah, I don't wanna get rid of it completely, I just want it to not show up when a button's being clicked. (still show up when being tabbed to, etc)


Well apparently there are enough people out there who find them distracting/annoying since there is an option in win2k to turn that focus rectangle off.


Ooo, where is this beautiful option? I knew their had to be something like this because the computers in our labs don't have it. 8-)


let's settle for the middleground:

1. Draw the buttons using GDI or DX or GL or whatever... by doing this, you allow greater flexibility and control.
2. Create a settings window/whatever that will allow the user to choose whether to have the dotted lines or not. Depending on the settings is how you will draw the button states...

of course it will be much harder(more code: loading/drawing images, determining the states of the button...). Sometimes there is no *easy* solution to everything.

Once you get the hang of it, manuallly doing everything would be a breeze. Just remember PtInRect is your favorite API function on this quest.


Eheh, if it comes to this, I'll keep the stupid dotted lines! :grin:


I'm just fantasing here so i do not know if its a good solution. But it's faster than Arkane's solution as i think. So when u click the button it gaines focus and this doted rectangle is appearing. So u just have to unfocus (or focus on youre main window) it but make some varible thet remember whitch button if any was clicked, It could be usefull for future use.


Yeah, I've done it this way before, except I think this way also eliminated being able to tab to buttons (i think). Also tried getting rid of the focus on mousedown but that was a complete failure (as it should be). :tongue:


Ok, longest post comprised of other peoples posts...ever :alright:
Posted on 2003-07-14 14:44:03 by jcsn
Right click on the desktop, 'properties', 'Effects' tab, check 'Hide keyboard navigation indicators until I use the Alt key'.

As for 'That's for the user to decide, not the program.' All that I can say, is that if I'm writing a program I feel that I can do whatever the hell that I want. ;) It may not be the nicest attitude, but it's mine. ....and apparently all of the authors of shareware programs that I've tried recently share this attitude as well. An option for the user to select this change is a grand idea.
Posted on 2003-07-15 10:16:01 by Will
For myself I would like it from time to time when using bitmapped buttons, it can affect the image "look and feel". Also when the buttons are very small it will obscure the text,. Ofcourse you can always say that it prevents bad programming practices like buttons that are too small ;)
Posted on 2003-07-15 10:42:22 by donkey
If you're writing a program for yourself, yeah. You can paint the buttons flaming pink and make them act like a listbox for all I care.

But when you're writing successful commercial software you have to keep the user in mind. And not all users are going to appreciate a program that dictates to them what a button should do.
Posted on 2003-07-15 10:46:42 by iblis
Flaming pink isn't my style but thanks for the suggestion. I don't write commercial software but was interested in how to do it on a regular dialog. The fact that it is not present in windows unless you use IsDialogMessage would suggest that it is an optional part of the user interface and not completely necessary as you suggest. Professional software that does not use it - I could name several hundred packages - any one that uses windows instead of dialogs would fit the bill. The option is always there to use dialog as window and leave out IsDialogMessage from the message loop, that is what I do right now if I don't want it. It is interesting to know if there is a method of removing this feature however.
Posted on 2003-07-15 11:02:35 by donkey
Donkey that's fine, and the topic is entirely worth discussing.
I'm not saying 'This is how you have to do things.'
I'm not saying that at all.

I'm not trying to dictate to anybody, rather I'm just offering some advice. Some information to take into consideration. I'm simply emphasizing the importance of these little 'features' some seem to find so annoying. They are there for a reason. And I want people to keep that in mind before they get too 'artistic'. Of course this does not apply to those people who are programming just for shits and giggles.

I myself navigate with the keyboard - a LOT. I don't use the mouse if I don't have to. I have nothing against the mouse, but I find that most tasks are faster without them. And I am not alone. Now, if I purchased a piece of software, and found that I could not navigate the dialogs with the keyboard, I would be a little frustrated, and might even consider taking the software back to the store for a refund if possible.

A good, easy to use, extensible, and intuitive GUI has shown to be the life or death of a piece of software.

There are also those users with physical disabilities to take into consideration. Blind people for example, must rely on voice software that reads the contents of the screen to them. These programs are set up to navigate through dialogs and read the titles on controls and menus, etc. Imagine how useful it would be for them if your program were to remove the focus of the button, just to get rid of the annoying dotted line that they can't see anyway.

And what about XP Styles or non XP users that have 3rd party programs installed that alter the standard Windows GUI to their liking? Imagine their dismay when they see a XOR'd rectangle over their custom button where normally the selection mechanism would make the button glow or whatnot.

Just think about all of your users when you write commercial software, that's all I'm saying.
Posted on 2003-07-15 12:02:01 by iblis
Yeah, I use the keyboard alot to navigate as well. But it would be nice to replace it say with a small dot in the corner of the button or change the color slightly on a change of focus. There is nothing to say that when you get rid of it that you're not going to replace it with some more asthetically suited to your application. For myself I would like to make bitmapped buttons "light up" when tab is used, in the same way that a mouse-over would do it, it would make for a more consistent and pleasing user interface.
Posted on 2003-07-15 12:17:53 by donkey
Aye, that would be good. Any kind of feedback is better than none.
Posted on 2003-07-15 12:21:16 by iblis
I'm not sure how windows 2000 handles the removal of the focus rectangle on buttons, but the focus 'shadow' is still there. You can still tab away to your heart's content, and after the first tab, the focus rectangle reappears. For me, the 'shadow' is quite enough to let me know which control has the focus currently. Maybe in time, as I get older, my eyes will start failing me and I'll need the focus rectangle, but for now the 'shadow' is just fine. That solution seems like it would satisfy any user of your software.
Posted on 2003-07-15 14:07:36 by Will
can't you use DrawFocusRect somehow? subclass the button and wait for WM_SETFOCUS maybe?
Posted on 2003-07-15 15:01:16 by Sloat
You can just wait for WM_CTLCOLORBTN, it is sent each time the focus rectangle is drawn but the problem is to erase it easily and draw your own. If you remove the button from the tab order it still shows up sometimes, pain in the a** that thing, like I said I searched quite a while for a way to get rid of it effectively and easily and couldn't find one.
Posted on 2003-07-15 15:32:18 by donkey
Hello everybody,

The dotted line indicates which button has the focus. I find it useful in a Yes/No/Cancel dialog box where you, the programmer, can set the focus on the button which will execute the 'safest' routine. For example set the focus on the 'Cancel' button and if the user accidentally presses <Enter> no harm is done.

If the dialog box has an edit control set focus on it, cuz that's where you want it anyway, and then there's no dotted line around any button.

This may sound like a hokey type of fix-it but I once had a dialog with a static control and a close button. I couldn't remove the dotted line from around the close button by setting the focus on the static control so I changed the creation order of the static control and button in my resource script...voila!

best regards,

czDrillard
Posted on 2003-07-16 09:22:40 by czDrillard