Dialog box - limiting resizing to one direction (x or y)

I'm resizing dialog box (by setting attributes to DIALOGATTR_DEFAULT |
DIALOGATTR_GROWABLE | DIALOGATTR_MOTIONTOITEMS)
and then some code in the hook function. Is there an easy way to limit
dialog box resizing to width (or height) ? In some circumstances I want to
allow
the resizing in one direction only.

Any suggestions ?

Thank you.

Jarek

  • Hi Jarek,

    Use the DIALOG_MESSAGE_WINDOWMOVING dialog hook message to check which corners are being resized and pass the message to a resize function to limit the finished size.

    #define FONTWIDTH(ht) ((int) (ht / 2))
    DLLEXPORT void dialogName_resizeDialogItems
    (
    DialogMessage *dmP
    )
    {
    int fontHeight = FONTWIDTH (mdlDialog_fontGetCurHeight (dmP->db));
    int width = fontHeight * 90;
    int height = (int) D_ROW(10);
    // reset minimum dialog dimensions if required
    if (dmP->u.windowMoving.newWidth < width) dmP->u.windowMoving.newWidth = width;
    if (dmP->u.windowMoving.newHeight < height) dmP->u.windowMoving.newHeight = height;
    // -------------------------------------------------------------------
    // Tell the dialog manager what new size we want. Resetting the
    // Height and Width in this message takes the place of calling
    // mdlWindow_extentSet. The dialog manager will reset the actual
    // size of the dialog if handled is set to TRUE
    // -------------------------------------------------------------------
    // tell the dialog manager to use our dialog dimensions
    dmP->u.windowMoving.handled = TRUE;
    }

    DLLEXPORT void dialogName_dBoxHook
    (
    DialogMessage *dmP
    )
    {
    dmP->msgUnderstood = TRUE;
    switch (dmP->messageType)
    {
    case DIALOG_MESSAGE_CREATE:
    // set the dialog interests for the popup menu item
    dmP->u.create.interests.mouses = dmP->u.create.interests.nonDataPoints = dmP->u.create.interests.preButtons = dmP->u.create.interests.resizes = dmP->u.create.interests.windowMoving = TRUE;
    break;

    case DIALOG_MESSAGE_WINDOWMOVING:
    // don't process if only moving dialog box
    if (dmP->u.windowMoving.newHeight != 1 && dmP->u.windowMoving.whichCorners != CORNER_ALL && dmP->u.windowMoving.whichCorners != CORNER_ALL_RESIZED)
    {
    // resize the dialog items to fit the dialog
    featureStatistics_resizeDialogItems (dmP);
    }
    break;
    default:
    dmP->msgUnderstood = FALSE;
    break;
    }
    }

    Regards,

    Micheal