Page 2 of 2

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

PostPosted: Mon Nov 13, 2017 4:06 pm
by cnavarro
And generic function for calculate, please test it and tell me

Code: Select all  Expand view


//----------------------------------------------------------------------------//

// 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 }

//----------------------------------------------------------------------------//

 

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

PostPosted: Tue Nov 14, 2017 5:32 pm
by ukoenig
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 :?:

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

PostPosted: Tue Nov 14, 2017 5:33 pm
by cnavarro
Yes, that should be the next step, but I need if you can prove it right
Ok?

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

PostPosted: Sat Nov 18, 2017 7:16 pm
by ukoenig
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 %

Image

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

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

PostPosted: Sat Nov 18, 2017 8:12 pm
by cnavarro
Uwe, run OK with all factor zoom and all resolutions ? ( 125% is 1.25 )

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

PostPosted: Sat Nov 18, 2017 8:18 pm
by ukoenig
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

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

PostPosted: Sat Nov 18, 2017 8:20 pm
by cnavarro
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?

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

PostPosted: Sat Nov 18, 2017 8:27 pm
by ukoenig
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

Image

regards
Uwe

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

PostPosted: Sat Nov 18, 2017 8:29 pm
by cnavarro
Yes, I know this, but

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

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

PostPosted: Sat Nov 18, 2017 8:40 pm
by ukoenig
Christobal,

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

Image

There is also a function for monitor

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


regards
Uwe :D