SQLite-OLE 2019-09-13

Updated version available.

Main new features:

Have added to the command line interpeter commands to find (InstrRex ) text, and to replace (ReplaceRex) text using regular expressions. The underlying regexp code is the open source Pcre2 “C” libary.

The SQLite loadable extension module (regexp.c) to support a regular expression as part of a WHERE clause has been added

SQLite-OLE 2019-08-07

Updated version available.

Main new features:

  • If in the “Edit Field”, you can select a block of text and send it to the command line interpret ( select the text, double right mouse click, select required option from the pop-up menu).
  • If in the “Edit Field”, a limited text find function is available.
  • These edit field features are also supported in the fields: “User macros”, “System macros”, “Report field” and “Help”.

For details about the following SQLite options and loadable extensions please refer to the SQLite web site.

The SQLite engine has been complied with the following options:

  • JSON1
  • FTS5

The following loadable extensions are included:

  • csv
  • fileio

SQLite-OLE 2019-04-27

New version of the SQLite and OLE tool for Windows.  Rightly or wrongly I am quite proud of this tool. Whilst my colleagues are using Excel to do a lot of data analysis they are hitting problems which are trivial in a SQL database environment.

Meanwhile I am running multiple instances of the SQLite-OLE tool on my laptop, often with databases approaching 2 GByte in a single instance. Because the tool is ~ 95% command line orientated, it forces me to create scripts. This has the massive advantage over a WIMP orientated tool because it means that I automatically have a script that I can save and reuse/rerun at a later date and not worry about “how did I do this last time”.

As a consequence of scripting I have found that I have adopted a “fire and forget” attitude. I focus on a task, script it, save it, and then focus on the next task. I do not need to commit to human memory the steps needed to complete a task. Given that I am running/developing scripts every day, I find that “fire and forget”/ scripting frees me from worry.

The output of the various tasks is usually in a Excel file (for easy exchange with my colleagues), the exporting of SQL query results to Excel is built in to the tool. Each Excel that I send out, contains an Admin sheet that identifies the script used to create the Excel file.

So if I am asked to modify/update an Excel file I simply ask the requester to identify the script (from the Admin sheet) and then I create a new version of the script and run it.

Some of the scripts are over 2000 lines long (with comments and lots of space to make it readable and less visually frightening).

The scripting language has similarities with Microsoft VBA to minimize the learning curve, and as the tool’s name implies it supports OLE.

What have you got to lose, go ahead and use it!

Big Screens for big kids

I have replaced my multiple monitor configuration on my PC, it was 1*27 inch and 1*32 inch monitors, by a single 42 inch 4k monitor from LG. To be precise a  LG 43UD79-B 108.98 cm (42.51 inch).

Like a dog with two tails, I do not know which one to wag first.

The only change I needed to do was to get a deeper desk so that I can set the screen about 15 cms further away.

NM_CUSTOMDRAW and Win 10

Hmm, I discovered that my solution using NM_CUSTOMDRAW does not quite do what I wanted in a MS Win 10 environment. The issue is the Win 10 themes.

The windows and controls that I use are created using CreateWindow or CreateWindowEx. In a MS Win 10 environment I found that I found that the  colour schemes that I tried to impose was not always followed.

If you call the API SetWindowThemeWindow , with the parameters: HWND of the target window / control, followed by 2 empty strings e.g.

SetWindowThemeWindow ( lWnd , _TEXT(“”),_TEXT(“”) ) ;

then the window/control will not follow the Windows Themes. I found it necessary to use this API for:

  • the main Window
  • Listviews so that I can set the colour of everyother row
  • the header of ListViews so that I can change the colour of the font and the background colour.

NM_CUSTOMDRAW and Listviews in Plain C

I recently spent 4 days trying to set the colour of the headers of a Listview in my Windows program SQLite-OLE. It was a painful experience partially because I program in plain C using the bare Win API and not using MFC (Microsoft Foundation Classes).

Hmm, well it was all my own fault. If you do not read the documentation carefully, what can one expect.

The solution was ultimately simple.

Here are a few tips if you want to set the background colour of a listview’s  cells or its column headers.

  1. When a Listview is displayed on the screen a number of  WM_NOTIFY messages are sent. We need to intercept a  subset of these WM_NOTIFY,  specifically those indicating a NM_CUSTOMDRAW operation.
  2. WM_NOTIFY / NM_CUSTOMDRAW messages concerning the data cells of the Listview are sent to the WndProc of the Listview’s PARENT, in my case the Window containing the Listview. These messages are also sent for some other controls, so be sure to check that the   (LPNMHDR)lParam)->hwndFrom  identifies the wanted Listview’s HWND.
  3. If you intercept these (cell) messages you can set the colour of the cell, the colour of the cells’ text, and the background color of the text, simply by providing a new RGB value to the data structure pointed at by the message’s lParam.
  4. WM_NOTIFY / NM_CUSTOMDRAW messages concerning the header of the Listview are sent to the WndProc of the Listview: In my case I had to subclass the Listview in order to create a WndProc for the Listview that I could intercept.
  5. If you intercept these (header) messages you can set the colour of the header cell, the colour of the text, and the background color of the text. BUT  you must use functions such as: FillRect, SetTextColor and SetBkColor.

Once I got this sorted out, the code was easy, and I can now modify the display of a Listview as shown below.

Before:

After: