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. Redraw a CStatic,create it using Create,but the function DrawItem doesn't been run

Redraw a CStatic,create it using Create,but the function DrawItem doesn't been run

Scheduled Pinned Locked Moved C / C++ / MFC
help
2 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.
  • M Offline
    M Offline
    Member 11147338
    wrote on last edited by
    #1

    the following are the related code,could someone can help me,

    void CXXXStatic::PreSubclassWindow()
    {
    // TODO: 在此添加专用代码和/或调用基类
    DWORD dwStyle = GetStyle();
    SetWindowLong(GetSafeHwnd(),GWL_STYLE,dwStyle | SS_OWNERDRAW);
    CStatic::PreSubclassWindow();

    }

    void CXXXStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
    {
    // TODO: 添加您的代码以绘制指定项
    CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

    }

    CXXXStatic m_Static;
    m_Static.Create("hello", WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(100, 100, 200, 200), this,0x0301);

    J 1 Reply Last reply
    0
    • M Member 11147338

      the following are the related code,could someone can help me,

      void CXXXStatic::PreSubclassWindow()
      {
      // TODO: 在此添加专用代码和/或调用基类
      DWORD dwStyle = GetStyle();
      SetWindowLong(GetSafeHwnd(),GWL_STYLE,dwStyle | SS_OWNERDRAW);
      CStatic::PreSubclassWindow();

      }

      void CXXXStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
      {
      // TODO: 添加您的代码以绘制指定项
      CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

      }

      CXXXStatic m_Static;
      m_Static.Create("hello", WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(100, 100, 200, 200), this,0x0301);

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      That is because SS_OWNERDRAW is not a bit value that can be O-red to the style but a masked value. Use

      SetWindowLong(GetSafeHwnd(),GWL_STYLE,( dwStyle & ~SS_TYPEMASK) | SS_OWNERDRAW);

      instead. Or better:

      ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW));

      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