4D Write v16

WR GET CURSOR COORDINATES

Home

 
4D Write v16
WR GET CURSOR COORDINATES

WR GET CURSOR COORDINATES 


 

WR GET CURSOR COORDINATES ( area ; posHoriz ; posVert ; height ) 
Parameter Type   Description
area  Longint in 4D Write area
posHoriz  Real in Horizontal position in the page
posVert  Real in Vertical position in the page
height  Real in Height of the cursor

The WR GET CURSOR COORDINATES command returns the coordinates of the cursor in relation to the upper left corner of the page. These values are expressed in the current default unit for the document.

When the command is executed with a text or a picture selected in the area, two cases can occur:

  • If the selection has been made programmatically, the cursor is considered to be set at the end of the selection.
  • If the selection has been made manually, the cursor is considered to be set at the mouse button release location. For example, if a paragraph has been manually selected by dragging the mouse from the last line to the first line, the cursor position will be set at the beginning of the selection.

The height parameter returns the current height of the cursor. If only a picture is selected, the height of the picture is returned.

Example  

Starting with 4D version 2004.5, the Print form command can be used to print 4D Write areas. In principle, these areas are printed with a fixed height. The following example shows how to use the 4D print commands and the WR GET CURSOR COORDINATES command in order to vary the printing height of the 4D Write area according to its contents.

  • Here is the form method that is called by the Print form command:
 If(Form event=On Printing Detail)
    GET OBJECT RECT(4DWriteArea;$left;$top;$right;$bottom)
    $markerpos:=Get print marker(Form detail)
    $areaheight:=$bottom-$top  ` height of 4D Write area
    $newheight:=sizecalcul
  ` sizecalcul returns the height of the 4D Write area according to its contents
  ` this method is shown below
    $shift:=$newheight-$areaheight
    MOVE OBJECT(4DWriteArea;0;0;0;$shift` resizing of the 4D Write area
    SET PRINT MARKER(Form detail;$markerpos+$shift` moving the marker
 End if
  • Below is the sizecalcul method:
 $area:=WR New offscreen area
 WR BLOB TO AREA($area;[Table 1]Write_)
 WR SET DOC PROPERTY($area;wr unit;2) ` We are working in pixels
 
 WR SET SELECTION($area;1;1) ` Start of text
 WR GET CURSOR COORDINATES($area;$hor;$startvert;$cursor1)
 WR SET SELECTION($area;1000000;1000000) ` End of text
 WR GET CURSOR COORDINATES($area;$hor;$vert;$cursor2)
 
 WR DELETE OFFSCREEN AREA($area)
 $0:=Trunc(($vert-$startvert+$cursor1+$cursor2)*0.75;0)



See also 

WR GET CURSOR POSITION

 
PROPERTIES 

Product: 4D Write
Theme: WR Area Options
Number: 89438

 
HISTORY 

Modified: 4D Write 2004.5

 
ARTICLE USAGE

4D Write Language ( 4D Write v16)