FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A problem with GETCURSORPOS() and widescreen-monitor ?
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Mon Nov 13, 2017 04:06 PM
And generic function for calculate, please test it and tell me

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

// Calculate nZoom and/or DPIs
Function CalcZoom( oWnd )

   // { nZoom, DPIs }
   Local aZooms := { { 100, 096 }, { 120, 115 }, { 125, 120 }, { 140, 134 }, ;
                     { 150, 144 }, { 160, 154 }, { 180, 173 }, ;
                     { 200, 192 }, { 225, 216 }, { 250, 240 }, { 300, 288 }, ;
                     { 400, 384 }, { 500, 480 } }
   Local nZoom
   local nDPIs    := 0
   local nPos     := 0
   local hDCM     := oWnd:GetDC()
   local nLogX    := GetDeviceCaps( hDCM, LOGPIXELSX )
   local nLogY    := GetDeviceCaps( hDCM, LOGPIXELSY )
   nPos           := AsCan( aZooms, { | a | a[ 2 ] == nLogX } )
   if Empty( nPos )
      // Not found in array predefined modes
      nDPIs       := 96  + Round( nLogX * 24 / 25, 0 )
      nZoom       := Round( nDPIs * 100 / 96, 0 )
   else
      // Found in array predefined modes
      nDPis       := nLogX
      nZoom       := aZooms[ nPos ][ 1 ]
   endif

Return { nZoom, nDPIs }

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Tue Nov 14, 2017 05:32 PM
Cristobal,

all tests are using

FUNCTION GETCOLOR()
local hDeskTop := GETDC(0)
local a := GETCURSORPOS()
local nColor := GETPIXEL( hDeskTop, a[2], a[1] )
local hDC := oDlg:GETDC()
local hPen := CREATEPEN( PS_SOLID, 1.5, CLR_HRED )
local hOldPen
local nTop, nLeft
local nWidth, nHeight


Isn't it possible to modify the function GETCURSORPOS()
to show the correct cursorposition-area ?

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Tue Nov 14, 2017 05:33 PM

Yes, that should be the next step, but I need if you can prove it right
Ok?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 07:16 PM
Cristobal

I adjusted the top / left values of < GETCURSORPOS() >
with a factor 1.25 -> 1920 x 1080 of 125 % zoom
linear with a factor 1.5 -> 1920 x 1080 of 150 % zoom
I tested all monitor areas with perfect results.
maybe we doen't need any complicted calculations and can work with a fixed factor ?

other resolution with a factor 1.25 -> 1600 x 900 of 125 % zoom works as well.

it means only 2 possible adjustments are needed : factor 1,25 for 125 % zoom and 1.5 if 150 % zoom is used.

I tested :
nZoom := GetScaleFactorForDevice( 0 )
MsgAlert( nZoom, "Zoom-factor" ) > returns 100 % ( 125 % is needed )
Is there maybe another function or calculation ?
Your function -> CalcZoom() also doesn't return 125 %



FUNCTION GETCOLOR()
local hDeskTop := GETDC(0)
local a := GETCURSORPOS()
// Left Top
local nColor := GETPIXEL( hDeskTop, a[2] * 1.25, a[1] * 1.25 )
local hDC := oDlgChild:GETDC()
local hPen := CREATEPEN( PS_SOLID, 1.5, CLR_HRED )
local hOldPen
local nTop, nLeft
local nWidth, nHeight

nTop := 5
nLeft := 5
nWidth := 90
nHeight := 90

MOVETO( hDC, nLeft-1, nTop-1)
LINETO( hDC, nLeft + nWidth+1, nTop-1 )
LINETO( hDC, nLeft + nWidth+1, nTop+nHeight+1 )
LINETO( hDC, nLeft -1, nTop+nHeight+1 )
LINETO( hDC, nLeft-1, nTop-1)

STRETCHBLT( hDC, nLeft, nTop, nWidth, nHeight, hDeskTop, ;
a[2] * 1.25 -(nWidth/(nZoom*2)), a[1] * 1.25 -(nHeight/(2*nZoom)), ;
nWidth/nZoom, nHeight/nZoom, 13369376 )
...
...
regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:12 PM

Uwe, run OK with all factor zoom and all resolutions ? ( 125% is 1.25 )

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:18 PM
Cristobal

other resolution with a factor 1.25 -> 1600 x 900 with 125 % zoom I tested and works as well !!
I think there is not much to do, we only have to define the selected zoom-factor.
of the possible selection of 100, 125, 150 or 175 ( zoom )

regards
Uwe
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:20 PM
ukoenig wrote:Cristobal

other resolution with a factor 1.25 -> 1600 x 900 with 125 % zoom I tested and works as well !!

it is only the possible selection of 100, 125, 150 or 175 ( zoom )

regards
Uwe


And with zoom different to 125 run OK also?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:27 PM
Christobal,

windows offers only these 4 values from a list
I found only 125 % is making sense to get bigger symbols visible on the desktop



regards
Uwe
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:29 PM

Yes, I know this, but

You are used 1.25 number for adjust
You are tested with zoom selected 175 ?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: A problem with GETCURSORPOS() and widescreen-monitor ?

Posted: Sat Nov 18, 2017 08:40 PM
Christobal,

175 % tested and works as well ( but to big )



There is also a function for monitor

STDAPI GetScaleFactorForMonitor(
_In_ HMONITOR hMon,
_Out_ DEVICE_SCALE_FACTOR *pScale
);


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion