Archicad 28 C++ API
Loading...
Searching...
No Matches
Resource handling

Functions providing a way to access the compiled GRC resources of the AddOn. Used to define and read the localized strings and other resources in a platform-independent manner. More...

Functions

GSResModule ACAPI_GetOwnResModule (void)
 Returns the add-on's own resource module identifier for loading resources.
 
bool ACAPI_Resource_GetLocStr (char *str, short resID, short index, GSResModule resModule=ACAPI_GetOwnResModule())
 Reads a string from an 'STR# ' string list resource.
 
bool ACAPI_Resource_GetLocUStr (GS::uchar_t *str, short resID, short index, GSResModule resModule=ACAPI_GetOwnResModule())
 Reads a unicode string from an 'STR# ' string list resource.
 
bool ACAPI_Resource_GetFixStr (char *str, short resID, short index, GSResModule resModule=ACAPI_GetOwnResModule())
 Reads a string from an 'STRf ' string list resource.
 

Detailed Description

Functions providing a way to access the compiled GRC resources of the AddOn. Used to define and read the localized strings and other resources in a platform-independent manner.

Function Documentation

◆ ACAPI_GetOwnResModule()

GSResModule ACAPI_GetOwnResModule ( void  )

Returns the add-on's own resource module identifier for loading resources.

Returns
  • NoError - The identifier of the add-on's resource file.
Remarks
You can use the return values of this function wherever a reference to the add-on's own resource module is needed.
Example
bool result;
result = RSGetIndString (&envir->addOnInfo.name, 32000, 1, ACAPI_GetOwnResModule ());
GSResModule ACAPI_GetOwnResModule(void)
Returns the add-on's own resource module identifier for loading resources.

◆ ACAPI_Resource_GetFixStr()

bool ACAPI_Resource_GetFixStr ( char *  str,
short  resID,
short  index,
GSResModule  resModule = ACAPI_GetOwnResModule() 
)

Reads a string from an 'STRf ' string list resource.

Parameters
strThe pointer of the string.
resIDThe resource ID of the ' STRf ' resource in the GRC file.
indexThe index of the string in the resource.
resModule[in] The resource module to load the resource from. The default value is the add-on's own resource module.
Returns
  • true - The string was retrieved successfully.
  • false - The string wasn't retrieved.
Remarks
This function is used to load a string from a string list resource, which is not required to localize. The GRC compiler uses the ' STRf ' resource type for this purpose. The different lines in the resource will be the indices referenced by index parameter. For more information about the structure of the GRC file please refer to the GRC documentation.
Example
See the example of ACAPI_Resource_GetLocStr
.
bool ACAPI_Resource_GetLocStr(char *str, short resID, short index, GSResModule resModule=ACAPI_GetOwnResModule())
Reads a string from an 'STR# ' string list resource.

◆ ACAPI_Resource_GetLocStr()

bool ACAPI_Resource_GetLocStr ( char *  str,
short  resID,
short  index,
GSResModule  resModule = ACAPI_GetOwnResModule() 
)

Reads a string from an 'STR# ' string list resource.

Parameters
str[out] The pointer of the string.
resID[in] The resource ID of the ' STR# ' resource in the GRC file.
index[in] The index of the string in the resource.
resModule[in] The resource module to load the resource from. The default value is the add-on's own resource module.
Returns
  • true - The string was retrieved successfully.
  • false - The string wasn't retrieved.
Remarks
This function is used to load a string from a string list resource, which requires localization. The GRC compiler uses the ' STR# ' resource type for this purpose. The different lines in the resource will be the indices referenced by index parameter. For more information about the structure of the GRC file please refer to the GRC documentation.
Example
/* This is the according part of the GRC file: */
'STR#' 32510 "Fix strings" {
/* [ 1] */ "Saving the file in abc format"
/* [ 2] */ "You have canceled the operation!"
}
/* In the source of the add-on it can be referred like this */
char own_res_str[256];
bool succ;
succ = ACAPI_Resource_GetLocStr (own_res_str, 32510, 1, ACAPI_GetOwnResModule ());
if (succ) {
/* Writing the string in the Report Window */
ACAPI_WriteReport (own_res_str, false);
}
void ACAPI_WriteReport(const GS::UniString &format, bool withDial,...)
Writes a report string into the Report Windowot into a custom alert window.

◆ ACAPI_Resource_GetLocUStr()

bool ACAPI_Resource_GetLocUStr ( GS::uchar_t *  str,
short  resID,
short  index,
GSResModule  resModule = ACAPI_GetOwnResModule() 
)

Reads a unicode string from an 'STR# ' string list resource.

Parameters
str[out] The pointer of the string.
resID[in] The resource ID of the ' STR# ' resource in the GRC file.
index[in] The index of the string in the resource.
resModule[in] The resource module to load the resource from. The default value is the add-on's own resource module.
Returns
  • true - The string was retrieved successfully.
  • false - The string wasn't retrieved.
Remarks
This function is used to load a Unicode string from a string list resource, which requires localization. The GRC compiler uses the ' STR# ' resource type for this purpose. The different lines in the resource will be the indices referenced by index parameter. For more information about the structure of the GRC file please refer to the GRC documentation.
Example
/* This is the according part of the GRC file: */
'STR#' 32530 "Localizable strings" {
/* [ 1] */ "Saving the file in abc format"
/* [ 2] */ "MISSING"
}
/* In the source of the add-on it can be referred like this */
UC257HeadData header;
bool succ;
succ = ACAPI_Resource_GetLocUStr (header.missingName, 32530, 2, ACAPI_GetOwnResModule ());
if (succ) {
...
}
bool ACAPI_Resource_GetLocUStr(GS::uchar_t *str, short resID, short index, GSResModule resModule=ACAPI_GetOwnResModule())
Reads a unicode string from an 'STR# ' string list resource.