CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2006
    Posts
    6

    Unhappy How to set font in static text dialog box VC++

    hi
    i had a problem in static text VC++

    how to change font in static text (VC++)

    i want to modif only one static text. not overall.

    thanks.

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: How to set font in static text dialog box VC++

    Quote Originally Posted by syrhackman
    how to change font in static text (VC++)
    SetFont() is the function you need.

  3. #3
    Join Date
    Apr 2006
    Posts
    6

    Unhappy Re: How to set font in static text dialog box VC++

    sorry,

    can u give me an example..

    i want to change my static text with ID : ID_STATIC1

    thanks.

  4. #4
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: How to set font in static text dialog box VC++

    Code:
    	CFont m_Font;
    	m_Font.Detach();
    	m_Font.CreateFont(-13, 0, 0, 0, FW_NORMAL, FALSE, FALSE,0,0,0,0,0,0, "Tahoma");
    	GetDlgItem(IDC_STATIC1)->SetFont(&m_Font);
    If this helps . do not forget to Rate This Post. Thx.

  5. #5
    Join Date
    Sep 2005
    Location
    Singapore
    Posts
    8

    Re: How to set font in static text dialog box VC++

    Add a control variable link to your static text. For example, m_Test.

    Then you can add in the similar code in your initialisation.

    Code:
            CFont font;
    	font.CreateFontW(20,                        // nHeight
    					0,                         // nWidth
    					0,                         // nEscapement
    					0,                         // nOrientation
    					FW_NORMAL,                 // nWeight
    					FALSE,                     // bItalic
    					FALSE,                     // bUnderline
    					0,                         // cStrikeOut
    					ANSI_CHARSET,              // nCharSet
    					OUT_DEFAULT_PRECIS,        // nOutPrecision
    					CLIP_DEFAULT_PRECIS,       // nClipPrecision
    					DEFAULT_QUALITY,           // nQuality
    					DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
    					_T("Arial"));                 // lpszFacename
    
    	m_Test.SetFont(&font,TRUE);
    Perhaps, there might be some easy way to do it.

  6. #6
    Join Date
    Apr 2006
    Posts
    6

    Smile Re: How to set font in static text dialog box VC++

    Thanks...

    It works..

    Thanks alot..

  7. #7
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: How to set font in static text dialog box VC++

    You are welcome .

  8. #8
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: How to set font in static text dialog box VC++

    To zawther :
    how to set ur m_Test to Static Control ????

  9. #9
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How to set font in static text dialog box VC++

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  10. #10
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: How to set font in static text dialog box VC++

    Quote Originally Posted by sunny_sz
    how to set ur m_Test to Static Control ????
    As zawthet explained: By creating a DDX member variable of type CStatic for the control - you usually do this with ClassWizard.

  11. #11
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: How to set font in static text dialog box VC++

    Yeah .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured