Skip to content

Commit f460e2a

Browse files
committed
0.7.0.13: Fixed grid view state management when entering/exiting table data edit mode
1 parent dd76b49 commit f460e2a

4 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/sqlite-ce-edit/execute.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,17 @@ void ExecuteSQL(const char *sql) {
275275
sqlite_progress_handler(g_db, 0, NULL, NULL);
276276

277277
/* Switch to results */
278+
if (g_gridView && g_hwndGrid)
279+
SendMessage(g_hwndGrid, WM_SETREDRAW, FALSE, 0);
278280
SwitchView(1);
279281
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWQUERY, FALSE);
280282
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWRESULT, TRUE);
281283
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWSCHEMA, FALSE);
284+
if (g_gridView) PopulateGrid();
285+
if (g_gridView && g_hwndGrid) {
286+
SendMessage(g_hwndGrid, WM_SETREDRAW, TRUE, 0);
287+
InvalidateRect(g_hwndGrid, NULL, TRUE);
288+
}
282289
}
283290

284291
void ExecuteQuery(void) {
@@ -613,10 +620,18 @@ void ExecuteQuery(void) {
613620

614621
/* Switch to results view (unless error - stay in query to show cursor) */
615622
if (!hadError) {
623+
/* Suppress redraw during view switch to avoid flicker */
624+
if (g_gridView && g_hwndGrid)
625+
SendMessage(g_hwndGrid, WM_SETREDRAW, FALSE, 0);
616626
SwitchView(1);
617627
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWQUERY, FALSE);
618628
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWRESULT, TRUE);
619629
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWSCHEMA, FALSE);
630+
if (g_gridView) PopulateGrid();
631+
if (g_gridView && g_hwndGrid) {
632+
SendMessage(g_hwndGrid, WM_SETREDRAW, TRUE, 0);
633+
InvalidateRect(g_hwndGrid, NULL, TRUE);
634+
}
620635
RefreshSchema(); /* Update schema in case CREATE/DROP was executed */
621636
}
622637
}

src/sqlite-ce-edit/globals.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ int g_recentQueryCount = 0;
7272
/* Grid edit mode state */
7373
int g_editMode = 0; /* 1 = grid is editable */
7474
char g_editTableName[128] = {0}; /* Table being edited */
75+
int g_gridViewBeforeEdit = 0; /* Saved g_gridView state before edit mode */

src/sqlite-ce-edit/globals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ BOOL WINAPI GetSaveFileNameW(CE_OPENFILENAME*);
8282
** Version
8383
**============================================================================*/
8484

85-
#define SQLITECEDIT_VERSION L"0.7.0.9"
85+
#define SQLITECEDIT_VERSION L"0.7.0.13"
8686

8787
/*============================================================================
8888
** Menu IDs
@@ -235,6 +235,7 @@ extern int g_recentQueryCount;
235235
/* Grid edit mode state */
236236
extern int g_editMode;
237237
extern char g_editTableName[128];
238+
extern int g_gridViewBeforeEdit;
238239

239240
/*============================================================================
240241
** Function Declarations - Output (output.c)

src/sqlite-ce-edit/schema.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,19 @@ void OnSchemaExpanding(NMTREEVIEWW *pnm) {
413413
**============================================================================*/
414414

415415
void ClearEditMode(void) {
416+
if (!g_editMode) return;
417+
416418
g_editMode = 0;
417419
g_editTableName[0] = '\0';
420+
421+
/* Restore previous grid/text view state */
422+
g_gridView = g_gridViewBeforeEdit;
423+
ShowWindow(g_hwndResult, g_gridView ? SW_HIDE : SW_SHOW);
424+
if (g_hwndGrid) ShowWindow(g_hwndGrid, g_gridView ? SW_SHOW : SW_HIDE);
425+
426+
/* Re-enable the grid toggle button */
427+
SendMessage(g_hwndCB, TB_ENABLEBUTTON, IDM_EXECATCURSOR, TRUE);
428+
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_EXECATCURSOR, g_gridView);
418429
}
419430

420431
/*============================================================================
@@ -488,6 +499,9 @@ void OpenTableForEditing(const char *tablename) {
488499
}
489500
sqlite_free_table(results);
490501

502+
/* Save current grid view state before entering edit mode */
503+
g_gridViewBeforeEdit = g_gridView;
504+
491505
/* Set edit mode */
492506
g_editMode = 1;
493507
s = tablename;
@@ -510,6 +524,10 @@ void OpenTableForEditing(const char *tablename) {
510524
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWQUERY, FALSE);
511525
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWRESULT, TRUE);
512526
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWSCHEMA, FALSE);
527+
528+
/* Disable grid/text toggle button while in edit mode */
529+
SendMessage(g_hwndCB, TB_ENABLEBUTTON, IDM_EXECATCURSOR, FALSE);
530+
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_EXECATCURSOR, TRUE);
513531
} else {
514532
if (errmsg) {
515533
OutputLine(errmsg);

0 commit comments

Comments
 (0)