@@ -353,10 +353,43 @@ void GridFindNext(void) {
353353 MessageBoxW (g_hwndMain , L"Text not found." , L"Find" , MB_OK );
354354}
355355
356+ /* Build placeholder hint for column: (auto), (TYPE null), (TYPE req), (TYPE) */
357+ static void GetPlaceholderHint (int col , wchar_t * buf , int buflen ) {
358+ ColumnMeta * cm ;
359+ const char * t ;
360+ wchar_t * p = buf ;
361+ wchar_t * end = buf + buflen - 1 ;
362+
363+ if (col >= g_colMetaCount ) { buf [0 ] = '\0' ; return ; }
364+ cm = & g_colMeta [col ];
365+
366+ if (cm -> isAutoInc ) {
367+ lstrcpyW (buf , L"(auto)" );
368+ return ;
369+ }
370+
371+ * p ++ = '(' ;
372+ t = cm -> type ;
373+ /* Shorten INTEGER to INT */
374+ if (t [0 ]== 'I' && t [1 ]== 'N' && t [2 ]== 'T' && t [3 ]== 'E' && t [4 ]== 'G' && t [5 ]== 'E' && t [6 ]== 'R' && t [7 ]== '\0' ) {
375+ * p ++ = 'I' ; * p ++ = 'N' ; * p ++ = 'T' ;
376+ } else {
377+ while (* t && p < end - 6 ) * p ++ = (wchar_t )* t ++ ;
378+ }
379+ /* Add null/req suffix */
380+ if (!cm -> notNull ) {
381+ * p ++ = ' ' ; * p ++ = 'n' ; * p ++ = 'u' ; * p ++ = 'l' ; * p ++ = 'l' ;
382+ } else if (!cm -> hasDefault ) {
383+ * p ++ = ' ' ; * p ++ = 'r' ; * p ++ = 'e' ; * p ++ = 'q' ;
384+ }
385+ * p ++ = ')' ; * p = '\0' ;
386+ }
387+
356388void OnGridGetDispInfo (NMLVDISPINFOW * pdi ) {
357389 int row , dataRow , col , dataCol ;
358390 char * val ;
359391 static wchar_t wbuf [256 ];
392+ static wchar_t hintbuf [32 ];
360393 int numDisplayCols ;
361394
362395 if (!(pdi -> item .mask & LVIF_TEXT )) return ;
@@ -380,18 +413,9 @@ void OnGridGetDispInfo(NMLVDISPINFOW *pdi) {
380413 MultiByteToWideChar (CP_ACP , 0 , g_pendingValues [col ], -1 , wbuf , 256 );
381414 pdi -> item .pszText = wbuf ;
382415 }
383- } else if (col < g_colMetaCount ) {
384- ColumnMeta * cm = & g_colMeta [col ];
385- if (cm -> isAutoInc ) {
386- pdi -> item .pszText = L"(auto)" ;
387- } else if (!cm -> notNull && !cm -> hasDefault ) {
388- /* Nullable without default - will be NULL if not filled */
389- pdi -> item .pszText = L"(null)" ;
390- } else {
391- pdi -> item .pszText = L"" ;
392- }
393416 } else {
394- pdi -> item .pszText = L"" ;
417+ GetPlaceholderHint (col , hintbuf , 32 );
418+ pdi -> item .pszText = hintbuf ;
395419 }
396420 return ;
397421 }
@@ -509,8 +533,8 @@ void PopulateGrid(void) {
509533 if (hdc ) {
510534 SIZE sz ;
511535 int hintWidth , curWidth ;
512- const wchar_t * hint = g_colMeta [ j ]. isAutoInc ? L"(auto)" :
513- (! g_colMeta [ j ]. notNull ? L"(null)" : L"" );
536+ wchar_t hint [ 32 ];
537+ GetPlaceholderHint ( j , hint , 32 );
514538 GetTextExtentPoint32W (hdc , hint , lstrlenW (hint ), & sz );
515539 hintWidth = sz .cx + 12 ; /* padding */
516540 curWidth = ListView_GetColumnWidth (g_hwndGrid , j );
0 commit comments