0

I noticed that the focus rectangle has changed in one of our legacy app when it works in Windows 10. It turned out that there are other old-style Microsoft apps in which we see the same effect - for example, in HTML Help Workshop. The focus rectangle must be a dotted rectangle consisting of alternating black and white dots, but we see a 2-pixel rectangle blended with the selection that looks like a red-orange rectangle:

enter image description here

The problem appears only on 2 computers with Windows 10, version 1909. One of them is the Pro edition, the other is the Home edition.

The focus rectangle is drawn in our app with the WinAPI DrawFocusRect function. The documentation for the DrawFocusRect function states the following:

Windows XP: The focus rectangle can now be thicker than 1 pixel, so it is more visible for high-resolution, high-density displays and accessibility needs.

But this does not help to understand why the problem occurs only on those 2 computers. They are equipped with normal 96dpi displays, and as I know, no accessibility options are turned on in them.

What it could be and how to fix the drawing of focus rectangle to see the traditional 1-pixel black/white dotted rectangle?


If it helps, here is an example of code used to draw the focus rectangle in our VB6 app:

Dim hBrBlack As Long
hBrBlack = CreateSolidBrush(vbBlack)
FrameRect hMemDC, rcFocusRect, hBrBlack
DeleteObject hBrBlack

SetBkColor hMemDC, lColor1
SetTextColor hMemDC, lColor2
DrawFocusRect hMemDC, rcFocusRect
TecMan
  • 2,743
  • 2
  • 30
  • 64
  • What does SystemParametersInfo return for SPI_GETFOCUSBORDERHEIGHT and SPI_GETFOCUSBORDERWIDTH? If it's 2, it means Windows has been configured like that. And you should be able to change it with SPI_SETFOCUSBORDERHEIGHT and SPI_SETFOCUSBORDERWIDTH – Simon Mourier Oct 06 '20 at 15:40
  • @SimonMourier Apps should not modify global settings! – Anders Oct 07 '20 at 00:00
  • Where/when are you drawing? – Anders Oct 07 '20 at 00:17
  • `The problem appears only on 2 computers with Windows 10, version 1909.` Have you tested other versions? 1903 or 2004? BTW, the modification made by `SystemParametersInfo` will be applied to all programs on the current desktop. My suggestion is that you do not use `DrawFocusRect` but draw this rectangle manually. It only alternates black and white pixels and can be used for effective drawing `BitBlt`. – Strive Sun Oct 07 '20 at 03:43
  • @SimonMourier and others: I can read SPI_GETFOCUSBORDERWIDTH/HEIGHT, but I can't understand why and when they were changed. Any ideas how users or system patches can change them? And Anders is right, we must not modify these settings as they are global. – TecMan Oct 07 '20 at 15:48
  • @StriveSun-MSFT, no, I am analyzing the situation only with the version 1909. We and our customers are using mainly this build, but we can't understand why the problem appears only on 2 computers. And yes, we already changed the drawing algorithm and simply use `SetPixel` to draw the focus rect. But we are trying to figure out why the problem occurs. It leads to improper drawing of the focus rect not only in our app but in other apps too. – TecMan Oct 07 '20 at 15:51
  • 2
    This can be a carry over from previous Windows upgrade. But you can have access to that feature through "Control Panel\All Control Panel Items\Ease of Access Center\Make the computer easier to see" and check the "Make the focus rectangle thicker". I don't see why you couldn't change that if you own the machine. There are Set methods for a reason. – Simon Mourier Oct 07 '20 at 16:11

1 Answers1

0

Thank you all who commented my question. The situation became clear, but not in all parts of the problem. I am resuming all what we know by now in this kind of an answer.

Yes, indeed, in Windows 10 we can open Control Panel > Ease of Access > Ease of Access Center > Make the computer easier to see and find the Make the focus rectangle thicker option:

'Make the focus rectangle thicker' option in Windows 10 Control Panel

The first thing I do not understand is that why this option became checked. Simon Mourier thinks it is a carryover from a previous Windows installation, but I doubt this is true. I definitely know that at least on my dev pc nobody checked this as only me could do that. It seems that Windows decide at some point to check this option itself depending on some system parameters.

The second incomprehensible point is why the focus rectangle became dark-orange-red. But maybe, this is by design. Perhaps, somebody in Microsoft decided that this color is the best choice for the focus rectangle.

Taking into account all this, I think, the best choice for me and other developers who need the focus rectangle in our apps is to draw the focus rectangle by ourselves using the thickness defined by the SPI_GETFOCUSBORDERHEIGHT and SPI_GETFOCUSBORDERWIDTH system parameter values.

TecMan
  • 2,743
  • 2
  • 30
  • 64
  • 2
    The focus effect is just a color inversion. It's not that anybody "chose" orange. It's that the inverse color to RGB(0, 120, 215) (blue) is RGB(255, 135, 40) (orange). – Raymond Chen Nov 24 '20 at 05:20