High contrast screen for non blind user - Antonio ?

High contrast screen for non blind user - Antonio ?

Postby Marco Turco » Thu Sep 17, 2009 7:29 am

Hi Antonio,
I have a non blind user that would like to buy a version of my FWH app.
The problem is that it run the high contrast screen mode available on XP and Vista pressing Shift-Alt-PrnScreen to read the screen.
In this mode the app appairs white/black for the highest contrast but some FWH functions doesn't recognize this screen mode as tTitle, Menu, xbrowse and buttonbars. Dialogs and folders appairs well.

See http://www.softwarexp.co.uk/beta/image1.png

Can you make something ?
Do you know a function to detect this screen mode in order I can manage in the meantime the xbrowse colors ?

Thanks in advance.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: High contrast screen for non blind user - Antonio ?

Postby Marco Turco » Thu Sep 17, 2009 9:31 am

Just an update:
the menu and buttonbar display problem can be easly solved removing the "2007" clause when the high contrast mode is active.

I could manage from myself the xbrowse, ttitle and rbbtn display if there is a way to detect if high contrast mode is active.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: High contrast screen for non blind user - Antonio ?

Postby anserkk » Thu Sep 17, 2009 9:48 am

Windows software can check for the high contrast setting by calling the SystemParametersInfo function with the SPI_GETHIGHCONTRAST value. Applications should query and support this value during initialization and when processing WM_COLORCHANGE messages.

Use this structure when you call the SystemParametersInfo function with the uiAction parameter set to the SPI_GETHIGHCONTRAST or SPI_SETHIGHCONTRAST value. When using SPI_GETHIGHCONTRAST, you must specify the cbSize member of the HIGHCONTRAST structure; the SystemParametersInfo function fills in the remaining members. Specify all structure members when using the SPI_SETHIGHCONTRAST value.

HCF_AVAILABLE : The high-contrast mode is available for use.

HCF_HIGHCONTRASTON : The high-contrast mode is on.

HCF_HOTKEYACTIVE : The user can turn the high-contrast mode on and off by pressing the Left ALT + Left SHIFT + PRINT SCREEN.

HCF_HOTKEYAVAILABLE : An application can enable the hot key associated with the high-contrast mode. An application can retrieve this value but cannot set it.

HCF_HOTKEYSOUND : The OS plays a siren sound when the user turns the high-contrast mode on or off by using the hot key.

http://msdn.microsoft.com/en-us/library/aa932539.aspx
http://msdn.microsoft.com/en-us/library/aa932465.aspx

Regards
Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: High contrast screen for non blind user - Antonio ?

Postby Marco Turco » Thu Sep 17, 2009 10:04 am

Hi Anser,
thank you your explain.
Do you already have a xharbour wrapper for this dll function ?
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: High contrast screen for non blind user - Antonio ?

Postby anserkk » Thu Sep 17, 2009 10:14 am

Do you already have a xharbour wrapper for this dll function ?

Sorry, I don't have. :(
Definitely Guru's here in this wonderful forum will be able to help you out.

Here's a VB.NET Code
Header: Declared in Winuser.h; include Windows.h.

'API declarations
Public Const HCF_HIGHCONTRASTON As Integer = 1
Public Const SPI_SETHIGHCONTRAST As Integer = 67
Public Const SPIF_SENDWININICHANGE As Integer = 2
<System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)> _

Public Structure HIGHCONTRAST
     Public cbSize As UInteger
     Public dwFlags As UInteger
     <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)> _
     Public lpszDefaultScheme As String
End Structure
<System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint:="SystemParametersInfoW")> _

Public Shared Function SystemParametersInfoW(ByVal uiAction As UInteger, ByVal uiParam As UInteger, ByVal pvParam As System.IntPtr, ByVal fWinIni As UInteger) As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean
End Function
'End of API declarations
 
'Some button click event
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim highcontraststruct As New HIGHCONTRAST
      highcontraststruct.dwFlags = HCF_HIGHCONTRASTON
      highcontraststruct.cbSize = CUInt(Marshal.SizeOf(highcontraststruct))
      Dim highcontrastptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(highcontraststruct))
      Runtime.InteropServices.Marshal.StructureToPtr(highcontraststruct, highcontrastptr, False)

      SystemParametersInfoW(SPI_SETHIGHCONTRAST, CUInt(Marshal.SizeOf(highcontraststruct)), highcontrastptr, SPIF_SENDWININICHANGE)
End Sub


Instead of
SystemParametersInfoW(SPI_SETHIGHCONTRAST, CUInt(Marshal.SizeOf(highcontraststruct)), highcontrastptr, SPIF_SENDWININICHANGE)

