Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Setfont() not work

Setfont() not work

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    I am confused with SetFont() function. I followed example code in MSDN, it works well in my laptop. but, when I same code in my WinCE program, it dont work, font not change, show [] [] [] []

    LOGFONT lf; //Use to create new font
    CEdit *pEdit1;

    lf.lfHeight = 12;
    lf.lfWidth = 0;
    memset(&lf, 0, sizeof(LOGFONT)); // Clear lf structure,use it to create the font.
    WCHAR lffn[] = TEXT("Simsun(OpenType)");
    wcscpy(lf.lfFaceName,lffn);
    lf.lfCharSet = GB2312_CHARSET;

    if (m_font2.m_hObject) {
    m_font2.DeleteObject();
    }
    m_font2.CreateFontIndirect(&lf);

    pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );
    pEdit1->SetFont(&m_font2);
    SetDlgItemText(IDC_EDIT1, _T("公里") ); //Chinese letters

    Appreciate any suggestions

    L 1 Reply Last reply
    0
    • E econy

      I am confused with SetFont() function. I followed example code in MSDN, it works well in my laptop. but, when I same code in my WinCE program, it dont work, font not change, show [] [] [] []

      LOGFONT lf; //Use to create new font
      CEdit *pEdit1;

      lf.lfHeight = 12;
      lf.lfWidth = 0;
      memset(&lf, 0, sizeof(LOGFONT)); // Clear lf structure,use it to create the font.
      WCHAR lffn[] = TEXT("Simsun(OpenType)");
      wcscpy(lf.lfFaceName,lffn);
      lf.lfCharSet = GB2312_CHARSET;

      if (m_font2.m_hObject) {
      m_font2.DeleteObject();
      }
      m_font2.CreateFontIndirect(&lf);

      pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );
      pEdit1->SetFont(&m_font2);
      SetDlgItemText(IDC_EDIT1, _T("公里") ); //Chinese letters

      Appreciate any suggestions

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, The code you pasted here appears to be bugged:

      //Here you are setting the font for control with resource id of IDC_EDIT1
      pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );

      //Then you are setting the text on the control with resource id of IDC_INFO_PL
      SetDlgItemText(IDC_INFO_PL, _T("公里") );

      Best Wishes, -David Delaune

      E 1 Reply Last reply
      0
      • L Lost User

        Hi, The code you pasted here appears to be bugged:

        //Here you are setting the font for control with resource id of IDC_EDIT1
        pEdit1 = (CEdit *) GetDlgItem( IDC_EDIT1 );

        //Then you are setting the text on the control with resource id of IDC_INFO_PL
        SetDlgItemText(IDC_INFO_PL, _T("公里") );

        Best Wishes, -David Delaune

        E Offline
        E Offline
        econy
        wrote on last edited by
        #3

        Changed. it is solved, but I don't know the reason. please refer to another question I posted.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups