C / C ++ Duilibカスタムコントロール

1.現在のニーズに応じて対応するコントロールを継承します。これにより、繰り返しの開発が削減されます。

通常、書き込みにはDoPaintを継承します。最上位レイヤーに表示する必要がある場合は、DoPostPaint()を継承する必要があります。

たとえば、画像の回転表示を読み、GDI +と連携し、Gdiplus :: Bitmapのコンストラクターに注意します。この場合、PNGはPixelFormat32bppPARGBを使用します。

bool RotateAnimation::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
		Gdiplus::PointF centerPos(m_rcItem.left + GetWidth()/ 2, m_rcItem.top + GetHeight()/ 2);

		Gdiplus::Graphics graphics(hDC);
		//graphics.SetSmoothingMode(SmoothingModeAntiAlias);

		graphics.TranslateTransform(centerPos.X, centerPos.Y);
		graphics.RotateTransform(m_fCurAngle);
		graphics.TranslateTransform(-centerPos.X, -centerPos.Y);

		const TImageInfo* imgInfo = GetManager()->GetImageEx(m_diBk.sImageName);
		BITMAP bmp;
		GetObject(imgInfo->hBitmap, sizeof(BITMAP), &bmp);		
		Gdiplus::Bitmap gdi_bmp(imgInfo->nX, imgInfo->nY, imgInfo->nX * 4, PixelFormat32bppPARGB, (BYTE*)bmp.bmBits);
	
		graphics.DrawImage(&gdi_bmp, m_rcItem.left, m_rcItem.top, GetWidth(), GetHeight());
		return true;
	}	
}

DoPostPaintを詳しく見てみましょう。まず、m_aPostPaintControls配列を追加します。すべてのコントロールがペイントされた後、最後に呼び出されます。したがって、DoPaintよりも最上位にあります。

Duilibのソースコードを見ると、
ここに画像の説明を挿入します
powered by:小さなカメが大きなカメの後ろにあることがわかります
その他の記事:https//blog.csdn.net/what951006

おすすめ

転載: blog.csdn.net/what951006/article/details/88601698