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. Changing Label Size/Font help

Changing Label Size/Font help

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studiocomtutorial
5 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.
  • D Offline
    D Offline
    Dragondima
    wrote on last edited by
    #1

    Hello, I'm having a very difficult time changing parameters using code to a program that has a few labels. I was able to move their position, change their color, but unfortunately not their sizes. This project also uses ActiveX. I'm using VS 2008, and the only articles that give any insight are all for VS 6.

    m_lblctrl1.SetWindowPos(&wndBottom,0,0,0,0,SWP_NOSIZE);

    changes m_lblctrl1 position (x,y,cx,cy)

    m_lblctrl1.SetForeColor(RGB(255,0,0));

    changes m_lblctrl1 to red.

    m_lblctrl1.SetFont(LPFONTDISP);

    now this is where i've been hitting a very bad wall this is the method i've been tackling. CFont font;

    LOGFONT lf;
    

    memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
    lf.lfHeight = 12; // request a 12-pixel-height font
    strcpy_s(lf.lfFaceName, "Arial"); // request a face name "Arial"
    VERIFY(font.CreateFontIndirect(&lf)); // create the font
    m_lblctrl1.SetFont(&lf);

    the error i'm getting is "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'LOGFONT *' to 'LPFONTDISP' " I've done all the research i could do to properly troubleshoot this, but unfortunately i've hit the point where i need professional help. m_lblctrl1 is defined as a CLabel in case that helps. Also i used Do Data Exchange from the original label defined: DDX_Control(pDX, IDC_LBLCTRL1, m_lblctrl1); If anyone has experience with this LPFONTDISP and how to change the label size/font, i'd greatly appreciate help. Thank you for any input, if there is any details i left out, I'd gladly add it. -David

    CPalliniC 1 Reply Last reply
    0
    • D Dragondima

      Hello, I'm having a very difficult time changing parameters using code to a program that has a few labels. I was able to move their position, change their color, but unfortunately not their sizes. This project also uses ActiveX. I'm using VS 2008, and the only articles that give any insight are all for VS 6.

      m_lblctrl1.SetWindowPos(&wndBottom,0,0,0,0,SWP_NOSIZE);

      changes m_lblctrl1 position (x,y,cx,cy)

      m_lblctrl1.SetForeColor(RGB(255,0,0));

      changes m_lblctrl1 to red.

      m_lblctrl1.SetFont(LPFONTDISP);

      now this is where i've been hitting a very bad wall this is the method i've been tackling. CFont font;

      LOGFONT lf;
      

      memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
      lf.lfHeight = 12; // request a 12-pixel-height font
      strcpy_s(lf.lfFaceName, "Arial"); // request a face name "Arial"
      VERIFY(font.CreateFontIndirect(&lf)); // create the font
      m_lblctrl1.SetFont(&lf);

      the error i'm getting is "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'LOGFONT *' to 'LPFONTDISP' " I've done all the research i could do to properly troubleshoot this, but unfortunately i've hit the point where i need professional help. m_lblctrl1 is defined as a CLabel in case that helps. Also i used Do Data Exchange from the original label defined: DDX_Control(pDX, IDC_LBLCTRL1, m_lblctrl1); If anyone has experience with this LPFONTDISP and how to change the label size/font, i'd greatly appreciate help. Thank you for any input, if there is any details i left out, I'd gladly add it. -David

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Dragondima wrote:

      m_lblctrl1.SetFont(&lf);

      Why don't you use

      m_lblctrl1.SetFont(&font);

      ?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      D 1 Reply Last reply
      0
      • CPalliniC CPallini

        Dragondima wrote:

        m_lblctrl1.SetFont(&lf);

        Why don't you use

        m_lblctrl1.SetFont(&font);

        ?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        D Offline
        D Offline
        Dragondima
        wrote on last edited by
        #3

        Hey, thanks for the reply! I tried this earlier, and got the same "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'CFont *' to 'LPFONTDISP'"

        CPalliniC 1 Reply Last reply
        0
        • D Dragondima

          Hey, thanks for the reply! I tried this earlier, and got the same "error C2664: 'CLabel::SetFont' : cannot convert parameter 1 from 'CFont *' to 'LPFONTDISP'"

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          OK. Now I'm aware your CLabel is an ActiveX control. You have to use OleCreateFontIndirect [^]. Sample code here. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          D 1 Reply Last reply
          0
          • CPalliniC CPallini

            OK. Now I'm aware your CLabel is an ActiveX control. You have to use OleCreateFontIndirect [^]. Sample code here. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            D Offline
            D Offline
            Dragondima
            wrote on last edited by
            #5

            Thanks for the reply! I'm having a hard time getting the exgrid.dll to work, their examples give me a lot of errors. This was more for VS 6 i'm using 2008. I don't know if this would make a difference, i downloaded the file, but haven't had much success. Other suggestions would be greatly appreciated!

            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