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. Set button style

Set button style

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

    Can you suggest me a way to change dynamically the button style from bitmap to text and viceversa? I tried with m_BUTT_25.SetButtonStyle(BS_TEXT); m_BUTT_25.RedrawWindow(); and m_BUTT_25.SetButtonStyle(BS_BITMAP); m_BUTT_25.RedrawWindow(); but nothing seems to happen... :( I can instead change the button caption with SetWindowText: why is this? :confused: Thanks :), Marco.

    J V D 3 Replies Last reply
    0
    • M marcomars

      Can you suggest me a way to change dynamically the button style from bitmap to text and viceversa? I tried with m_BUTT_25.SetButtonStyle(BS_TEXT); m_BUTT_25.RedrawWindow(); and m_BUTT_25.SetButtonStyle(BS_BITMAP); m_BUTT_25.RedrawWindow(); but nothing seems to happen... :( I can instead change the button caption with SetWindowText: why is this? :confused: Thanks :), Marco.

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      Not all styles can be changed at runtime, this might very well be an example. A common method is to destroy and recreate the button. marcomars wrote: I can instead change the button caption with SetWindowText: why is this? Because the text is not a style.

      1 Reply Last reply
      0
      • M marcomars

        Can you suggest me a way to change dynamically the button style from bitmap to text and viceversa? I tried with m_BUTT_25.SetButtonStyle(BS_TEXT); m_BUTT_25.RedrawWindow(); and m_BUTT_25.SetButtonStyle(BS_BITMAP); m_BUTT_25.RedrawWindow(); but nothing seems to happen... :( I can instead change the button caption with SetWindowText: why is this? :confused: Thanks :), Marco.

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        Maybe you have to "detach" your object (text, icon, bmp) from the button first? "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix

        1 Reply Last reply
        0
        • M marcomars

          Can you suggest me a way to change dynamically the button style from bitmap to text and viceversa? I tried with m_BUTT_25.SetButtonStyle(BS_TEXT); m_BUTT_25.RedrawWindow(); and m_BUTT_25.SetButtonStyle(BS_BITMAP); m_BUTT_25.RedrawWindow(); but nothing seems to happen... :( I can instead change the button caption with SetWindowText: why is this? :confused: Thanks :), Marco.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          How about creating two buttons, one with text and the other with a bitmap? Disable/enable them accordingly. marcomars wrote: I can instead change the button caption with SetWindowText: why is this? Because that's the way it is supposed to work. Per MSDN: The SetWindowText function changes the text of the specified window's title bar (if it has one). If the specified window is a control (e.g., button), the text of the control is changed.


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          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