You may have to use SPI_GETHIGHCONTRAST

Regards
Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: High contrast screen for non blind user - Antonio ?

Postby anserkk » Thu Sep 17, 2009 10:33 am

If you need your app to automatically check for any change in window display setting and behave accordingly, then the code given in the below given site may be of useful to you.

http://www.vbaccelerator.com/home/vb/Tips/Detecting_Windows_Settings_Changes/article.asp

VB 6 Code

'Declarations
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Private Declare Function SystemParametersInfoByLong Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As Long) As Long

'Structure
Public Enum enSystemParametersInfo
SPI_NOMESSAGE = 0 '\\ To cope with Win95/WinNT differences!
SPI_GETBEEP = 1
SPI_SETBEEP = 2
SPI_GETMOUSE = 3
SPI_SETMOUSE = 4
SPI_GETBORDER = 5
SPI_SETBORDER = 6
SPI_GETKEYBOARDSPEED = 10
SPI_SETKEYBOARDSPEED = 11
SPI_LANGDRIVER = 12
SPI_ICONHORIZONTALSPACING = 13
SPI_GETSCREENSAVETIMEOUT = 14
SPI_SETSCREENSAVETIMEOUT = 15
SPI_GETSCREENSAVEACTIVE = 16
SPI_SETSCREENSAVEACTIVE = 17
SPI_GETGRIDGRANULARITY = 18
SPI_SETGRIDGRANULARITY = 19
SPI_SETDESKWALLPAPER = 20
SPI_SETDESKPATTERN = 21
SPI_GETKEYBOARDDELAY = 22
SPI_SETKEYBOARDDELAY = 23
SPI_ICONVERTICALSPACING = 24
SPI_GETICONTITLEWRAP = 25
SPI_SETICONTITLEWRAP = 26
SPI_GETMENUDROPALIGNMENT = 27
SPI_SETMENUDROPALIGNMENT = 28
SPI_SETDOUBLECLKWIDTH = 29
SPI_SETDOUBLECLKHEIGHT = 30
SPI_GETICONTITLELOGFONT = 31
SPI_SETDOUBLECLICKTIME = 32
SPI_SETMOUSEBUTTONSWAP = 33
SPI_SETICONTITLELOGFONT = 34
SPI_GETFASTTASKSWITCH = 35
SPI_SETFASTTASKSWITCH = 36
SPI_SETDRAGFULLWINDOWS = 37
SPI_GETDRAGFULLWINDOWS = 38
SPI_GETNONCLIENTMETRICS = 41
SPI_SETNONCLIENTMETRICS = 42
SPI_GETMINIMIZEDMETRICS = 43
SPI_SETMINIMIZEDMETRICS = 44
SPI_GETICONMETRICS = 45
SPI_SETICONMETRICS = 46
SPI_SETWORKAREA = 47
SPI_GETWORKAREA = 48
SPI_SETPENWINDOWS = 49
SPI_GETHIGHCONTRAST = 66
SPI_SETHIGHCONTRAST = 67
SPI_GETKEYBOARDPREF = 68
SPI_SETKEYBOARDPREF = 69
SPI_GETSCREENREADER = 70
SPI_SETSCREENREADER = 71
SPI_GETANIMATION = 72
SPI_SETANIMATION = 73
SPI_GETFONTSMOOTHING = 74
SPI_SETFONTSMOOTHING = 75
SPI_SETDRAGWIDTH = 76
SPI_SETDRAGHEIGHT = 77
SPI_SETHANDHELD = 78
SPI_GETLOWPOWERTIMEOUT = 79
SPI_GETPOWEROFFTIMEOUT = 80
SPI_SETLOWPOWERTIMEOUT = 81
SPI_SETPOWEROFFTIMEOUT = 82
SPI_GETLOWPOWERACTIVE = 83
SPI_GETPOWEROFFACTIVE = 84
SPI_SETLOWPOWERACTIVE = 85
SPI_SETPOWEROFFACTIVE = 86
SPI_SETCURSORS = 87
SPI_SETICONS = 88
SPI_GETDEFAULTINPUTLANG = 89
SPI_SETDEFAULTINPUTLANG = 90
SPI_SETLANGTOGGLE = 91
SPI_GETWINDOWSEXTENSION = 92
SPI_SETMOUSETRAILS = 93
SPI_GETMOUSETRAILS = 94
SPI_SETSCREENSAVERRUNNING = 97
SPI_GETFILTERKEYS = 50
SPI_SETFILTERKEYS = 51
SPI_GETTOGGLEKEYS = 52
SPI_SETTOGGLEKEYS = 53
SPI_GETMOUSEKEYS = 54
SPI_SETMOUSEKEYS = 55
SPI_GETSHOWSOUNDS = 56
SPI_SETSHOWSOUNDS = 57
SPI_GETSTICKYKEYS = 58
SPI_SETSTICKYKEYS = 59
SPI_GETACCESSTIMEOUT = 60
SPI_SETACCESSTIMEOUT = 61
SPI_GETSERIALKEYS = 62
SPI_SETSERIALKEYS = 63
SPI_GETSOUNDSENTRY = 64
SPI_SETSOUNDSENTRY = 65
SPI_GETMOUSEHOVERWIDTH = 98
SPI_SETMOUSEHOVERWIDTH = 99
SPI_GETMOUSEHOVERHEIGHT = 100
SPI_SETMOUSEHOVERHEIGHT = 101
SPI_GETMOUSEHOVERTIME = 102
SPI_SETMOUSEHOVERTIME = 103
SPI_GETWHEELSCROLLLINES = 104
SPI_SETWHEELSCROLLLINES = 105
SPI_GETSHOWIMEUI = 110
SPI_SETSHOWIMEUI = 111
SPI_GETMOUSESPEED = 112
SPI_SETMOUSESPEED = 113
SPI_GETSCREENSAVERRUNNING = 114
SPI_GETACTIVEWINDOWTRACKING = &H1000
SPI_SETACTIVEWINDOWTRACKING = &H1001
SPI_GETMENUANIMATION = &H1002
SPI_SETMENUANIMATION = &H1003
SPI_GETCOMBOBOXANIMATION = &H1004
SPI_SETCOMBOBOXANIMATION = &H1005
SPI_GETLISTBOXSMOOTHSCROLLING = &H1006
SPI_SETLISTBOXSMOOTHSCROLLING = &H1007
SPI_GETGRADIENTCAPTIONS = &H1008
SPI_SETGRADIENTCAPTIONS = &H1009
SPI_GETMENUUNDERLINES = &H100A
SPI_SETMENUUNDERLINES = &H100B
SPI_GETACTIVEWNDTRKZORDER = &H100C
SPI_SETACTIVEWNDTRKZORDER = &H100D
SPI_GETHOTTRACKING = &H100E
SPI_SETHOTTRACKING = &H100F
SPI_GETFOREGROUNDLOCKTIMEOUT = &H2000
SPI_SETFOREGROUNDLOCKTIMEOUT = &H2001
SPI_GETACTIVEWNDTRKTIMEOUT = &H2002
SPI_SETACTIVEWNDTRKTIMEOUT = &H2003
SPI_GETFOREGROUNDFLASHCOUNT = &H2004
SPI_SETFOREGROUNDFLASHCOUNT = &H2005
End Enum



