CanvasDrawTextAtPoint
int CanvasDrawTextAtPoint (int panelHandle, int controlID, char text[], char metaFont[], Point anchorPoint, int alignment);
Purpose
Draws a text string at the specified location in the canvas control. The location is in terms of an anchor point and an alignment around the point. If the string exceeds the size of the rectangle, CanvasDrawTextAtPoint clips the text.
CanvasDrawTextAtPoint draws the text using the current value of ATTR_PEN_COLOR.
CanvasDrawTextAtPoint draws the background of the text using the current value of the following attributes:
ATTR_PEN_FILL_COLOR
ATTR_PEN_MODE
ATTR_PEN_PATTERN
If you do not want to draw the background of the rectangle, set the ATTR_PEN_FILL_COLOR attribute of the canvas control to VAL_TRANSPARENT.
Supported Controls
You can use CanvasDrawTextAtPoint with canvas controls.
Parameters
Input | ||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||
panelHandle | int | Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel. | ||||||||||||||||||
controlID | int | The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl. | ||||||||||||||||||
text | char [] | Text string to be drawn at the anchor point. | ||||||||||||||||||
metaFont | char [] | The font to use for the text string. metaFont can be a predefined NI metafont or a user-defined metafont saved by a previous call to functions such as CreateMetaFont and CreateMetaFontEx. The following are NI metafonts: Predefined metafonts—Contain typeface information, point size, and text styles such as bold, underline, italic, and strikeout. These metafonts are used in the LabWindows/CVI environment. The predefined metafonts are VAL_MENU_META_FONT, VAL_DIALOG_META_FONT, VAL_EDITOR_META_FONT, VAL_APP_META_FONT, and VAL_MESSAGE_BOX_META_FONT. LabWindows/CVI-supplied metafonts—Use typefaces that are not native to the operating system. These metafonts are installed while LabWindows/CVI is running. The LabWindows/CVI-supplied metafonts are VAL_7SEG_META_FONT and VAL_SYSTEM_META_FONT. |
||||||||||||||||||
anchorPoint | Point | Point structure specifying location of the point at which to draw the text. The Point structure is defined as follows: typedef struct { int x; int y; } Point; You can create a Point without having to declare a variable by using the following function: Point MakePoint (int x, int y); ExampleCanvasDrawTextAtPoint (panelHandle, controlID, "sample text", VAL_APP_META_FONT, MakePoint (20, 30), VAL_CENTER); |
||||||||||||||||||
alignment | int | Determines the placement of the text string in relation to the anchor point. Each alignment value refers to a point on the rectangle that implicitly encloses the text string. The text string is placed so that the point you specify with the alignment parameter is at the location you specify with the anchorPoint parameter. The valid values for the alignment parameter are listed in the following table.
|
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to userint\RotatedText.cws for an example of using the CanvasDrawTextAtPoint function.