2019-02-17 07:46 AM - last edited on 2022-10-04 04:39 PM by Daniel Kassai
API_TextType element; BNZeroMemory(&element , sizeof(API_TextType)); API_ElementMemo memo; BNZeroMemory(&memo, sizeof(API_ElementMemo)); element.head.typeID = API_TextID; element.head.hasMemo = true; element.head.guid = APINULLGuid; element.loc.x = 0; element.loc.y = 0; element.font = 131; CHCopyC(*memo.textContent , "some text"); ACAPI_Element_Create(&element, &memo);
Solved! Go to Solution.
2019-02-18 09:56 AM
static GSErrCode CreateAText (const char* content, short pen, double size, double xPos, double yPos) { API_Element element = {}; element.header.typeID = API_TextID; GSErrCode err = ACAPI_Element_GetDefaults (&element, nullptr); if (err != NoError) { ErrorBeep ("ACAPI_Element_GetDefaults (text)", err); return err; } element.text.pen = pen; element.text.size = size; element.text.anchor = APIAnc_LT; element.text.just = APIJust_Left; element.text.loc.x = xPos; element.text.loc.y = yPos; element.text.nonBreaking = true; element.text.nLine = 1; API_ElementMemo memo = {}; memo.textContent = BMAllocateHandle (Strlen32 (content) + 1, ALLOCATE_CLEAR, 0); strcpy (*memo.textContent, content); err = ACAPI_CallUndoableCommand ("Create text", [&] () -> GSErrCode { return ACAPI_Element_Create (&element, &memo); }); if (err != NoError) ErrorBeep ("ACAPI_Element_Create (text)", err); ACAPI_DisposeElemMemoHdls (&memo); return err; } // CreateAText
2019-02-18 12:17 AM
2019-02-18 09:56 AM
static GSErrCode CreateAText (const char* content, short pen, double size, double xPos, double yPos) { API_Element element = {}; element.header.typeID = API_TextID; GSErrCode err = ACAPI_Element_GetDefaults (&element, nullptr); if (err != NoError) { ErrorBeep ("ACAPI_Element_GetDefaults (text)", err); return err; } element.text.pen = pen; element.text.size = size; element.text.anchor = APIAnc_LT; element.text.just = APIJust_Left; element.text.loc.x = xPos; element.text.loc.y = yPos; element.text.nonBreaking = true; element.text.nLine = 1; API_ElementMemo memo = {}; memo.textContent = BMAllocateHandle (Strlen32 (content) + 1, ALLOCATE_CLEAR, 0); strcpy (*memo.textContent, content); err = ACAPI_CallUndoableCommand ("Create text", [&] () -> GSErrCode { return ACAPI_Element_Create (&element, &memo); }); if (err != NoError) ErrorBeep ("ACAPI_Element_Create (text)", err); ACAPI_DisposeElemMemoHdls (&memo); return err; } // CreateAText
2019-02-18 04:37 PM