Skip to content

Commit 77e52f8

Browse files
committed
0.9.0.46: New universal message passing system for printing text output to the Results pane
1 parent 38f22dd commit 77e52f8

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

src/sqlite-ce-edit/fileops.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,19 +1588,11 @@ void DoRestoreDatabase(void) {
15881588

15891589
/* Reset UI to clean state */
15901590
ClearEditMode();
1591-
g_lastResultRows = 0; /* No rowset - prevents grid toggle until next query */
1592-
SendMessage(g_hwndMain, WM_COMMAND, IDM_VIEWRESULT, 0); /* Switch to results view */
1593-
/* Show text view without changing grid preference (like no-rowset queries) */
1594-
if (g_gridView && g_hwndGrid) {
1595-
ShowWindow(g_hwndGrid, SW_HIDE);
1596-
ShowWindow(g_hwndResult, SW_SHOW);
1597-
}
1598-
SendMessage(g_hwndCB, TB_ENABLEBUTTON, IDM_EXECATCURSOR, FALSE);
15991591
if (ok) {
1600-
SetWindowTextW(g_hwndResult, L"Database restored successfully.");
1592+
ShowResultMessage(L"Database restored successfully.", 1);
16011593
SendMessageW(g_hwndStatus, SB_SETTEXTW, 1, (LPARAM)L"Database restored");
16021594
} else {
1603-
SetWindowTextW(g_hwndResult, L"Restore failed.");
1595+
ShowResultMessage(L"Restore failed.", 1);
16041596
MessageBoxW(g_hwndMain, L"Restore failed", L"Error", MB_OK | MB_ICONERROR);
16051597
SendMessageW(g_hwndStatus, SB_SETTEXTW, 1, (LPARAM)L"Restore failed");
16061598
}

src/sqlite-ce-edit/globals.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,16 @@ BOOL WINAPI GetSaveFileNameW(CE_OPENFILENAME*);
7878
#define VIEW_DETAILS 3
7979
#endif
8080

81+
/* Application view modes for SwitchView() */
82+
#define VIEW_QUERY 0
83+
#define VIEW_RESULT 1
84+
#define VIEW_SCHEMA 2
85+
8186
/*============================================================================
8287
** Version
8388
**============================================================================*/
8489

85-
#define SQLITECEDIT_VERSION L"0.9.0.42"
90+
#define SQLITECEDIT_VERSION L"0.9.0.46"
8691

8792
/*============================================================================
8893
** Menu IDs
@@ -260,6 +265,7 @@ void ClearOutput(void);
260265
void Output(const char *sz);
261266
void OutputLine(const char *sz);
262267
void FlushOutput(void);
268+
void ShowResultMessage(LPCWSTR msg, int clear);
263269

264270
/*============================================================================
265271
** Function Declarations - Editor (editor.c)

src/sqlite-ce-edit/output.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,35 @@ void FlushOutput(void) {
2929
LocalFree(wz);
3030
}
3131
}
32+
33+
void ShowResultMessage(LPCWSTR msg, int clear) {
34+
if (clear) {
35+
g_lastResultRows = 0;
36+
SetWindowTextW(g_hwndResult, msg);
37+
} else {
38+
/* Append to existing text */
39+
int existingLen = GetWindowTextLengthW(g_hwndResult);
40+
int msgLen = lstrlenW(msg);
41+
wchar_t *buf = (wchar_t *)LocalAlloc(LMEM_FIXED, (existingLen + msgLen + 3) * sizeof(wchar_t));
42+
if (buf) {
43+
GetWindowTextW(g_hwndResult, buf, existingLen + 1);
44+
if (existingLen > 0) {
45+
buf[existingLen++] = '\r';
46+
buf[existingLen++] = '\n';
47+
}
48+
lstrcpyW(buf + existingLen, msg);
49+
SetWindowTextW(g_hwndResult, buf);
50+
LocalFree(buf);
51+
}
52+
}
53+
/* Switch to text results view */
54+
SwitchView(VIEW_RESULT);
55+
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWQUERY, FALSE);
56+
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWRESULT, TRUE);
57+
SendMessage(g_hwndCB, TB_CHECKBUTTON, IDM_VIEWSCHEMA, FALSE);
58+
if (g_gridView && g_hwndGrid) {
59+
ShowWindow(g_hwndGrid, SW_HIDE);
60+
ShowWindow(g_hwndResult, SW_SHOW);
61+
}
62+
SendMessage(g_hwndCB, TB_ENABLEBUTTON, IDM_EXECATCURSOR, FALSE);
63+
}

0 commit comments

Comments
 (0)