# EasyTab_ConvertFromCanvas

int EasyTab_ConvertFromCanvas (int panel, int canvasToConvert);

## Purpose

This function converts an existing canvas control into a Tab control.

Although you can call EasyTab_Create to create a Tab control from scratch, it may be more convenient to create and position a canvas control in the User Interface Editor and then use this function to convert the canvas control into a Tab control after the panel is loaded.

If the canvas control has a callback function, the callback function is used for the Tab control.

Events:

> When you change tabs, the event EVENT_TAB_CHANGED is sent to the Tab Control's callback and the callbacks for the panels associated with the current and previous active tabs. The callbacks are called with eventData1 set to the panel handle associated with the current active tab and with eventData2 set to the panelHandle associated with the previous active tab (or to 0 if no tab was previously active).

| Note The Easy Tab Instrument uses the toolbox function ChainCtrlCallback on the tab control, its child panels and their controls, and the panel that the EasyTab control is on (and all of its controls). If you change the callback function or callback data of one of these controls or panels, the resulting behavior is undefined. However, you may call ChainCtrlCallback. You may also set the callback function and callback data for a canvas control before converting it to a tab control, and you may also specify a callback function and callback data when calling EasyTab_Create. For the same reasons, do not call DuplicatePanel or DuplicateCtrl on any of these panels or controls after the Easy Tab control has been created. DiscardPanel or DiscardCtrl will free dynamically allocated memory used by a Tab control.

## Parameters

Input
Name | Type | Description
panel | integer | The specifier for a particular panel that is currently in memory. This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
canvasToConvert | integer | Specifies the canvas control on the panel to convert into a Tab control. Pass the defined constant (located in the UIR header file) which was assigned to the canvas control in the User Interface Editor, or the ID returned by the NewCtrl or DuplicateCtrl function.

## Return Value

Name | Type | Description
easyTabControl | integer | Returns the ID used to specify the Tab control in subsequent function calls. Negative values indicate that an error occurred. If the function succeeds, it returns the same ID that was passed in for the canvasToConvert parameter. Thus, if the canvasToConvert parameter was specified using a defined constant (from the UIR header file) that was assigned to a canvas control in the User Interface Editor, then this same constant can now be used to refer to the Tab control. The possible negative error codes are:
–1 to –999 | A User Interface Library error code. (Constants are available in userint.h.)
| –5000 to –5499 | A Toolbox instrument driver error code. (Constants are available in toolbox.h.)

If the EasyTab_ConvertFromCanvas function has previously been called for the specified control, then nothing is done and the error code UIEInvalidControlType (–45) is returned.
A description of any of these error codes can be obtained using the GetGeneralErrorString function in the toolbox.fp instrument driver.