이 example은 기본적으로 텍스트의 가운데 가운데 맞춤으로 사용됩니다. 사용하는 형식 (NoPrefix | WordBreak | TextBoxControl | EndEllipsis)은 기본적으로 왼쪽 정렬됩니다. 따라서 광선 클리핑을 수정하려면 광선 경계를 확장해야합니다.
다음은 수정 된 샘플입니다.
public void DrawTextOnGlass(IntPtr hwnd, String text, Font font, Rectangle bounds, int glowSize){
//...
RECT glowRect = new RECT();
RECT textRect = new RECT();
glowRect.left = bounds.Left - glowSize;
glowRect.right = bounds.Right + glowSize;
glowRect.top = bounds.Top - glowSize;
glowRect.bottom = bounds.Bottom + glowSize;
textRect.left = glowSize;
textRect.top = glowSize;
textRect.right = glowRect.right - glowRect.left;
textRect.bottom = glowRect.bottom - glowRect.top;
//...
int uFormat = (int)(TextFormatFlags.NoPrefix
| TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl | TextFormatFlags.EndEllipsis);
//...
DrawThemeTextEx(renderer.Handle, Memdc, 0, 0, text, -1, uFormat, ref textRect, ref dttOpts);
BitBlt(destdc, glowRect.left, glowRect.top,
glowRect.right - glowRect.left,
glowRect.bottom - glowRect.top,
Memdc, 0, 0, SRCCOPY);
//...
}
결과가 완벽합니다. – Velcro