Skip to content

Commit 090eebb

Browse files
committed
0.10.0.22: Column auto-sizing now factors in dummy insert row correctly
1 parent 157facb commit 090eebb

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/sqlite-ce-edit/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BOOL WINAPI GetSaveFileNameW(CE_OPENFILENAME*);
8787
** Version
8888
**============================================================================*/
8989

90-
#define SQLITECEDIT_VERSION L"0.10.0.21"
90+
#define SQLITECEDIT_VERSION L"0.10.0.22"
9191

9292
/*============================================================================
9393
** Menu IDs

src/sqlite-ce-edit/grid.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,22 @@ void PopulateGrid(void) {
470470
headerWidth = ListView_GetColumnWidth(g_hwndGrid, j);
471471
if (contentWidth > headerWidth)
472472
ListView_SetColumnWidth(g_hwndGrid, j, contentWidth);
473+
/* In edit mode, ensure column fits placeholder hints */
474+
if (g_editMode && j < g_colMetaCount) {
475+
HDC hdc = GetDC(g_hwndGrid);
476+
if (hdc) {
477+
SIZE sz;
478+
int hintWidth, curWidth;
479+
const wchar_t *hint = g_colMeta[j].isAutoInc ? L"(auto)" :
480+
(!g_colMeta[j].notNull ? L"(null)" : L"");
481+
GetTextExtentPoint32W(hdc, hint, lstrlenW(hint), &sz);
482+
hintWidth = sz.cx + 12; /* padding */
483+
curWidth = ListView_GetColumnWidth(g_hwndGrid, j);
484+
if (hintWidth > curWidth)
485+
ListView_SetColumnWidth(g_hwndGrid, j, hintWidth);
486+
ReleaseDC(g_hwndGrid, hdc);
487+
}
488+
}
473489
}
474490
ListView_SetItemCount(g_hwndGrid, totalRows);
475491
}

0 commit comments

Comments
 (0)