HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, nsAutoString(NS_ConvertASCIItoUCS2("Print Frame")), rect);
HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect);
UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) {  if (uiMsg == WM_COMMAND) {    UINT id = LOWORD(wParam);    if (id == rad4 || id == rad5 || id == rad6) {      gFrameSelectedRadioBtn = id;      SetRadioOfGroup(hdlg, id);    }  } else if (uiMsg == WM_INITDIALOG) {    PRINTDLG * printDlg = (PRINTDLG *)lParam;    if (printDlg == NULL) return 0L;    PRInt16 howToEnableFrameUI = (PRBool)printDlg->lCustData;    HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hdlg, GWL_HINSTANCE);    if (hInst == NULL) return 0L;    // Start by getting the local rects of several of the controls    // so we can calculate where the new controls are    HWND wnd = ::GetDlgItem(hdlg, grp1);    if (wnd == NULL) return 0L;    RECT dlgRect;    GetLocalRect(wnd, dlgRect, hdlg);    wnd = ::GetDlgItem(hdlg, rad1); // this is the top control "All"    if (wnd == NULL) return 0L;    RECT rad1Rect;    GetLocalRect(wnd, rad1Rect, hdlg);    wnd = ::GetDlgItem(hdlg, rad2); // this is the bottom control "Selection"    if (wnd == NULL) return 0L;    RECT rad2Rect;    GetLocalRect(wnd, rad2Rect, hdlg);    wnd = ::GetDlgItem(hdlg, rad3); // this is the middle control "Pages"    if (wnd == NULL) return 0L;    RECT rad3Rect;    GetLocalRect(wnd, rad3Rect, hdlg);    HWND okWnd = ::GetDlgItem(hdlg, IDOK);    if (okWnd == NULL) return 0L;    RECT okRect;    GetLocalRect(okWnd, okRect, hdlg);    wnd = ::GetDlgItem(hdlg, grp4); // this is the "Print range" groupbox    if (wnd == NULL) return 0L;    RECT prtRect;    GetLocalRect(wnd, prtRect, hdlg);    // calculate various different "gaps" for layout purposes    int rbGap     = rad3Rect.top - rad1Rect.bottom;     // gap between radiobtns    int grpBotGap = dlgRect.bottom - rad2Rect.bottom;   // gap from bottom rb to bottom of grpbox    int grpGap    = dlgRect.top - prtRect.bottom ;      // gap between group boxes    int top       = dlgRect.bottom + grpGap;                int radHgt    = rad1Rect.bottom - rad1Rect.top + 1; // top of new group box    int y         = top+(rad1Rect.top-dlgRect.top);     // starting pos of first radio    int rbWidth   = dlgRect.right - rad1Rect.left - 5;  // measure from rb left to the edge of the groupbox                                                        // (5 is arbitrary)    nsRect rect;    // Create and position the radio buttons    //    // If any one control cannot be created then     // hide the others and bail out    //    rect.SetRect(rad1Rect.left, y, rbWidth,radHgt);    HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, nsAutoString(NS_ConvertASCIItoUCS2("As &laid out on the screen")), rect);    if (rad4Wnd == NULL) return 0L;    y += radHgt + rbGap;    rect.SetRect(rad1Rect.left, y, rbWidth, radHgt);    HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, nsAutoString(NS_ConvertASCIItoUCS2("The selected &frame")), rect);    if (rad5Wnd == NULL) {      Show(rad4Wnd, FALSE); // hide      return 0L;    }    y += radHgt + rbGap;    rect.SetRect(rad1Rect.left, y, rbWidth, radHgt);    HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, nsAutoString(NS_ConvertASCIItoUCS2("&Each frame separately")), rect);    if (rad6Wnd == NULL) {      Show(rad4Wnd, FALSE); // hide      Show(rad5Wnd, FALSE); // hide      return 0L;    }    y += radHgt + grpBotGap;    // Create and position the group box    rect.SetRect (dlgRect.left, top, dlgRect.right-dlgRect.left+1, y-top+1);    HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, nsAutoString(NS_ConvertASCIItoUCS2("Print Frame")), rect);    if (grpBoxWnd == NULL) {      Show(rad4Wnd, FALSE); // hide      Show(rad5Wnd, FALSE); // hide      Show(rad6Wnd, FALSE); // hide      return 0L;    }    // Here we figure out the old height of the dlg    // then figure it's gap from the old grpbx to the bottom    // then size the dlg    RECT pr, cr;     ::GetWindowRect(hdlg, &pr);    ::GetClientRect(hdlg, &cr);    int dlgHgt = (cr.bottom - cr.top) + 1;    int bottomGap = dlgHgt - okRect.bottom;    pr.bottom += (dlgRect.bottom-dlgRect.top) + grpGap + 1 - (dlgHgt-dlgRect.bottom) + bottomGap;    ::SetWindowPos(hdlg, NULL, pr.left, pr.top, pr.right-pr.left+1, pr.bottom-pr.top+1,                    SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER);    // figure out the new height of the dialog    ::GetClientRect(hdlg, &cr);    dlgHgt = (cr.bottom - cr.top) + 1;     // Reposition the OK and Cancel btns    int okHgt = okRect.bottom - okRect.top + 1;    ::SetWindowPos(okWnd, NULL, okRect.left, dlgHgt-bottomGap-okHgt, 0, 0,                    SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER);    HWND cancelWnd = ::GetDlgItem(hdlg, IDCANCEL);    if (cancelWnd == NULL) return 0L;    RECT cancelRect;    GetLocalRect(cancelWnd, cancelRect, hdlg);    int cancelHgt = cancelRect.bottom - cancelRect.top + 1;    ::SetWindowPos(cancelWnd, NULL, cancelRect.left, dlgHgt-bottomGap-cancelHgt, 0, 0,                    SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER);    // Localize the new controls in the print dialog    nsCOMPtr<nsIStringBundle> strBundle;    if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) {      PRInt32 i = 0;      while (gAllPropKeys[i].mKeyStr != NULL) {        SetText(hdlg, gAllPropKeys[i].mKeyId, strBundle, gAllPropKeys[i].mKeyStr);        i++;      }    }    // Set up radio buttons    if (howToEnableFrameUI == nsIPrintOptions::kFrameEnableAll) {      SetRadio(hdlg, rad4, PR_TRUE);        SetRadio(hdlg, rad5, PR_FALSE);       SetRadio(hdlg, rad6, PR_FALSE);      // set default so user doesn't have to actually press on it      gFrameSelectedRadioBtn = rad4;    } else if (howToEnableFrameUI == nsIPrintOptions::kFrameEnableAsIsAndEach) {      SetRadio(hdlg, rad4, PR_TRUE);        SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE);       SetRadio(hdlg, rad6, PR_FALSE);      // set default so user doesn't have to actually press on it      gFrameSelectedRadioBtn = rad4;    } else {  // nsIPrintOptions::kFrameEnableNone      // we are using this function to disabe the group box      SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE);       // now disable radiobuttons      SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE);       SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE);       SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE);     }    // Looks like we were able to extend the dialog    gDialogWasExtended = PR_TRUE;  }  return 0L;}