A problem with GETCURSORPOS() and widescreen-monitor ?

User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

A problem with GETCURSORPOS() and widescreen-monitor ?

Post by ukoenig »

I tested one of my old colorpicker-solutions.
It seems with my widescreen-monitor it doesn't work anymore ?
The cursor returns a wrong screenarea ( must return the color on mouseposition ).
I remember with my old monitor 4:3 it was ok.

Image

DEFINED

local hDeskTop := GETDC(0)
local a := GETCURSORPOS()
local nColor := GETPIXEL( hDeskTop, a[2], a[1] )
...
...


any changes needed because of the monitor-resolution ?

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.
User avatar
Enrico Maria Giordano
Posts: 8761
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

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

Post by Enrico Maria Giordano »

Look if this sample can be of any help:

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON CLICK DRAGDLG( oDlg );
             CENTER

    RETURN NIL


STATIC FUNCTION DRAGDLG( oDlg )

    LOCAL aCoo := GETWNDRECT( oDlg:hWnd )
    LOCAL aOrg := GETCURSORPOS()

    LOCAL aPos

    WHILE GETKEYSTATE( VK_LBUTTON )
        aPos = GETCURSORPOS()

        MOVEWINDOW( oDlg:hWnd, aCoo[ 1 ] + aPos[ 1 ] - aOrg[ 1 ], aCoo[ 2 ] + aPos[ 2 ] - aOrg[ 2 ], , , .T. )

        SYSREFRESH()
    ENDDO

    RETURN NIL


EMG
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post by ukoenig »

Enrico,

it is a test with a existing tool that worked before.
The problem is not the dialog it is the area of the mousecaption.

viewtopic.php?f=3&t=31155&p=180185&hilit=colorpicker#p180185

Download :
http://www.pflegeplus.com/DOWNLOADS/TestPick2.zip

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

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

Post by ukoenig »

I tested some samples like zoomer2.prg with the same wrong results
The cursor must return the cursor area but returns something else.
Maybe < GetCursorPos() > does not work ?

Image

From sample < zoomer2.prg >

FUNCTION getcolor(ownd,nzoom)

local hDeskTop := GetDC(0)
local a := GetCursorPos()
local nColor := GetPixel( hDeskTop, a[2], a[1] )
local hDC := oWnd:GetDC()
local nTop := 0
local nLeft := 0
local nWidth := 200
local nHeight := 200

StretchBlt( hDC, nLeft, nTop, nWidth, nHeight, hDeskTop, a[2]-(nWidth/(nZoom*2)), a[1]-(nHeight/(2*nZoom)), nWidth/nZoom, nHeight/nZoom, 13369376 )

oWnd:ReleaseDC()
ReleaseDC( 0, hDeskTop )
RETURN nil


result of sample < Zoomer.prg >
like You can see, the cursorposition is different

Image

any idea ?

regards
Uwe :(
Last edited by ukoenig on Mon Nov 13, 2017 12:42 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
Enrico Maria Giordano
Posts: 8761
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

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

Post by Enrico Maria Giordano »

Can we see a reduced, yet complete, sample of the problem, please?

EMG
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post by ukoenig »

Enrico,

I used the original FWH-samples < zoomer.prg and zoomer2.prg > to show the results.

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.
User avatar
Enrico Maria Giordano
Posts: 8761
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

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

Post by Enrico Maria Giordano »

I just tried zoomer.prg and found it perfectly working.

EMG
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post by ukoenig »

Enrico,

maybe the problem is the selected screenresolution ?

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.
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

Uwe
What resolution use?
What monitor ?
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
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post by ukoenig »

Cristobal,

I found the reason :
with the monitor it is possible to define a RESIZE-factor.
Normally 100 % is used ( tested and that works !!! )
Because to get a bigger display I used 125 %
THAT IS NOT SUPPORTED !

Monitor settings

Image

regards
Uwe
Last edited by ukoenig on Mon Nov 13, 2017 2:04 pm, edited 5 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
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

Yes, I assumed it was that
It happened to me when I developed the menus
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
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post by ukoenig »

Cristobal,

do You think there is any solution
to respect this setting and adjust the returnvalues of < GetCursorPos() > ?

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.
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

ukoenig wrote:Cristobal,

do You think there is any solution
to respect this setting and adjust the returnvalues of < GetCursorPos() > ?

regards
Uwe :?:


It's possible with DPI SCaling, but developing a function may be complicated to adjust

DPI Scaling Level
Value data
Smaller 100% (default) 96
Medium 125% 120
Larger 150% 144
Extra Large 200% 192
Custom 250% 240
Custom 300% 288
Custom 400% 384
Custom 500% 480

This value think is into register windows
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: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

I found this

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics

But this is better

Code: Select all | Expand


#define LOGPIXELSX    88
#define LOGPIXELSY    90

Function GetLogPixels()

   local hDCM     := oMWnd:GetDC()
   ? GetDeviceCaps( hDCM, LOGPIXELSX ), GetDeviceCaps( hDCM, LOGPIXELSY )
   oMWnd:ReleaseDC()

Return nil


 
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: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

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

Post by cnavarro »

And for know zoom active

Code: Select all | Expand


#define LOGPIXELSX    88
#define LOGPIXELSY    90
#define ASPECTX                     40
#define ASPECTY                     42
#define ASPECTXY                    44

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

Function GetLogPixels()

   local hDCM     := oMWnd:GetDC()
   ? GetDeviceCaps( hDCM, LOGPIXELSX ), GetDeviceCaps( hDCM, LOGPIXELSY ), ;
     GetDeviceCaps( hDCM, ASPECTX ), GetDeviceCaps( hDCM, ASPECTY )
   ? GetScaleFactorForDevice( 0 )
   oMWnd:ReleaseDC()

Return nil

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

DLL32 FUNCTION GetScaleFactorForDevice( deviceType AS DWORD ) AS LONG PASCAL LIB "Shcore.dll"

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

 


And I do not know if this function performs the coordinate conversion correctly

Code: Select all | Expand



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

Function AdjustPos( aPoint )

   Local nZoom  := GetScaleFactorForDevice( 0 )
   Local nPorc  := nZoom / 96
   aPoint[ 1 ]  := Round( aPoint[ 1 ] / nPorc, 0 )
   aPoint[ 2 ]  := Round( aPoint[ 2 ] / nPorc, 0 )

Return aPoint

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

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