SAY pixel position

Post Reply
User avatar
fp
Posts: 76
Joined: Fri Dec 30, 2005 10:25 am
Location: Germany

SAY pixel position

Post by fp »

Using PIXEL with TSay, the position given is not the real position in the dialog.

Code: Select all


#include "FplFwh.Ch"

*******************
FUNCTION Test4711()
*******************
LOCAL oDlg, oSay, cText := "Hallo"
DEFINE DIALOG oDlg FROM 0,0 TO 50,200 PIXEL TITLE "Test"
@  5, 45  SAY oSay VAR cText OF oDlg PIXEL
oDlg:bStart := {||CheckPosition(oDlg,oSay:nId),oDlg:End()}
ACTIVATE DIALOG oDlg CENTER
RETURN NIL



***************************************
STATIC FUNCTION CheckPosition(oDlg,nId)
***************************************

LOCAL aPos := Le_GetIdPos(oDlg,nId)
nMsgBox(STR(aPos[1])+CHR(13)+;
        STR(aPos[2])+CHR(13)+;
        STR(aPos[3])+CHR(13)+;
        STR(aPos[4])+CHR(13))
RETURN NIL


******************************
FUNCTION Le_GetIdPos(oWnd,nId)
******************************

LOCAL aRect, aWinRect, nLeftDiff, nRightDiff, hWndParent
hWndParent  := oWnd:hWnd
aRect       := GetClientRect(GetDlgItem(hWndParent,nID))
aWinRect    := GetClientRect(hWndparent)
nLeftDiff   := aWinRect[3] - aRect[3]
nRightDiff  := aWinRect[4] - aRect[4]
aWinRect    := GetWndRect(GetDlgItem(hWndParent,nID))
aWinRect[3] := aWinRect[3] - aWinRect[1]
aWinRect[4] := aWinRect[4] - aWinRect[2]
ScreenToClient(hWndParent,@aWinRect)
RETURN aWinRect
If I set @ 5,45 PIXEL ..... the real position is 10,90.

So, if want the pixel-position 5,45 on the dialog, I must use 2.5 , 22.5

why?
Frank-Peter
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

The Windows API dialogboxes management has a different way to consider coordinates when creating a dialogbox.

If you want to have exact coordinates, you may place the controls from the ON INIT clause of the dialogbox:

Code: Select all

   ACTIVATE DIALOG oDlg ;
      ON INIT PlaceControls( oDlg )

...

function PlaceControls( oDlg )

   @ ..., ... SAY ... PIXEL
   ...

return nil
This way you will see you get the right positions.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply