A problem with GETCURSORPOS() and widescreen-monitor ?

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

Postby cnavarro » Mon Nov 13, 2017 4:06 pm

And generic function for calculate, please test it and tell me

Code: Select all  Expand view  RUN


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

// 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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby ukoenig » Tue Nov 14, 2017 5: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 :?:
Last edited by ukoenig on Tue Nov 14, 2017 5:36 pm, edited 2 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby cnavarro » Tue Nov 14, 2017 5: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby ukoenig » Sat Nov 18, 2017 7: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 %

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 :?:
Last edited by ukoenig on Sat Nov 18, 2017 8:26 pm, edited 2 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby cnavarro » Sat Nov 18, 2017 8: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby ukoenig » Sat Nov 18, 2017 8: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
Last edited by ukoenig on Sat Nov 18, 2017 8:22 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby cnavarro » Sat Nov 18, 2017 8: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby ukoenig » Sat Nov 18, 2017 8: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

Image

regards
Uwe
Last edited by ukoenig on Sat Nov 18, 2017 8:38 pm, edited 3 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

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

Postby cnavarro » Sat Nov 18, 2017 8: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

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

Postby ukoenig » Sat Nov 18, 2017 8:40 pm

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
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Surasak and 27 guests