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. SetWindowText() style question

SetWindowText() style question

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 5 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 have a static control area, it is about 4 lines height. if I only have one string to display, How can I make it horizontal and vertical center? Thanks

    J M L 3 Replies Last reply
    0
    • E econy

      I have a static control area, it is about 4 lines height. if I only have one string to display, How can I make it horizontal and vertical center? Thanks

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      By using the SS_CENTER[^] style.

      1 Reply Last reply
      0
      • E econy

        I have a static control area, it is about 4 lines height. if I only have one string to display, How can I make it horizontal and vertical center? Thanks

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        For the horizontal center, use SS_CENTER, there is not vertical center for CStatic ( or Cedit), you will have to do it manually.

        I'd rather be phishing!

        E 1 Reply Last reply
        0
        • M Maximilien

          For the horizontal center, use SS_CENTER, there is not vertical center for CStatic ( or Cedit), you will have to do it manually.

          I'd rather be phishing!

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

          I use \r\n, almost got vertical center effect

          L 1 Reply Last reply
          0
          • E econy

            I use \r\n, almost got vertical center effect

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

            If you want it to be exact then you need to use a different control (possibly a RichEdit) or subclass the label and do your own painting of the text.

            1 Reply Last reply
            0
            • E econy

              I have a static control area, it is about 4 lines height. if I only have one string to display, How can I make it horizontal and vertical center? Thanks

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              Exactly what Richard said above just subclass a static text box and you can use it over and over again. I have a standard code I use to do what you are doing and it also allows you to change the font, text color and background color as well which is all fairly trivial. Let me know if you want to see how to code it as I wont paste that amount of code if you don't need it.

              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