### XxxxSTYLES

This function is the PMCX control's style dialog used through the IRE.

Syntax

     MRESULT EXPENTRY XxxxStyles(HWND hWnd, ULONG msg,
                                MPARAM mp1, MPARAM mp2);

     BOOL EXPENTRY XxxxStyles(HWND hDlg, UINT message,
                                UINT wParam, LONG lParam);

Parameters

For OS/2, the parameters are as follows:

    hWnd (HWND) - input
    msg (ULONG) - input
    mp1 (MPARAM) - input
    mp2 (MPARAM) - input

For Windows, the parameters are as follows:

    hDlg (HWND) - input
    message (UINT) - input
    wParam (UINT) - input
    lParam (LONG) - input

Returns

     rc (MRESULT) - returns

     rc (BOOL) - returns

Remarks

On OS/2, during the processing of the WM_INITDLG message, the control should refer to message parameter 2 (MPARAM mp2) as follows:

>     PDATATODLG(hWnd);

On Windows, during the processing of the WM_INITDIALOG message, the control should refer to message lParam (LONG lParam) as follows:

>     PDATATODLG(hDlg);

This will cause the address of the USERSTYLE structure allocated in the IRE to be saved within the dialog's reserved memory. The dialog will then be able to refer to the information in the USERSTYLE structure by using the following method:

     pust = PDATAFROMDLG(hWnd);

     pust = PDATAFROMDLG(hDlg);

Also, during the processing of the WM_INITDLG for OS/2 or WM_INITDIALOG for Windows message, the entry fields for the dialog, along with any styles, should be completed.

For example, on OS/2, if the control supported text, the following could be used to fill in the Text and ID fields:

    if ( (pust = (PUSERSTYLE)mp2) != NULL )
    {
            WinSetDlgItemText(hWnd, ID_TEXT, pust-szText);
            pust->pfnSetSymbolID(hWnd, IDBX_SYMBOLVALUE, pust);
    }

On Windows, the following could be used to fill in the Text and ID fields:

    if ( (pust = (PUSERSTYLE)lParam) != NULL )
    {
            SetDlgItemText(hDlg, ID_TEXT, pust-szText);
            pust->pfnSetSymbolID(hDlg, IDBX_SYMBOLVALUE, pust);
    }

When the dialog is dismissed, the function must return either TRUE through the WinDismissDlg function for OS/2 or the EndDialog function for Windows to indicate to the IRE that changes have been made to the USERSTYLE structure, or FALSE to indicate that no changes were made.

The USERSTYLE structure contains the addresses of the five IRE helper routines. These routines are defined as follows:

    VOID (EXPENTRY *pfnSetSymbolID)(HWND hWnd, ULONG idSymbol, PUSERSTYLE pust);
    BOOL (EXPENTRY *pfnGetSymbolID)(HWND hWnd, ULONG idSymbol, PUSERSTYLE pust);
    VOID (EXPENTRY *pfnGetFontClr)(HWND hWnd);
    BOOL (EXPENTRY *pfnCUACheck)(HWND hWnd, ULONG idEntryField, LONG iCUACompliance);
    BOOL (EXPENTRY *pfnRealloc)(PVOID pv, INT cSize);

The pfnSetSymbol function is used in conjunction with the ID field. The function is used to set the symbol and value of the control within the field.

The following shows how this would be done on OS/2:

    if ( (pust = (PUSERSTYLE)mp2) != NULL )
            pust->pfnSetSymbolID(hWnd, IDBX_SYMBOLVALUE, pust);

The following shows how this would be done on Windows:

    if ( (pust = (PUSERSTYLE)lParam) != NULL )
            pust->pfnSetSymbolID(hDlg, IDBX_SYMBOLVALUE, pust);

The pfnGetFontClr function is used to display the Font & Color dialog box when the user clicks on the Font & Color push button on the toolbar. The function allows the user to set the font and colors for the control.

The following shows how this would be done on OS/2:

    case WM_COMMAND :
            switch ( SHORT1FROMMP(mp1) )
            {
                    case ID_FONTCLR :
                            if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                                    pust->pfnGetFontClr(hWnd);
                            break;

                    .
                    .
                    .
            }
            break;

The following shows how this would be done on Windows:

    case WM_COMMAND :
            switch ( LOWORD(wParam) )
            {
                    case ID_FONTCLR :
                            if ( (pust = PDATAFROMDLG(hDlg)) != NULL )
                                    pust->pfnGetFontClr(hDlg);
                            break;

                    .
                    .
                    .
            }
            break;

The pfnGetBidi function is used to display the Bidirectional Support dialog box when the user clicks on the Bidi push button on the toolbar. The function allows the user to set the font and colors for the control.

The following shows how this would be done on OS/2:

    case WM_COMMAND :
            switch ( SHORT1FROMMP(mp1) )
            {
                    case ID_BIDI :
                            if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                                    pust->pfnGetBidi(hWnd);
                            break;
                    .
                    .
                    .
            }
            break;

The following shows how this would be done on Windows:

    case WM_COMMAND :
            switch ( LOWORD(wParam) )
            {
                    case ID_BIDI :
                            if ( (pust = PDATAFROMDLG(hDlg)) != NULL )
                                    pust->pfnGetBidi(hDlg);
                            break;
                    .
                    .
                    .
            }
            break;

