diff --git a/resources/pinned_results.png b/resources/pinned_results.png new file mode 100644 index 0000000..9731613 Binary files /dev/null and b/resources/pinned_results.png differ diff --git a/src/dialogs.cpp b/src/dialogs.cpp index d229365..c254aae 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -1466,6 +1466,8 @@ namespace dialogs { DialogBoxParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_ROW), hWnd, (DLGPROC)&cbDlgRow, MAKELPARAM(ROW_ADD, 0)); int currRow = ListView_GetNextItem(hListWnd, -1, LVNI_SELECTED); SendMessage(hWnd, WMU_SET_CURRENT_CELL, currRow, currCol); + + ListView_SetSelectionMark(hListWnd, currRow); } if (cmd == IDM_ROW_REFRESH) @@ -1560,7 +1562,9 @@ namespace dialogs { int currCol = (int)(LONG_PTR)GetProp(hWnd, TEXT("CURRENTCOLUMN")); if (firstRow - 1 > 0) ListView_SetItemState (hListWnd, firstRow - 1, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); - PostMessage(hWnd, WMU_SET_CURRENT_CELL, MAX(0, firstRow - 1), currCol); + int currRow = MAX(0, firstRow - 1); + PostMessage(hWnd, WMU_SET_CURRENT_CELL, currRow, currCol); + PostMessage(hListWnd, LVM_SETSELECTIONMARK, 0, currRow); } else { showDbError(hWnd); } @@ -2435,6 +2439,7 @@ namespace dialogs { vCount += colCount + 1; datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte)); SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount)); + SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes); } int rowNo = mode == ROW_ADD ? ListView_GetItemCount(hListWnd) : currRow; @@ -2472,6 +2477,9 @@ namespace dialogs { if (mode == ROW_EDIT) SendMessage(hWnd, WMU_SET_DLG_ROW_DATA, 0, 0); SetFocus(GetDlgItem(hColumnsWnd, IDC_ROW_EDIT + 1)); + + for (int i = 1; prefs::get("clear-values") && (mode == ROW_ADD) && (i <= colCount); i++) + SetDlgItemText(hColumnsWnd, IDC_ROW_EDIT + i, TEXT("")); } else showDbError(hWnd); @@ -2488,9 +2496,6 @@ namespace dialogs { if (values8[i]) delete [] values8[i]; } - - for (int i = 1; prefs::get("clear-values") && (mode == ROW_ADD) && (i <= colCount); i++) - SetDlgItemText(hColumnsWnd, IDC_ROW_EDIT + i, TEXT("")); } if (wParam == IDC_DLG_CANCEL || wParam == IDCANCEL) diff --git a/src/main.cpp b/src/main.cpp index ca0d027..7537697 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2272,6 +2272,11 @@ LRESULT CALLBACK cbMainWindow (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam } } + if (kd->wVKey == 0x50) { // Ctrl + P + SendMessage(hWnd, WM_COMMAND, IDM_RESULT_PREVIEW, 0); + return 0; + } + bool isNum = kd->wVKey >= 0x31 && kd->wVKey <= 0x39; bool isNumPad = kd->wVKey >= 0x61 && kd->wVKey <= 0x69; if ((isNum || isNumPad) && GetKeyState(VK_CONTROL)) // Ctrl + 1-9 @@ -5897,14 +5902,6 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) { ListView_SetColumn(hListWnd, colNo, &lvc); } - int vCount = (colCount + 1) * rowCount; - SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount)); - datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte)); - SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes); - - - SetProp(hListWnd, TEXT("ORDERBY"), new int(0)); - ListView_SetExtendedListViewStyle(hListWnd, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_AUTOSIZECOLUMNS | LVS_EX_LABELTIP); if ((WNDPROC)GetWindowLongPtr(hListWnd, GWLP_WNDPROC) != cbNewListView) SetProp(hListWnd, TEXT("WNDPROC"), (HANDLE)SetWindowLongPtr(hListWnd, GWLP_WNDPROC, (LONG_PTR)&cbNewListView)); @@ -5918,28 +5915,45 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) { delete [] err16; if (!isVirtual) { + TCHAR rowLength16[64]; + _sntprintf(rowLength16, 63, TEXT("%i"), _tcslen(msg16)); LVITEM lvi = {0}; lvi.mask = LVIF_TEXT; + lvi.iItem = rowNo; lvi.iSubItem = 0; - lvi.iItem = 0; + lvi.pszText = rowLength16; + lvi.cchTextMax = _tcslen(rowLength16) + 1; + ListView_InsertItem(hListWnd, &lvi); + + lvi.iSubItem = 1; + lvi.mask = LVIF_TEXT; lvi.pszText = msg16; lvi.cchTextMax = _tcslen(msg16) + 1; - ListView_InsertItem(hListWnd, &lvi); + ListView_SetItem(hListWnd, &lvi); } else { cache[rowNo] = (TCHAR**)calloc (colCount + 1, sizeof (TCHAR*)); cache[rowNo][1] = _tcsdup(msg16); // malloc! - rowNo++; } delete [] msg16; + + datatypes[1 + rowNo * colCount] = SQLITE_TEXT; + rowCount++; } + int vCount = (colCount + 1) * rowCount; + SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount)); + datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte)); + SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes); + + SetProp(hListWnd, TEXT("ORDERBY"), new int(0)); + if (isVirtual) { cache = (TCHAR***)realloc(cache, vCount * sizeof(TCHAR**)); blobs = (unsigned char**)realloc(blobs, vCount * sizeof(unsigned char*)); SetProp(hListWnd, TEXT("CACHE"), cache); SetProp(hListWnd, TEXT("BLOBS"), (HANDLE)blobs); - SetProp(hListWnd, TEXT("ROWCOUNT"), new int(rowNo)); - SetProp(hListWnd, TEXT("TOTALROWCOUNT"), new int(rowNo)); + SetProp(hListWnd, TEXT("ROWCOUNT"), new int(rowCount)); + SetProp(hListWnd, TEXT("TOTALROWCOUNT"), new int(rowCount)); ListView_SetItemCount(hListWnd, 0); SendMessage(hListWnd, WMU_UPDATE_RESULTSET, 0, 0); @@ -5948,7 +5962,7 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) { SendMessage(hListWnd, WMU_AUTO_COLUMN_SIZE, 0, 0); ListView_EnsureVisible(hListWnd, 0, 0); - return isStopByLimit ? -rowNo : rowNo; + return isStopByLimit ? -rowCount : rowCount; } int ListView_ShowRef(HWND hListWnd, int rowNo, int colNo) { diff --git a/src/resource.h b/src/resource.h index 295b750..ef8d7a5 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,5 +1,5 @@ -#define GUI_VERSION "1.7.9" -#define GUI_VERSION2 1, 7, 9, 0 +#define GUI_VERSION "1.8.0" +#define GUI_VERSION2 1, 8, 0, 0 #ifdef __MINGW64__ #define GUI_PLATFORM 64 #else @@ -31,7 +31,7 @@ #define IDD_TEXT_COMPARISON 32 #define IDD_FK_SELECTOR 33 #define IDD_COLOR_PICKER 34 -#define IDD_URI_DB_PATH 35 +#define IDD_URI_DB_PATH 35 #define IDD_TOOL_IMPORT_CSV 55 #define IDD_TOOL_IMPORT_JSON 56 diff --git a/src/resource.rc b/src/resource.rc index ed2ddf8..f1bb63c 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -1111,6 +1111,7 @@ BEGIN "Ctrl + Tab - Toggle to a next result\n" \ "Ctrl + 1, Ctrl + 2, ... - Sort by column 1, 2, ... \n" \ "Ctrl + I - Invert row selection\n" \ + "Ctrl + P - Show/Hide a preview\n" \ "Ctrl + Shift + C - Copy selected rows to clipboard with a header\n" \ "Alt + Click - Show referenced data\n" \ "Alt + Double Click - Drill-down by referenced value\n" \