Dialog Resizing in Japanese XP

In an 8-year old MFC/MDI project under Visual C++ 6.0, I use the default 8-Pt. MS San Serif.  For the first time I have heard from a Japanese XP customer that the dialog is being resized and labels are being shifted and/or truncated.  Experimentation showed that I could easily reproduce the behavior just by changing font dialog.  I assumed that XP was replacing an unknown font with some more universal font.  However, 8-Pt. MS San Serif was resident on the system and reinstalling it made no difference.  I suspect that this has been a problem all along, but it took all this time to hear about it. 

Anybody know if this is really a font issue   Anyone have a solution for generating dialogs that display correctly under all Windows installations

Thanks

F.F.



Answer this question

Dialog Resizing in Japanese XP

  • techbuild

    Yes, this is an MFC MDI project.

    Thanks

    F.F.


  • Shubham

    How can we change system font and size at run time


  • MITILL

    Does your project use MFC   My answer will depend on that.
  • CHABdesign

    MFC 6.0 has some special handling for dialog fonts.  It is in CDialogTemplate::SetSystemFont.  If you look at the MFC source code in DLGCORE.CPP the following gets called

      // On DBCS systems, also change "MS Sans Serif" or "Helv" to system font.
      if ((!bSetSysFont) && GetSystemMetrics(SM_DBCSENABLED))
      {
       bSetSysFont = (strFace == _T("MS Shell Dlg") ||
        strFace == _T("MS Sans Serif") || strFace == _T("Helv"));
       if (bSetSysFont && (wSize == 8))
        wSize = 0;
      }

      if (bSetSysFont)
      {
       CDialogTemplate dlgTemp(lpDialogTemplate);
       dlgTemp.SetSystemFont(wSize);
       hTemplate = dlgTemp.Detach();
      }

    And in SetSystemFont it does:

     LPCTSTR pszFace = _T("System");
     WORD wDefSize = 10;
     HFONT hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
     if (hFont == NULL)
      hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
     if (hFont != NULL)
     {
      LOGFONT lf;
      if (::GetObject(hFont, sizeof(LOGFONT), &lf) != 0)
      {
       pszFace = lf.lfFaceName;
       HDC hDC = ::GetDC(NULL);
       if (lf.lfHeight < 0)
        lf.lfHeight = -lf.lfHeight;
       wDefSize = (WORD)MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
       ::ReleaseDC(NULL, hDC);
      }
     }

     if (wSize == 0)
      wSize = wDefSize;

     return SetFont(pszFace, wSize);

    For any dialog that has set MS Sans Serif size 8, it converts to the default gui font size and style, which on Japanese is a size 9 and usually MS Gothic (Japanese translation) or MS UI Gothic.   This is normal, you just need to make sure your static controls are big enough (they can be set by using the fit to size in the dialog editor, it should be enough room for Japanese size 9)


  • tconkling

    Thanks...  I will work with this.

     

    F.F.


  • Dialog Resizing in Japanese XP