The pfnGetSymbol function is used to inform the dialog box to accept the changes made. The function checks the values in the ID field for validity and displays any required error-message boxes. If the function returns a value of FALSE, the dialog procedure should not retrieve any changes made, but should simply break the current processing to allow the user to correct values within the dialog, as appropriate. A return value of TRUE indicates that the dialog should retrieve all changes made and save them within the USERSTYLE structure before dismissing the dialog. The function will also retrieve the ID symbol and value and place them within the USERSTYLE structure.

The following shows how this would be done on OS/2:

    case WM_COMMAND :
         switch ( SHORT1FROMMP(mp1) )
              {
              case DID_OK :
                   if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                        if ( !pust->pfnGetSymbolID(hWnd, IDBX_SYMBOLVALUE, pust) )
                             }
                             .
                             .      /* Continue processing */
                             .
                             WinDismissDlg(hWnd, TRUE);
                             {
                   break;
              .
              .
              .
              }
         break;

The following shows how this would be done on Windows:

    case WM_COMMAND :
         switch ( LOWORD(wParam) )
              {
              case IDOK :
                   if ( (pust = PDATAFROMDLG(hDlg)) != NULL )
                        if ( !pust->pfnGetSymbolID(hDlg, IDBX_SYMBOLVALUE, pust) )
                             }
                             .
                             .      /* Continue processing */
                             .
                             EndDialog(hDlg, TRUE);
                             {
                   break;
              .
              .
              .
              }
         break;

The pfnCUACheck function is used to inform the dialog box to accept the changes made. The function checks the values within the Text entry field for CUA compliance according to the option selected, and displays any required error-message boxes. If the function returns a value of FALSE, the dialog procedure should not retrieve any changes made, but should simply break the current processing to allow the user to correct values within the dialog, as appropriate. A return value of TRUE indicates that the dialog should retrieve all changes made and save them within the USERSTYLE structure before dismissing the dialog.

The following shows how this would be done on OS/2:

    case WM_COMMAND :
         switch ( SHORT1FROMMP(mp1) )
         {
              case DID_OK :
                    if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                         if ( pust->pfnCUACheck(hWnd, ID_TEXT, CUACHK_CAPS) )
                              break;
                         else
                              {
                                    .       /* Continue processing */
                                    .
                                    .
                                    WinDismissDlg(hWnd, TRUE);
                              }
                         break;
                    .
                    .
                    }
         break;

The following shows how this would be done on Windows:

    case WM_COMMAND :
         switch ( LOWORD(wParam) )
         {
              case IDOK :
                    if ( (pust = PDATAFROMDLG(hDlg)) != NULL )
                         if ( pust->pfnCUACheck(hDlg, ID_TEXT, CUACHK_CAPS) )
                              break;
                         else
                              {
                                    .       /* Continue processing */
                                    .
                                    .
                                    EndDialog(hDlg, TRUE);
                              }
                         break;
                    .
                    .
                    }
         break;

The pfnRealloc function is used when the control accepts variable-length data and the user indicates that the information for the control is to be saved. You have to use the function to reallocate the data buffer for the control data, because the IRE controls the memory allocation for the structures. The function utilizes the memory-management routines of the IRE; therefore care must be exercised that the function is not misused, or the IRE might develop an irrecoverable error. The function behaves exactly like the C library function realloc.

The following shows how this would be done on OS/2:

    case WM_COMMAND :
         switch ( SHORT1FROMMP(mp1) )
         {
              case DID_OK :
                    if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                    {
                         if ( !(pust->pbCtlData =
                              (PBYTE)pust->pfnRealloc(pust-pbCtlData,
                                            sizeof(COMBOBOXCDATA) - 1L)) )
                              {
                              WinMessageBox(HWND_DESKTOP, hWnd,
                                            "Memory error on reallocating control data!",
                                            "Super Combo Box Control", 0,
                                            MB_OK ! MB_ICONEXCLAMATION);
                              return(0L);
                              }
                         pust-cbCtlData = sizeof(COMBOBOXCDATA) - 1 + n;

                         pcbd = (PCOMBOBOXCDATA)pust->pbCtlData;
                         pcbd->cb = sizeof(COMBOBOXCDATA) - 1 + n;
                         pcbd->cItems = cItems;
                         memcpy(pcbd->abList, pchData, n);
                         }
                    break;
              .
              .
              }
         break;

The following shows how this would be done on Windows:

    case WM_COMMAND :
         switch ( LOWORD(wParam) )
         {
              case IDOK :
                    if ( (pust = PDATAFROMDLG(hWnd)) != NULL )
                    {
                         if ( !(pust->pbCtlData =
                              (PBYTE)pust->pfnRealloc(pust-pbCtlData,
                                            sizeof(COMBOBOXCDATA) - 1L)) )
                              {
                              MessageBox(hDlg, "Memory error on reallocating control data!",
                                            "Super Combo Box Control",
                                            MB_OK ! MB_ICONEXCLAMATION);
                              return(0L);
                              }
                         pust-cbCtlData = sizeof(COMBOBOXCDATA) - 1 + n;

                         pcbd = (PCOMBOBOXCDATA)pust->pbCtlData;
                         pcbd->cb = sizeof(COMBOBOXCDATA) - 1 + n;
                         pcbd->cItems = cItems;
                         memcpy(pcbd->abList, pchData, n);
                         }
                    break;
              .
              .
              }
         break;

Control Extensions

PMCX Construction

PMCX Architecture
How PMCX Works