Page 1 of 1

Get high contrast mode for colors

Posted: Sun Sep 20, 2020 12:43 am
by oryaaaaa
I tried to check the contrast settings in Windows 10,
as using the API to check the contrast settings feels bad.

My software users are aging and some are in their 70s and older,
so I'm looking for setup high contrast screens.

Code: Select all

Procedure.i GetHighContrastMode()
  ; Windows 10
  Protected GetColor.i, Result.i
  GetColor = GetSysColor_(#COLOR_HOTLIGHT)
  Select GetColor
      ; Case 13395456
      ; result = 0
    Case 65535, 16744576, 10420224
      Result + 1
  EndSelect
  GetColor = GetSysColor_(#COLOR_MENUHILIGHT)
  Select GetColor
      ;Case 14120960
      ; result = 0
    Case 0, 32768, 8388736, 16711680
      Result + 1
  EndSelect
  ProcedureReturn Result
EndProcedure

Debug GetHighContrastMode()
CallDebugger

Re: Get high contrast mode for colors

Posted: Sun Sep 20, 2020 12:54 am
by BarryG

Code: Select all

Case 65535, 16744576, 10420224
You can't check hard-coded values like that, because the results of GetSysColor_() can be different for different people. This is because high contrast mode can be personalised by the user (#COLOR_HOTLIGHT and #COLOR_MENUHILIGHT on your PC will be different to mine).

Re: Get high contrast mode for colors

Posted: Sun Sep 20, 2020 6:11 am
by oryaaaaa
I see.

Code: Select all

Procedure.b GetHighContrast()
  Structure HIGHCONTRAST
    cbsize.l
    dwFlags.l
    *lpszDefaultScheme
  EndStructure
  
  HC.HIGHCONTRAST
  SystemParametersInfo_(#SPI_GETHIGHCONTRAST, SizeOf(HIGHCONTRAST), @HC, 0)
  If HC\dwFlags & $2
    ProcedureReturn #True
  EndIf
EndProcedure

Debug GetHighContrast() ; can not get
Just another tips, do you know?

Re: Get high contrast mode for colors

Posted: Sun Sep 20, 2020 7:36 am
by RASHAD
Windows 10 HIGHCONTRAST ON/OFF

Code: Select all

#HCF_HIGHCONTRASTOFF = $00000000
#HCF_HIGHCONTRASTON = $00000001
#SPIF_SENDCHANGE = $2

Structure HIGHCONTRAST
  cbSize.l
  dwFlags.i
  *lpszDefaultScheme 
EndStructure

hc.HIGHCONTRAST
hc\cbSize = SizeOf(hc)
hc\dwFlags = #HCF_HIGHCONTRASTON ;Use #HCF_HIGHCONTRASTOFF for off
SystemParametersInfo_(#SPI_SETHIGHCONTRAST, 0, @hc, #SPIF_SENDCHANGE)

Re: Get high contrast mode for colors

Posted: Sun Sep 20, 2020 10:57 am
by oryaaaaa
RASHAD wrote:Windows 10 HIGHCONTRAST ON/OFF
This corner is Windows 9x OS only. :(
SPI_SETHIGHCONTRAST, SPI_GETHIGHCONTRAST

I will write at documents 'Let's use manual switching.'