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. Driving Ctatic::DrawItem

Driving Ctatic::DrawItem

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharptutorial
2 Posts 1 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    I have an owerdraw ComboBox When a user selects an Item I want to Display the Detail info I figure I could use the same Dialog for Background So for the 6 CStatic and Their 6 Labels I do ShowWindow(SW_HIDE) I saw the following post on how to drive DrawItem by Calling invalidate an the SetWindowText Getting owner draw child control to paint when calling SetWindowText - vc.mfc[^] So I create my own derived CStatic

    class MyStatic : public CStatic
    { DECLARE_DYNAMIC(MyStatic)
    public:
    MyStatic();
    ~MyStatic();

    void SetWindowText(LPSTR);
    void DrawItem(LPDRAWITEMSTRUCT pdis);
    

    };

    This my SSetWindowText

    void MyStatic::SetWindowText(LPSTR lpsz)
    {
    Invalidate();
    CStatic::SetWindowText(lpsz);

    }

    two bad things on the way to getting where I want 1) I get an exception in wincore.cpp at the retrun ::CallWindowProc

    RESULT CWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
    {
    if (m_pfnSuper != NULL)
    return ::CallWindowProc(m_pfnSuper, m_hWnd, nMsg, wParam, lParam);

    WNDPROC pfnWndProc;
    if ((pfnWndProc = \*GetSuperWndProcAddr()) == NULL)
    	return ::DefWindowProc(m\_hWnd, nMsg, wParam, lParam);
    else
    
    1. After the exception my Drawitem is called however ItemData doesn't have the String pointer and and is NULL Thanks
    F 1 Reply Last reply
    0
    • F ForNow

      I have an owerdraw ComboBox When a user selects an Item I want to Display the Detail info I figure I could use the same Dialog for Background So for the 6 CStatic and Their 6 Labels I do ShowWindow(SW_HIDE) I saw the following post on how to drive DrawItem by Calling invalidate an the SetWindowText Getting owner draw child control to paint when calling SetWindowText - vc.mfc[^] So I create my own derived CStatic

      class MyStatic : public CStatic
      { DECLARE_DYNAMIC(MyStatic)
      public:
      MyStatic();
      ~MyStatic();

      void SetWindowText(LPSTR);
      void DrawItem(LPDRAWITEMSTRUCT pdis);
      

      };

      This my SSetWindowText

      void MyStatic::SetWindowText(LPSTR lpsz)
      {
      Invalidate();
      CStatic::SetWindowText(lpsz);

      }

      two bad things on the way to getting where I want 1) I get an exception in wincore.cpp at the retrun ::CallWindowProc

      RESULT CWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
      {
      if (m_pfnSuper != NULL)
      return ::CallWindowProc(m_pfnSuper, m_hWnd, nMsg, wParam, lParam);

      WNDPROC pfnWndProc;
      if ((pfnWndProc = \*GetSuperWndProcAddr()) == NULL)
      	return ::DefWindowProc(m\_hWnd, nMsg, wParam, lParam);
      else
      
      1. After the exception my Drawitem is called however ItemData doesn't have the String pointer and and is NULL Thanks
      F Offline
      F Offline
      ForNow
      wrote on last edited by
      #2

      Didn't have a message map entry from my Derived CStatic also the text of the Static control isn't set in the itemData you have to a GetWindowText to get it with those two fixes everything worked

      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