@@ -256,6 +256,7 @@ class TControl : public TObject
256256
257257 /* Non-visual database components (CT_DBFTABLE etc.) */
258258 char FFileName[260 ];
259+ HBITMAP FBitmap;
259260 char FRDD[16 ];
260261 BOOL FActive;
261262 BOOL FTransparent;
@@ -1035,4 +1036,102 @@ class TComponentPalette : public TControl
10351036 */
10361037TControl * CreateControlByType ( BYTE bType );
10371038
1039+ /* Unicode / UTF-8 helper functions for native Emoji rendering */
1040+ #include < malloc.h>
1041+ #include < windows.h>
1042+
1043+ inline void SetWindowTextDetectUTF8 ( HWND hWnd, const char * szText )
1044+ {
1045+ if ( !hWnd || !szText ) return ;
1046+ int nLen = (int ) strlen ( szText );
1047+ int nWideLen = MultiByteToWideChar ( CP_UTF8, MB_ERR_INVALID_CHARS, szText, nLen, NULL , 0 );
1048+ if ( nWideLen > 0 )
1049+ {
1050+ WCHAR * wbuf = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1051+ MultiByteToWideChar ( CP_UTF8, 0 , szText, nLen, wbuf, nWideLen );
1052+ wbuf[nWideLen] = 0 ;
1053+ SetWindowTextW ( hWnd, wbuf );
1054+ free ( wbuf );
1055+ }
1056+ else
1057+ {
1058+ nWideLen = MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, NULL , 0 );
1059+ if ( nWideLen > 0 )
1060+ {
1061+ WCHAR * wbuf = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1062+ MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, wbuf, nWideLen );
1063+ wbuf[nWideLen] = 0 ;
1064+ SetWindowTextW ( hWnd, wbuf );
1065+ free ( wbuf );
1066+ }
1067+ else
1068+ {
1069+ SetWindowTextA ( hWnd, szText );
1070+ }
1071+ }
1072+ }
1073+
1074+ inline void DrawTextDetectUTF8 ( HDC hDC, const char * szText, int nCount, RECT * lpRect, UINT uFormat )
1075+ {
1076+ if ( !szText ) return ;
1077+ int nLen = (nCount < 0 ) ? (int ) strlen ( szText ) : nCount;
1078+ int nWideLen = MultiByteToWideChar ( CP_UTF8, MB_ERR_INVALID_CHARS, szText, nLen, NULL , 0 );
1079+ if ( nWideLen > 0 )
1080+ {
1081+ WCHAR * wbuf = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1082+ MultiByteToWideChar ( CP_UTF8, 0 , szText, nLen, wbuf, nWideLen );
1083+ wbuf[nWideLen] = 0 ;
1084+ DrawTextW ( hDC, wbuf, nWideLen, lpRect, uFormat );
1085+ free ( wbuf );
1086+ }
1087+ else
1088+ {
1089+ nWideLen = MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, NULL , 0 );
1090+ if ( nWideLen > 0 )
1091+ {
1092+ WCHAR * wbuf = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1093+ MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, wbuf, nWideLen );
1094+ wbuf[nWideLen] = 0 ;
1095+ DrawTextW ( hDC, wbuf, nWideLen, lpRect, uFormat );
1096+ free ( wbuf );
1097+ }
1098+ else
1099+ {
1100+ DrawTextA ( hDC, szText, nCount, lpRect, uFormat );
1101+ }
1102+ }
1103+ }
1104+
1105+ inline HWND CreateWindowExDetectUTF8 ( DWORD dwExStyle, const char * szClass, const char * szText, DWORD dwStyle,
1106+ int x, int y, int nWidth, int nHeight, HWND hParent, HMENU hMenu, HINSTANCE hInst, LPVOID lpParam )
1107+ {
1108+ WCHAR wClass[128 ] = {0 };
1109+ MultiByteToWideChar ( CP_ACP, 0 , szClass, -1 , wClass, 128 );
1110+ WCHAR * wText = NULL ;
1111+ if ( szText )
1112+ {
1113+ int nLen = (int ) strlen ( szText );
1114+ int nWideLen = MultiByteToWideChar ( CP_UTF8, MB_ERR_INVALID_CHARS, szText, nLen, NULL , 0 );
1115+ if ( nWideLen > 0 )
1116+ {
1117+ wText = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1118+ MultiByteToWideChar ( CP_UTF8, 0 , szText, nLen, wText, nWideLen );
1119+ wText[nWideLen] = 0 ;
1120+ }
1121+ else
1122+ {
1123+ nWideLen = MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, NULL , 0 );
1124+ if ( nWideLen > 0 )
1125+ {
1126+ wText = (WCHAR *) malloc ( (nWideLen + 1 ) * sizeof (WCHAR) );
1127+ MultiByteToWideChar ( CP_ACP, 0 , szText, nLen, wText, nWideLen );
1128+ wText[nWideLen] = 0 ;
1129+ }
1130+ }
1131+ }
1132+ HWND hWnd = CreateWindowExW ( dwExStyle, wClass, wText, dwStyle, x, y, nWidth, nHeight, hParent, hMenu, hInst, lpParam );
1133+ if ( wText ) free ( wText );
1134+ return hWnd;
1135+ }
1136+
10381137#endif /* _HBIDE_H_ */
0 commit comments