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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Fonts

Fonts

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 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.
  • W Offline
    W Offline
    Waldermort
    wrote on last edited by
    #1

    I have created a custom control which contains two buttons. I want these buttons to display the same arraows which are displayed on a scrollbars buttons. So, I create a font using the Marlett face name and instruct the button to use this font via WM_SETFONT. I also set the buttons text to "3" 4, 5 or 6 ( which maps to the arrows ). But the button still displays the number instead of the arrow. The marlett font doesn't contain any ASCII characters, it's all pictographs! I have verified that the button is using the font via WM_GETFONT. Everything appears to be correct except that the arrows are not being displayed. Any clue as to what's gone wrong?

    HFONT hFont = NULL;

    hFont = (HFONT)SendMessage( m_hButtonUp, WM_GETFONT, 0, 0 );
    if ( ! hFont )
    hFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT );
    if ( ! hFont )
    hFont = (HFONT)GetStockObject( ANSI_VAR_FONT );

    if ( hFont )
    {
    LOGFONT lf;
    GetObject( hFont, sizeof( LOGFONT ), &lf );

    \_tcscpy\_s( lf.lfFaceName, LF\_FACESIZE, \_T("Marlett") );
    
    hFont = CreateFontIndirect( &lf );
    
    SendMessage( m\_hButtonUp,	WM\_SETFONT, (WPARAM)hFont, TRUE );
    SendMessage( m\_hButtonDown, WM\_SETFONT, (WPARAM)hFont, TRUE );
    
    SendMessage( m\_hButtonUp,	WM\_SETTEXT, 0, (LPARAM)\_T("3") );
    SendMessage( m\_hButtonDown,	WM\_SETTEXT, 0, (LPARAM)\_T("4") );
    

    }

    Waldermort

    K N 2 Replies Last reply
    0
    • W Waldermort

      I have created a custom control which contains two buttons. I want these buttons to display the same arraows which are displayed on a scrollbars buttons. So, I create a font using the Marlett face name and instruct the button to use this font via WM_SETFONT. I also set the buttons text to "3" 4, 5 or 6 ( which maps to the arrows ). But the button still displays the number instead of the arrow. The marlett font doesn't contain any ASCII characters, it's all pictographs! I have verified that the button is using the font via WM_GETFONT. Everything appears to be correct except that the arrows are not being displayed. Any clue as to what's gone wrong?

      HFONT hFont = NULL;

      hFont = (HFONT)SendMessage( m_hButtonUp, WM_GETFONT, 0, 0 );
      if ( ! hFont )
      hFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT );
      if ( ! hFont )
      hFont = (HFONT)GetStockObject( ANSI_VAR_FONT );

      if ( hFont )
      {
      LOGFONT lf;
      GetObject( hFont, sizeof( LOGFONT ), &lf );

      \_tcscpy\_s( lf.lfFaceName, LF\_FACESIZE, \_T("Marlett") );
      
      hFont = CreateFontIndirect( &lf );
      
      SendMessage( m\_hButtonUp,	WM\_SETFONT, (WPARAM)hFont, TRUE );
      SendMessage( m\_hButtonDown, WM\_SETFONT, (WPARAM)hFont, TRUE );
      
      SendMessage( m\_hButtonUp,	WM\_SETTEXT, 0, (LPARAM)\_T("3") );
      SendMessage( m\_hButtonDown,	WM\_SETTEXT, 0, (LPARAM)\_T("4") );
      

      }

      Waldermort

      K Offline
      K Offline
      KarstenK
      wrote on last edited by
      #2

      The returncodes of the SendMessage() and try an Invalidate() of the controls :doh:

      Greetings from Germany

      1 Reply Last reply
      0
      • W Waldermort

        I have created a custom control which contains two buttons. I want these buttons to display the same arraows which are displayed on a scrollbars buttons. So, I create a font using the Marlett face name and instruct the button to use this font via WM_SETFONT. I also set the buttons text to "3" 4, 5 or 6 ( which maps to the arrows ). But the button still displays the number instead of the arrow. The marlett font doesn't contain any ASCII characters, it's all pictographs! I have verified that the button is using the font via WM_GETFONT. Everything appears to be correct except that the arrows are not being displayed. Any clue as to what's gone wrong?

        HFONT hFont = NULL;

        hFont = (HFONT)SendMessage( m_hButtonUp, WM_GETFONT, 0, 0 );
        if ( ! hFont )
        hFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT );
        if ( ! hFont )
        hFont = (HFONT)GetStockObject( ANSI_VAR_FONT );

        if ( hFont )
        {
        LOGFONT lf;
        GetObject( hFont, sizeof( LOGFONT ), &lf );

        \_tcscpy\_s( lf.lfFaceName, LF\_FACESIZE, \_T("Marlett") );
        
        hFont = CreateFontIndirect( &lf );
        
        SendMessage( m\_hButtonUp,	WM\_SETFONT, (WPARAM)hFont, TRUE );
        SendMessage( m\_hButtonDown, WM\_SETFONT, (WPARAM)hFont, TRUE );
        
        SendMessage( m\_hButtonUp,	WM\_SETTEXT, 0, (LPARAM)\_T("3") );
        SendMessage( m\_hButtonDown,	WM\_SETTEXT, 0, (LPARAM)\_T("4") );
        

        }

        Waldermort

        N Offline
        N Offline
        nbugalia
        wrote on last edited by
        #3

        SendMessage( m_hButtonUp, WM_SETFONT, (WPARAM)hFont, TRUE ); Have you checked the return value ? I mean has the font got set ? If not, check using different fonts like arial etc.

        W 1 Reply Last reply
        0
        • N nbugalia

          SendMessage( m_hButtonUp, WM_SETFONT, (WPARAM)hFont, TRUE ); Have you checked the return value ? I mean has the font got set ? If not, check using different fonts like arial etc.

          W Offline
          W Offline
          Waldermort
          wrote on last edited by
          #4

          The WM_SETFONT does not return a value according to MSDN, also I noted in my post that I did verify that the font has been set. The mistake was simple, I forgot to set the SYMBOL_CHARSET flag. Thanks anyway.

          Waldermort

          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