FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A problem with GETCURSORPOS() and widescreen-monitor ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Thu Nov 09, 2017 12:04 PM
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.



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.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Thu Nov 09, 2017 02:45 PM
Look if this sample can be of any help:

Code (fw): Select all Collapse
#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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Thu Nov 09, 2017 03:36 PM

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=3t=31155p=180185hilit=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.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 12:12 PM
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 ?



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



any idea ?

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: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 12:40 PM

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

EMG

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 12:45 PM
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.
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 01:13 PM

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

EMG

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 01:22 PM

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.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 01:24 PM

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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 01:39 PM
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



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: Mon Nov 13, 2017 01:45 PM

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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 02:03 PM

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.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 02:10 PM
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 02:28 PM
I found this

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics

But this is better

Code (fw): Select all Collapse
#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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: A problem with GETCURSORPOS() and widescreen-monitor ?
Posted: Mon Nov 13, 2017 03:02 PM
And for know zoom active

Code (fw): Select all Collapse
#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 (fw): Select all Collapse
//----------------------------------------------------------------------------//

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