Regards
Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: High contrast screen for non blind user - Antonio ?

Postby Marco Turco » Tue Sep 22, 2009 4:17 pm

Hi all,
is there any C guru able to convert this VB6 call

SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

into xharbour code ?

I need to know the SPI_GETHIGHCONTRAST (66) value.

Thanks in advance.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: High contrast screen for non blind user - Antonio ?

Postby James Bott » Tue Sep 22, 2009 5:03 pm

Marco,

Maybe this will help:

DllCall( "user32.dll", NIL, "SystemParametersInfo", 0, 0, 0, 0 )

Where the 0s are the parameters. I have never used it, I just found it in a Google search here:
http://article.gmane.org/gmane.comp.lang.harbour.devel/2781

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: High contrast screen for non blind user - Antonio ?

Postby mmercado » Tue Sep 22, 2009 6:56 pm

Hello Marco:
Marco Turco wrote:Do you know a function to detect this screen mode in order I can manage in the meantime the xbrowse colors ?

Try this:
Code: Select all  Expand view
#include "FiveWin.ch"

Function Main()

   ?IsHighContrast()

Return Nil

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

BOOL GetHiContrastInfo( VOID ) ;

BOOL GetHiContrastInfo( VOID )
{
   HIGHCONTRAST hc;
   hc.cbSize = sizeof( hc );

   if( SystemParametersInfo( SPI_GETHIGHCONTRAST, sizeof( hc ), & hc, FALSE ) && ( hc.dwFlags & HCF_HIGHCONTRASTON ) )
      return TRUE ;
   else
      return FALSE ;
}

HB_FUNC( ISHIGHCONTRAST )
{
   hb_retl( GetHiContrastInfo() ) ;
}

#pragma ENDDUMP

Best regards.

Manuel Mercado Gomez.
manuelmercado at prodigy dot net dot mx
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: High contrast screen for non blind user - Antonio ?

Postby Marco Turco » Tue Sep 22, 2009 7:48 pm

Great. It runs well.

Thank you very much Manuel.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 21 guests