Trouble with PIXEL clause of SAY command

Trouble with PIXEL clause of SAY command

Postby James Bott » Tue Jul 16, 2013 4:57 pm

I am having trouble with the PIXEL clause of the SAY command.

This:

@ 140,120 say "Title" of oDlg pixel

Actually displays at 290, 242 (measured with an on-screen pixel ruler).

I can create correction factors and get it to display properly.

140/292 = .48
120/242 = .50

So I can do:

@ (140 * .48), (120 * .50) say "Title" of oDlg pixel

And it will be displayed properly. But why is it not displaying at the correct location without conversion? Am I doing something wrong or is it a bug in the SAY class?

I am using FWH 13.04 and BCC 5.82.

Antonio, Nages, anyone?

Regards,
James


Code: Select all  Expand view
// Sample program showing problem with PIXEL clause of SAY command

#include "fivewin.ch"

Function main()

   Local oDlg, oFont, oSay1, oSay2

   define font oFont name "Arial" size 0,-25

   DEFINE DIALOG oDlg size 600, 400

   // Actually displayed at 290, 242
   @ 140, 120 SAY oSay1 PROMPT "Title" ;
      font oFont OF oDlg PIXEL

   @ (140  * .48 ) , 120 * .5 say oSay2 ;
     PROMPT "Title w/ conversion" ;
     font oFont of oDlg PIXEL

   ACTIVATE DIALOG oDlg

   release font oFont

return nil
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Trouble with PIXEL clause of SAY command

Postby James Bott » Wed Jul 17, 2013 12:35 am

OK, I solved the mystery. Dialogs have different units than windows, panels, etc. The controls are placed properly on windows (I didn't check panels yet). So, it does seem to be a bug--controls are not placed properly on dialogs when using the PIXEL clause. I haven't looked into where that would have to be fixed but it seems that controls need to be aware that their parent is a dialog and adjust accordingly. I assume that controls are using dialog units instead of pixels.

I knew it was going to be embarrassing when I discovered the answer.

Sometimes you just have to walk away from the computer and let your subconscious mind work.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Trouble with PIXEL clause of SAY command

Postby Otto » Wed Jul 17, 2013 5:14 am

Hello James,
If I remember well it was you who suggested to me the value 2.05.
It is my Euler number for dialogs. :)
I always use 999/2.05
@ (140 /2.05 ), (120 /2.05 ) say "Title" of oDlg pixel


This gives me good results.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Trouble with PIXEL clause of SAY command

Postby James Bott » Wed Jul 17, 2013 1:38 pm

Otto,

Yes, I rarely hand code controls onto dialogs. I was working with Metro design ideas when this came up and I wasn't even thinking that it was on a dialog.

Nevertheless, it does seem that the conversion should be automatic. Mainly so feeble minded people like me don't have to remember ;-).

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Trouble with PIXEL clause of SAY command

Postby Antonio Linares » Wed Jul 17, 2013 4:03 pm

James,

When the PIXEL clause was implemented in FWH we were not aware that on dialogs, controls use dialog units instead of pixels :-)

By the time that we noticed it (and really understood it), there were already many FWH code around, so we decided to keep it as it was :-)
regards, saludos

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

Re: Trouble with PIXEL clause of SAY command

Postby James Bott » Wed Jul 17, 2013 5:23 pm

Antonio,

Yes, I would agree that you can't break existing code.

The only solution I can see is to create a global setting to really use pixels instead of dialog units. But, I doubt there is much demand for this so I would place a very low priority on it.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests