Possible bug in some coordinates conversion

Possible bug in some coordinates conversion

Postby toninhofwi » Sat Apr 30, 2022 8:40 pm

Hi Antonio how are you?

I found a interesting bug in screen coordinates function (at least in windows 11):

---cut---
GetWindowRect( hWnd, &rct );
wWidth = rct.right - rct.left;
wHeight = rct.bottom - rct.top;
---cut---

In windows 11 rct.right is 1374 and rct.left is -8, so 1374 - (-8) give 1382 and the correct is 1366.
I corrected it using abs() : wWidth = rct.right - abs(rct.left);

Please let me know if is this a bug or an expected behavior.

Regards,

Toninho.
toninhofwi
 
Posts: 170
Joined: Tue Oct 18, 2005 10:01 am

Re: Possible bug in some coordinates conversion

Postby Antonio Linares » Wed Jun 22, 2022 9:17 am

Dear Toninho,

thats VERY interesting, as these days meanwhile we are implementing the new Method Html() for the controls I noticed something similar, so I am going to check with your suggested fix ;-)

many thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Possible bug in some coordinates conversion

Postby Antonio Linares » Wed Jun 22, 2022 9:19 am

Maybe you could try to modify this function using longs instead of ints:

Code: Select all  Expand view
HB_FUNC( GETWNDRECT )     //  hWnd  -->  { nTop, nLeft, nBottom, nRight }
{
   #ifndef _WIN64
      HWND hWnd = ( HWND ) hb_parnl( 1 );
   #else
      HWND hWnd = ( HWND ) hb_parnll( 1 );
   #endif

   RECT rct;

   rct.top    = 0;
   rct.left   = 0;
   rct.bottom = 0;
   rct.right  = 0;

   if( hWnd )
      GetWindowRect( hWnd, &rct );

   hb_reta( 4 );
   hb_storvnl( rct.top,    -1, 1 );   // changed!
   hb_storvnl( rct.left,   -1, 2 );    // changed!
   hb_storvnl( rct.bottom, -1, 3 ); // changed!
   hb_storvnl( rct.right,  -1, 4 );   // changed!
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Possible bug in some coordinates conversion

Postby Otto » Wed Jun 22, 2022 9:47 am

Dear Antonio,
I get the following error:
But I will install FWH 2022/6 on a clean PC and then test again.
Best regards,
Otto

Stack Calls
===========
Called from: => NUMTOHEX( 0 )
Called from: .\source\function\VALBLANK.PRG => FW_CLRTOHTML( 318 )
Called from: .\source\function\WEBAPP.PRG => CHECKBOXHTML( 389 )
Called from: .\source\function\WEBAPP.PRG => CTRLSHTML( 410 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HTML( 426 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:INITIATE( 954 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 1203 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 306 )
Called from: C:\fwh\samples\testdlg.prg => MAIN( 22 )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6068
Joined: Fri Oct 07, 2005 7:07 pm

Re: Possible bug in some coordinates conversion

Postby Antonio Linares » Wed Jun 22, 2022 10:49 am

Dear Otto,

Just after you create the DIALOG please do:

oDlg:lHtml = .F.

Please download FWH.exe again and reinstall it

Many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Possible bug in some coordinates conversion

Postby toninhofwi » Thu Jun 23, 2022 12:24 am

Antonio Linares wrote:Maybe you could try to modify this function using longs instead of ints:

Code: Select all  Expand view
HB_FUNC( GETWNDRECT )     //  hWnd  -->  { nTop, nLeft, nBottom, nRight }
{
...
   hb_reta( 4 );
   hb_storvnl( rct.top,    -1, 1 );   // changed!
   hb_storvnl( rct.left,   -1, 2 );    // changed!
   hb_storvnl( rct.bottom, -1, 3 ); // changed!
   hb_storvnl( rct.right,  -1, 4 );   // changed!
}


Hi Antonio, thanks for answer, but using longs doesn't help, but I think I found the problem:

https://stackoverflow.com/questions/341 ... le-borders

Regards.
toninhofwi
 
Posts: 170
Joined: Tue Oct 18, 2005 10:01 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 46 guests