The first step in creating a PMCX control is to develop a naming convention. The best way to illustrate this is by considering the example below:
Functions
XxxxRegister XxxxQuery XxxxStyles
Dynamic-Link Library
Xxxx.DLL
Xxxx is the common name for the control. The common name is limited to 8 letters to allow for FAT disk systems, unless it is specifically to be used with HPFS disk systems. The maximum length that the common name is allowed to have is 32 bytes, including the null-terminating character, because the szName field of the USERINFO structure accepts only that number of characters.
Next, determine who is responsible for allocating and de-allocating memory for the structures. The IRE will allocate and de-allocate necessary memory for structures used to communicate with the PMCX control, and will provide the function with a pointer to the memory address of the structure when communication is required. The PMCX control's style function is responsible for saving the address of this structure. Any pointers to memory elements within the structures are also allocated and de-allocated by the IRE on behalf of the control.
The only exception is in the case of a control that allows for variable-length control data. In this case, the control can, through a callback function to the IRE, reallocate the control data memory.
Because the PMCX control's dialog procedure is responsible for saving the address of the USERSTYLE structure address passed to it by the IRE, you can use the two helper macros that are defined for use by the styles dialog procedure to save and retreive.
To save the address of the USERSTYLE structure address within the dialog's reserved memory at the DWL_USER reserved memory location, you use the PDATATODLG macro. To retrieve the USERSTYLE structure address from the same location, you use PDATAFROMDLG macro.
For any PMCX control to be successful, you must provide encapsulation of its use to permit multiple usage. This requires that the control be totally re-entrant. A means of achieving this is by using dynamically allocated memory. You would then save this memory address within the control's reserved memory. These can be referred to with the QWW_* indexes.
The IRE provides a set of helper functions for the control's style dialog to allow it to be used in a manner consistent with the style dialogs provided normally through the IRE.These helper functions must allow the control's dialog access to the ID field, the Font & Color dialog box, symbol verification and CUA compliance. The IRE must provide the addresses of these routines within the USERSTYLE structure in the following elements:
| pfnSetSymbol | ID field symbol and value-set helper function |
| pfnGetSymbol | Symbol ID and value validation and retrieval helper function |
| pfnGetFontClr | Font & Color helper function |
| pfnCUACheck | CUA-compliance helper function |
| pfnRealloc | Memory reallocation function, similar to C library function realloc |
The IRE constructs the necessary statements within the resource script on behalf of the PMCX control. In turn, the PMCX control must provide style masks and a string table containing the ASCII style definitions within its resources if styles are permitted for the control. The style masks and ID values for the string that corresponds to the style masks are to be placed within the provided structure elements of the USERINFO structure, along with the count of masks. The control must also provide, through the USERINFO structure, the number of control data bytes that it requires. This structure must be completed in the XxxxQuery function through the structure address passed to the function when it is called by the IRE.
The functions defined for the control must be exported within the controls definition file. The name of the function should be entered along with an ordinal value. The following ordinals are required:
| XxxxRegister | 1 |
| XxxxQuery | 2 |
| XxxxStyles | 3 |
![]()
PMCX Definition
Headers
PMCX Architecture
How PMCX Works