PureBasic Forum
https://www.purebasic.fr/english/

Get high contrast mode for colors
https://www.purebasic.fr/english/viewtopic.php?f=5&t=75970
Page 1 of 1

Author:  oryaaaaa [ Sun Sep 20, 2020 12:43 am ]
Post subject:  Get high contrast mode for colors

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:
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

Author:  BarryG [ Sun Sep 20, 2020 12:54 am ]
Post subject:  Re: Get high contrast mode for colors

Code:
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).

Author:  oryaaaaa [ Sun Sep 20, 2020 6:11 am ]
Post subject:  Re: Get high contrast mode for colors

I see.

Code:
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?

Author:  RASHAD [ Sun Sep 20, 2020 7:36 am ]
Post subject:  Re: Get high contrast mode for colors

Windows 10 HIGHCONTRAST ON/OFF
Code:
#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)

Author:  oryaaaaa [ Sun Sep 20, 2020 10:57 am ]
Post subject:  Re: Get high contrast mode for colors

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.'

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/