On Fri Jan 12 11:26:37 2024 +0000, Alex Henrie wrote:
Can you add a test please?
hi, a test have added !!
here is my demo on windows:
`#include <stdlib.h> #include <stdio.h> #include <Windows.h> #include <WinUser.h> #include <windef.h> #include <wingdi.h>
void main() { HDC hdc; HWND hwnd; HFONT hFont, hOldFont; LOGFONTA lf;
hwnd = CreateWindowExA(0,"static",NULL,WS_POPUP,500,20,800,800,0,0,0,NULL); if (!hwnd) printf("create window fail !!!\n"); hdc = GetDC(hwnd);
memset(&lf,0,sizeof(lf)); lf.lfCharSet = ANSI_CHARSET; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfWeight = FW_DONTCARE; lf.lfHeight = 0; lf.lfQuality = DEFAULT_QUALITY; lstrcpyA(lf.lfFaceName,"Arial");
SetMapMode(hdc,MM_TEXT); lf.lfHeight = 200 * 9 / 72; hFont = CreateFontIndirectA(&lf); if(!hFont) printf("create font fail !!!\n"); hOldFont = SelectObject(hdc, hFont);
ShowWindow(hwnd, SW_SHOW);
RECT rect = {0, 0, 319, 23}; DRAWTEXTPARAMS dtp; //static WCHAR teststr[] = L"企业同时开会数已达5场上限,当前正在限时免费使用不受限制。"; //static WCHAR teststr[] = L"a1b2c3d4f5g6h7i8j9A1B2C3D4F5G6H7I8J9 more tests for dtp."; //static WCHAR teststr[] = L" a1b2c3d4f5g6h7i8j9A1B2C3D4F5G6H7I8J9 more tests for dtp."; //static WCHAR teststr[] = L"a 1 b2c3d4f5g6h7i8j9A1B2C3D4F5G6H7I8J9 more tests for dtp."; //static WCHAR teststr[] = L"a 1\tb2c3d4f5g6h7i8j9A1B2C3D4F5G6H7I8J9 more tests for dtp."; static WCHAR teststr[] = { 'W','i','d','e',' ','c','h','a','r',' ', 's','t','r','i','n','g','\0' };
SetRect(&rect, 0, 0, 100, 25); memset(&dtp,0,sizeof(dtp)); dtp.cbSize = sizeof(dtp);
int ret = DrawTextExW(hdc, teststr, lstrlenW(teststr), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); printf("--->%d %d\n", dtp.uiLengthDrawn, ret); ret = DrawTextExW(hdc, L" a1b2c3", lstrlenW(L" a1b2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); printf("--->%d %d\n", dtp.uiLengthDrawn, ret); ret = DrawTextExW(hdc, L"a 1\tb2c3", lstrlenW(L"a 1\tb2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); printf("--->%d %d\n", dtp.uiLengthDrawn, ret);
system("pause"); DeleteObject(hFont); ReleaseDC(hwnd, hdc); DestroyWindow(hwnd);
}`