1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#ifndef WIDE_DEFINED
typedef wchar_t wide;
#define WIDE_DEFINED
#endif
typedef struct zxCHAR_struct
{
char* m_text;
uint m_len;
uint m_full;
} zxCHAR;
typedef struct zxWIDE_struct
{
wide* m_text;
uint m_len;
uint m_full;
} zxWIDE;
#ifdef UNICODE
typedef wide zxChar;
#define zxTEXT zxWIDE
#else
typedef char zxChar;
#define zxTEXT zxCHAR
#endif
uint zx_mswSetText( HWND hdl, zxTEXT* text, int line, int pos, HBRUSH bg )
{
RECT cRect = {0}, rect = {0};
POINT pt;
TEXTMETRIC tm;
HDC dc = GetDC( NULL );
if ( !dc )
return 0u;
GetWindowRect( hdl, &rect );
GetClientRect( hdl, &cRect );
pt.x = ( rect.right - rect.left ) - cRect.right;
pt.y = ( rect.bottom - rect.top ) - cRect.bottom;
rect.left += pt.x;
rect.right -= pt.x;
rect.top += pt.y;
rect.bottom -= pt.y;
GetTextMetrics( dc, &tm );
SetCaretPos( ( pos * tm.tmAveCharWidth ) - ( pt.x >> 1),
( line * tm.tmHeight ) + ( pt.y >> 1 ) );
FillRect( dc, &rect, bg );
DrawText( dc, text->m_text, text->m_len, &rect,
DT_LEFT | DT_SINGLELINE | DT_END_ELLIPSIS | DT_VCENTER );
ReleaseDC( NULL, dc );
return 1u;
}
|