int CanvasDrawText (int panelHandle, int controlID, char text[], char metaFont[], Rect bounds, int alignment);
Draws a text string within a specified rectangular area on the canvas control. You can set the alignment of the string within the rectangle. If the string exceeds the size of the rectangle, CanvasDrawText clips the string.
CanvasDrawText draws the text using the current value of ATTR_PEN_COLOR.
CanvasDrawText draws the background rectangle 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.
Input | ||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||
panelHandle | integer | Specifier for a particular panel that is currently in memory. You obtain this handle from LoadPanel, NewPanel, or DuplicatePanel. | ||||||||||||||||||
controlID | integer | 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 NewCtrl or DuplicateCtrl. | ||||||||||||||||||
text | string | Text string to draw within the rectangle. | ||||||||||||||||||
metaFont | string | The text font. metaFont must be one of the predefined metafonts or a metafont you create by calling CreateMetaFont. 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. Examples of predefined metafonts include VAL_MENU_META_FONT, VAL_DIALOG_META_FONT, VAL_EDITOR_META_FONT, and VAL_APP_META_FONT. LabWindows/CVI-supplied metafonts—Supplied with LabWindows/CVI and installed while LabWindows/CVI is running. These metafonts use typefaces that are not native to the operating systems. Examples of LabWindows/CVI-supplied metafonts are VAL_7SEG_META_FONT and VAL_SYSTEM_META_FONT. |
||||||||||||||||||
bounds | Rect | Rect structure specifying the location and size of the background rectangle within which to draw the text. Specify values in the bounds parameter in terms of pixel coordinates, with the origin (0,0) at the upper left corner of the canvas control. The Rect structure is defined as follows: typedef struct { int top; int left; int height; int width; } Rect; You can create a Rect without having to declare a variable by using the following function: Rect MakeRect (int top, int left, int height, int width); If you want the size of the background rectangle to adjust automatically to the display size of the text string, set the height and width of the rectangle to VAL_KEEP_SAME_SIZE. ExampleCanvasDrawText (panelHandle, controlID, "sample text" VAL_APP_META_FONT, MakeRect(20,30,150,200), VAL_CENTER); |
||||||||||||||||||
alignment | integer | Determines the placement of the text string within the background rectangle.
If the background rectangle you specify in bounds is smaller than the text display size, the function clips the text to the rectangle and ignores the alignment parameter. If the rectangle width is smaller than the text display width, the text starts from the left. If the rectangle height is smaller than the text display height, the text starts from the top. |
Name | Type | Description | ||||
status | integer | Return value indicating whether the function was successful. A negative number indicates that an error occurred.
|