1

カスタムのプログレスバーコントロールが必要です。たとえば、移動する斜線などを表示したり、プログレスバーコントロール内に画像を描画したりしますWebとカスタム描画のいくつかの例でリストビューと動的サブクラス化を検索しましたが、コードはペイントメソッドを呼び出しません。

public:
     BOOL SubclassWindow(HWND hWnd)
      {
          ATLASSERT(m_hWnd==NULL);
          ATLASSERT(::IsWindow(hWnd));
          BOOL bRet = CWindowImpl<CMyProgressControl, CProgressBarCtrl>::SubclassWindow(hWnd);
          return bRet;
       }

    BEGIN_MSG_MAP(CMyProgressControl)
      CHAIN_MSG_MAP(CCustomDraw<CMyProgressControl>)
   END_MSG_MAP()

   DWORD OnPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/)
    {        
        return  CDRF_NOTIFYITEMDRAW;
    }
     DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW lpNMCustomDraw)
    {
        NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( lpNMCustomDraw );

        // This is the prepaint stage for an item. Here's where we set the
        // item's text color. Our return value will tell Windows to draw the
        // item itself, but it will use the new color we set here for the background

        COLORREF crText;


            crText = RGB(200,200,255);

        // Store the color back in the NMLVCUSTOMDRAW struct.
        pLVCD->clrTextBk = crText;


        // Tell Windows to paint the control itself.
        return CDRF_DODEFAULT;
    }
4

1 に答える 1

1

引用したコードは機能を開始する機会がありません。NMLVCUSTOMDRAWリストビューコントロールに属しており、所有者が描画するようにコントロールをサブクラス化していますか?いいえ、このようには機能しません。

プログレスバーは単純なクラスであり、所有者による描画のカスタマイズはできません。代わりに、完全な裁量で視覚的な表現を使用して完全にカスタム制御を実装することをお勧めします。

カスタムプログレスバーウィンドウのスケルトンは、ここで検索できます:http: //tech.groups.yahoo.com/group/wtl/message/4814追加するMSG_WM_PAINTと、OnPaint希望どおりにペイントできます。

于 2012-10-19T19:38:46.503 に答える