GreSetLineOrigin

GreSetLineOrigin sets the current line style and current position.

This function must be supported by the presentation driver. GreSetLineOrigin is used to enable the simultaneous update of line style and position. This function can be handled by bit-map simulation.


 * Simulation support: None. This function is mandatory for all drivers.

Syntax
GreSetLineOrigin(hdc, pptlXY, lStyle, pInstance, lFunction);

Parameters

 * hdc (HDC) - input
 * Device context handle.


 * pptlXY (PPOINTL) - input
 * Pointer to an (X,Y) coordinate pair to which the current position is returned.


 * lStyle (ULONG) - input
 * Style number.


 * pInstance (PVOID) - input
 * Pointer to instance data.


 * lFunction (ULONG) - input
 * High-order WORD=flags; low-order WORD=NGreSetLineOrigin.

Return Code

 * rc (BOOL) - returns
 * Return codes.


 * On completion, the handling routine must return a BOOLEAN value to indicate success or an error.


 * TRUE Successful
 * FALSE Error


 * Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:


 * PMERR_BASE_ERROR
 * PMERR_COORDINATE_OVERFLOW
 * PMERR_DEV_FUNC_NOT_INSTALLED
 * PMERR_HDC_BUSY
 * PMERR_INV_COORD_SPACE
 * PMERR_INV_HDC
 * PMERR_INV_LENGTH_OR_COUNT
 * PMERR_PATH_LIMIT_EXCEEDED


 * Refer to the "Error Explanations" section in the Presentation Manager Programming Reference for further explanation.

Remarks
If COM_TRANSFORM is set, the current position is expected in world coordinates. If COM_TRANSFORM is not set, the current position is expected in screen coordinates. The new line style is stored in the DC instance data structure. Some lines and curves can be drawn either by the presentation driver or by simulations, and therefore must be able to query and set the style as required.

The high-order WORD of the style number contains the first/last pel information. The low-order BYTE indicates the position in the style mask. The next byte is the state of the style error value. Refer to GreGetLineOrigin for further information.

The following C Language example outlines a strategy by which the handling routine could use the information from a call to GreSetLineOrigin.

 /******************************************************************/ /*                                                               */ /*   StyleMask is a single byte. usState is a USHORT with the   */ /*  error byte as the low-order byte and the mask position as    */ /*  the high-order byte. The three low-order bytes of the mask */ /*  position represent the number of bits by which StyleMask has */ /*  been rotated. */ /*                                                               */ /******************************************************************/

while (necessary--) {

/******************************************************************/ /*                                                               */ /*   Do we need to draw the first pel in the line? */ /*                                                               */ /******************************************************************/

if (stylemask & 0x80) SetPel (x, y);

/******************************************************************/ /*                                                               */ /*   Save the current style state. */ /*                                                               */ /******************************************************************/

usStateOld=usState; switch (LineMajor) {              case yMajor: usState=usState+yRatio; break; default: usState=usState+xRatio; break; }

if HIBYTE (usState) != HIBYTE (usStateOld)

/******************************************************************/ /*                                                               */ /*   If the error byte has overflowed, rotate the style ratio. */ /*  The style mask is reset every eighth rotation. */ /*                                                               */ /******************************************************************/

RotateLeftOne (StyleRatio); UpDateNext (x, y); } 

The values for pRatio are set and queried by GreSetStyleRatio and GreGetStyleRatio respectively. Alternatively, the programmer can specify device-specific defaults for xRatio and yRatio.

Sample Code

 * 1) define INCL_GRE_DEVMISC3
 * 2) include 

HDC       hdc;        /*  Device context handle. */ PPOINTL   pptlXY;     /*  Pointer to an (X,Y) coordinate pair to which the current position is returned. */ ULONG     lStyle;     /*  Style number. */ PVOID     pInstance;  /*  Pointer to instance data. */ ULONG     lFunction;  /*  High-order WORD=flags; low-order WORD=NGreSetLineOrigin.

*/ BOOL      rc;         /*  Return codes. */

rc = GreSetLineOrigin(hdc, pptlXY, lStyle, pInstance, lFunction); 