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. I subclassed a CStatic...

I subclassed a CStatic...

Scheduled Pinned Locked Moved C / C++ / MFC
comquestion
10 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    ... and added the SS_OWNERDRAW style, but I never get a call to DrawItem. Why? :confused: My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

    P O 2 Replies Last reply
    0
    • L Lost User

      ... and added the SS_OWNERDRAW style, but I never get a call to DrawItem. Why? :confused: My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

      P Offline
      P Offline
      palbano
      wrote on last edited by
      #2

      show yur code where you subclass it.

      "No matter where you go, there your are..." - Buckaoo Banzi

      -pete

      L 2 Replies Last reply
      0
      • P palbano

        show yur code where you subclass it.

        "No matter where you go, there your are..." - Buckaoo Banzi

        -pete

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3
        BOOL CMyStatic::PreCreateWindow(CREATESTRUCT& cs)
        {
         if (!CStatic::PreCreateWindow(cs)) { return FALSE; }
         cs.style |= SS_OWNERDRAW;
         return TRUE;
        }
        
        void CMyStatic::PreSubclassWindow() 
        {
         CStatic::PreSubclassWindow();
         ModifyStyle(0, SS_OWNERDRAW);
        }
        

        I did both just to make sure. Winspector Spy shows SS_OWNERDRAW style in the window styles, but no call to DrawItem occurs. My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

        P 1 Reply Last reply
        0
        • P palbano

          show yur code where you subclass it.

          "No matter where you go, there your are..." - Buckaoo Banzi

          -pete

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

          does it make any difference that the control is on a dialogbar and not a dialog? My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

          P 1 Reply Last reply
          0
          • L Lost User

            does it make any difference that the control is on a dialogbar and not a dialog? My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

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

            Good question, i remember there are issues with toolbars and messages not getting routed. i think that the solution is to override PreTranslateMessage and handle them ur self. Did you watch messages with spy and see if the frame or dialog is receiving the DRAWITEM for that window? -pete

            "No matter where you go, there your are..." - Buckaoo Banzi

            -pete

            L 2 Replies Last reply
            0
            • P palbano

              Good question, i remember there are issues with toolbars and messages not getting routed. i think that the solution is to override PreTranslateMessage and handle them ur self. Did you watch messages with spy and see if the frame or dialog is receiving the DRAWITEM for that window? -pete

              "No matter where you go, there your are..." - Buckaoo Banzi

              -pete

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

              No WM_DRAWITEM messages to be seen anywhere... not on the frame, not on the dialogbar, and not on the static control itself. Now, I have no clue about this. The static shows SS_OWNERDRAW style though... My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

              1 Reply Last reply
              0
              • P palbano

                Good question, i remember there are issues with toolbars and messages not getting routed. i think that the solution is to override PreTranslateMessage and handle them ur self. Did you watch messages with spy and see if the frame or dialog is receiving the DRAWITEM for that window? -pete

                "No matter where you go, there your are..." - Buckaoo Banzi

                -pete

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

                i give up. I implemented OnPaint() to draw it. I wanted to draw a focus rect, if the control got input focus, but I do not know how to do it when I draw it on OnPaint(). Any ideas? My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

                P 1 Reply Last reply
                0
                • L Lost User
                  BOOL CMyStatic::PreCreateWindow(CREATESTRUCT& cs)
                  {
                   if (!CStatic::PreCreateWindow(cs)) { return FALSE; }
                   cs.style |= SS_OWNERDRAW;
                   return TRUE;
                  }
                  
                  void CMyStatic::PreSubclassWindow() 
                  {
                   CStatic::PreSubclassWindow();
                   ModifyStyle(0, SS_OWNERDRAW);
                  }
                  

                  I did both just to make sure. Winspector Spy shows SS_OWNERDRAW style in the window styles, but no call to DrawItem occurs. My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

                  P Offline
                  P Offline
                  palbano
                  wrote on last edited by
                  #8

                  what about the code creating the instance of CMyStatic on the toolbar?

                  "No matter where you go, there your are..." - Buckaoo Banzi

                  -pete

                  1 Reply Last reply
                  0
                  • L Lost User

                    i give up. I implemented OnPaint() to draw it. I wanted to draw a focus rect, if the control got input focus, but I do not know how to do it when I draw it on OnPaint(). Any ideas? My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

                    P Offline
                    P Offline
                    palbano
                    wrote on last edited by
                    #9

                    Well i don't believe CStatic get input focus. Perhaps you just need a custom window so derive from CWnd. Then do ur OnPaint handler. For focus rect drawing look at CDC::Draw3dRect/DrawEdge/DrawState Something there should do the trick. -pete

                    "No matter where you go, there your are..." - Buckaoo Banzi

                    -pete

                    1 Reply Last reply
                    0
                    • L Lost User

                      ... and added the SS_OWNERDRAW style, but I never get a call to DrawItem. Why? :confused: My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

                      O Offline
                      O Offline
                      Oliver Anhuth
                      wrote on last edited by
                      #10

                      WM_DRAWITEM is not sent to the owner draw control but to the owner window (the dialog it is on) of the control. No need to subclass... Oliver

                      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