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. Problem in Owner Draw Button

Problem in Owner Draw Button

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
6 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.
  • P Offline
    P Offline
    Parthi_Appu
    wrote on last edited by
    #1

    Hi All, I derived a class from CButton and I'm creating pointers with style BS_OWNERDRAW. This works fine if i give style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW. But now i want to custom draw my Radio Button, i giving style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW|BS_AUTORADIOBUTTON. But my DrawItem method is not getting called...if remove the BS_AUTORADIOBUTTON style my DrawItem method is called.. Why is this happing?... How can i custom draw my button as radio button.. Thanx

    Do your Duty and Don't expect the Result

    P 1 Reply Last reply
    0
    • P Parthi_Appu

      Hi All, I derived a class from CButton and I'm creating pointers with style BS_OWNERDRAW. This works fine if i give style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW. But now i want to custom draw my Radio Button, i giving style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW|BS_AUTORADIOBUTTON. But my DrawItem method is not getting called...if remove the BS_AUTORADIOBUTTON style my DrawItem method is called.. Why is this happing?... How can i custom draw my button as radio button.. Thanx

      Do your Duty and Don't expect the Result

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      http://msdn2.microsoft.com/en-us/library/ms673347.aspx[^] [quote] BS_OWNERDRAW     Creates an owner-drawn button. The owner window receives a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles. [/quote]

      P 1 Reply Last reply
      0
      • P PJ Arends

        http://msdn2.microsoft.com/en-us/library/ms673347.aspx[^] [quote] BS_OWNERDRAW     Creates an owner-drawn button. The owner window receives a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles. [/quote]

        P Offline
        P Offline
        Parthi_Appu
        wrote on last edited by
        #3

        Hi Arends, Thanx.. actually i refered Jan'2005 MSDN.. it says..

        Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.

        Now i'm facing another problem, even though i set the checked state by SetCheck(BST_CHECKED), i'm not getting the BST_CHECKED value while i'm using GetCheck().. Any Idea... Thanx again..

        Do your Duty and Don't expect the Result

        H 1 Reply Last reply
        0
        • P Parthi_Appu

          Hi Arends, Thanx.. actually i refered Jan'2005 MSDN.. it says..

          Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.

          Now i'm facing another problem, even though i set the checked state by SetCheck(BST_CHECKED), i'm not getting the BST_CHECKED value while i'm using GetCheck().. Any Idea... Thanx again..

          Do your Duty and Don't expect the Result

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          If you run this code do you get any change or its like your problem CButton m_Button; myButton.Create("Test", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,23), this, 1); m_Button.SetCheck(BST_CHECKED);


          WhiteSky


          P 1 Reply Last reply
          0
          • H Hamid Taebi

            If you run this code do you get any change or its like your problem CButton m_Button; myButton.Create("Test", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,23), this, 1); m_Button.SetCheck(BST_CHECKED);


            WhiteSky


            P Offline
            P Offline
            Parthi_Appu
            wrote on last edited by
            #5

            Hi Whitesky, The above code will work fine.. My problem is i have to draw a custom option(Radio) button. So i derived a class from CButton and i override the DrawItem method... As per MSDN we cannot combine any other style with BS_OWNERDRAW. Always i'm getting BST_UNCHECKED, so i cannot able to draw the checked radio. in DrawItem, DRAWITEMSTRUCT::itemState has no ODS_CHECKED flag and also if i use the GetCheck() API it returns BST_UNCHECKED.

            Do your Duty and Don't expect the Result

            H 1 Reply Last reply
            0
            • P Parthi_Appu

              Hi Whitesky, The above code will work fine.. My problem is i have to draw a custom option(Radio) button. So i derived a class from CButton and i override the DrawItem method... As per MSDN we cannot combine any other style with BS_OWNERDRAW. Always i'm getting BST_UNCHECKED, so i cannot able to draw the checked radio. in DrawItem, DRAWITEMSTRUCT::itemState has no ODS_CHECKED flag and also if i use the GetCheck() API it returns BST_UNCHECKED.

              Do your Duty and Don't expect the Result

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Maybe its not good way but its possible if you use of DrawItem you can imitation behavior of checkbox for radio button (once I tried many years ago with three buttons(checkbox)and it worked)


              WhiteSky


              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