Get high contrast mode for colors

Windows specific forum
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Get high contrast mode for colors

Post 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
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Get high contrast mode for colors

Post 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).
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Re: Get high contrast mode for colors

Post 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?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Get high contrast mode for colors

Post 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)
Egypt my love
User avatar
oryaaaaa
Enthusiast
Enthusiast
Posts: 791
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Re: Get high contrast mode for colors

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