views:

98

answers:

2

How would one prevent the little dotted square that appears on a button when it has the keyboard focus in a dialog. (w/ apologies for the technical jargon). At one point I hacked together a solution by subclassing a button WindowProc and subverting some windows messages, but wanted to know the correct way.

There's actually a problem with another control in the dialog also involving the keyboard. This other control is actually also a button, but being used as a group box or panel, not as a functioning button. But when I hit the tab key in the dialog, this group box "button" comes to the foreground obscuring the static controls on top of it, so I wanted to prevent that.

For both of the above, I tried turning off WS_TABSTOP - didn't help.)

A: 

The correct way is to write your own button control instead of using the default Windows one.

Alternatively, you can prevent if from ever getting keyboard focus.

John Knoeller
How do I prevent them from getting keyboard focus - is that not what WS_TABSTOP is for (I guess all of us have gaps in knowledge no matter what the general proficiency level.)
Mark
The most reliable way is to listen for the BN_SETFOCUS notification from the button, and then set the focus somewhere else.
John Knoeller
THanks - I'll report in a bit if I get this working.
Mark
+1  A: 

Both of my problems mentioned above were solved by subclassing the WndProcs and returning 0 in response to message 0x128 and discarding it. Even Spy++ could not identify this message 0x128, and I don't have it in any header. But its sent to every control in the dialog the first time tab is hit in the dialog.

(I did try BN_SETFOCUS as described above and also WM_SETFOCUS but it didn't help.)

So if anyone knows where to find what windows message 0x128 is...

Mark
WM_UPDATEUISTATE is the message:"When a window that draws keyboard cues receives a WM_UPDATEUISTATE message, it typically invalidates itself so that the cues can be redrawn/erased, depending on the new state. "-http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx
Mark