LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CanvasDrawText() fails with code -14

The output of the following snippet is a line drawn in the canvas control, "CanvasDrawText() failed with code -14", then another line drawn in the canvas control. Why is CanvasDrawLine() failing?

char sMessage[200];
int iRet;
// Rect TextRect = { 1, 1, 40, 200 };
static char sFontName[] = { "NewFont" };
Point TextPoint = {0,0};
Point LinePoint = {0,50};

CanvasDrawLine( pGraphic->phPanel, pGraphic->iControlID,
TextPoint, LinePoint );

iRet = CanvasDrawText( pGraphic->phPanel, pGraphic->iControlID,
"Sample Text", VAL_APP_META_FONT, MakeRect( 20, 30, 150, 200 ),
VAL_CENTER_JUSTIFIED );
if ( iRet < 0 ) {
sprintf( sMessage, "CanvasDrawText() failed with code %i", iRet );
MessagePopup( "Message", sMessage );
} else MessagePopup( "Message", "CanvasDrawText() passed" );

CanvasDrawLine( pGraphic->phPanel, pGraphic->iControlID,
pAxis->Axis.Line.Start, pAxis->Axis.Line.End );
0 Kudos
Message 1 of 4
(3,189 Views)
The error you are getting is because VAL_CENTER_JUSTIFIED is not a valid origin for a text plot. Replacing it with VAL_CENTER corrects the problem.

Regards,

Alex
0 Kudos
Message 2 of 4
(3,183 Views)
Glenn,

The reason you're getting the error is because of the last parameter, VAL_CENTER_JUSTIFIED. That's not a valid value for this function. This function expects one of:

VAL_LOWER_LEFT
VAL_CENTER_LEFT
VAL_UPPER_LEFT
VAL_LOWER_CENTER
VAL_CENTER_CENTER
VAL_UPPER_CENTER
VAL_LOWER_RIGHT
VAL_CENTER_RIGHT
VAL_UPPER_RIGHT

Good luck!

Luis
NI
0 Kudos
Message 3 of 4
(3,182 Views)
Oops, my bad. It looks as if there's a problem in the documentation: VAL_CENTER_CENTER does not exist. It's actually VAL_CENTER. Alex is correct.

Luis
0 Kudos
Message 4 of 4
(3,178 Views)