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. How to change CEdit font [Solved]

How to change CEdit font [Solved]

Scheduled Pinned Locked Moved C / C++ / MFC
tutoriallearning
2 Posts 1 Posters 1 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

    Hi, I want to change several CEdit's font in a dialog based program. the dialog is a non-modal dialog,in it's OnInitDialog().

    BOOL CTestFontDlg::OnInitDialog()
    {
    CFont * pFontNew;
    LOGFONT lf; //Use to create new font
    CEdit *pEdit1;
    CEdit *pEdit2;
    CEdit *pEdit3;

    CDialog::OnInitDialog();
    pApp = (CTestFont\*) AfxGetApp();
    
    AddFontResource(TEXT("\\\\FlashDisk\\\\Startup\\\\Simsun.ttc"));	//Add font resource
    
    if ( pApp->g\_Settings.language == LNG\_CHINESE ) {
    	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;
    	pFontNew->CreateFontIndirect(&lf);
    	//FontNew = CreateFontIndirect(&lf);
    	
    	pEdit1 = (CEdit \*) GetDlgItem( IDC\_INFO\_PL );
    	pEdit2 = (CEdit \*) GetDlgItem( IDC\_INFO\_PRESS );
    	pEdit3 = (CEdit \*) GetDlgItem( IDC\_INFO\_TOP );
    	pEdit1->SetFont(pFontNew);
    	pEdit2->SetFont(pFontNew);
    	pEdit3->SetFont(pFontNew);
    }
    
    return TRUE; 
    

    }

    but once I added the if ( pApp->g_Settings.language == LNG_CHINESE ) { ... } block, the screen become black, nothing be displayed.

    E 1 Reply Last reply
    0
    • E econy

      Hi, I want to change several CEdit's font in a dialog based program. the dialog is a non-modal dialog,in it's OnInitDialog().

      BOOL CTestFontDlg::OnInitDialog()
      {
      CFont * pFontNew;
      LOGFONT lf; //Use to create new font
      CEdit *pEdit1;
      CEdit *pEdit2;
      CEdit *pEdit3;

      CDialog::OnInitDialog();
      pApp = (CTestFont\*) AfxGetApp();
      
      AddFontResource(TEXT("\\\\FlashDisk\\\\Startup\\\\Simsun.ttc"));	//Add font resource
      
      if ( pApp->g\_Settings.language == LNG\_CHINESE ) {
      	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;
      	pFontNew->CreateFontIndirect(&lf);
      	//FontNew = CreateFontIndirect(&lf);
      	
      	pEdit1 = (CEdit \*) GetDlgItem( IDC\_INFO\_PL );
      	pEdit2 = (CEdit \*) GetDlgItem( IDC\_INFO\_PRESS );
      	pEdit3 = (CEdit \*) GetDlgItem( IDC\_INFO\_TOP );
      	pEdit1->SetFont(pFontNew);
      	pEdit2->SetFont(pFontNew);
      	pEdit3->SetFont(pFontNew);
      }
      
      return TRUE; 
      

      }

      but once I added the if ( pApp->g_Settings.language == LNG_CHINESE ) { ... } block, the screen become black, nothing be displayed.

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

      Resolved

      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