I have implemented quite a few changes to the SQLite-OLE application. A new version is now available for download.
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.
- 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.
- 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.
- 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.
- 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.
- 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:
Creating your own GUI with SQLite-OLE
SQLite-OLE has now been updated, still less that 2.5 Mb, to include the ability for a user to create their own GUI and to interact with it via callbacks.
The capabilities are part of the underlying Forth-like interpreter, I only had to find a ways to expose these capabilities via a “Basic” like command line interpreter.
Well, I found a way to expose some of these (> 1000 Forth-like definition) to the SQLite-OLE command line interpreter.
Microsoft Office and LibreOffice
I have done (for me) a phenomenal amount of number crunching at work. One average I am processing about 1.2 million lines of data a week, nearly all of it provided as Excel or as CSV files. Fortunately the SQLite-OLE application lets me write script files, so that it is easy to rerun the processing steps.
I am a great fan of the automation of repeated activities.
However when it comes to presenting the data / results to other people it is usually necessary for me to use Excel.
Now, I have been programming in VBA for Excel, Word and PowerPoint for more than 10 years (especially in PowerPoint). And I have been fortunate that I have a work laptop so that I can play program at home. But I have often wondered if I should install LibreOffice (https://www.libreoffice.org/).
I was (until today) wondering how easy it would be to use the OLE interface of SQLite-OLE to control LibreOffice. Well now I know.
I started looking at the possibility last Sunday, and today (Thursday) I managed to get the LibreOffice WriterDemo going.
For anyone who is interested, you can find it on the SQLITE-OLE Scripts page.
Happy New Year and SQLite-OLE
I have spent the last two weeks trying to get a 30 minute video ready for YouTube about the SQLite-OLE application that is available from this web-site.
Each time I tried to record the video demonstrating SQLite-OLE I did something a bit different, and the demo crashed. Now with less than 7 hours to the New Year, I have got the video done. I feel as though I did something in 2017!
Here is the video:
Oops, sorry. Happy New Year.
By jingo, now I’m German and British
Well, today has been a day that I expect most people do not experience.
Today I was given a piece of paper that says I am a Germany citizen. Along with about 60 people, I was at a small ceremony where we were given our citizenship certificates.
I know that I was not the only British citizen there. Whilst going through the relatively simple process I was told by the civil servant that there was a significant increase in the number of British people applying for German nationality. The civil servant said it was nearly all due to Brexit. I know that that was my reason for applying.
No, I will not be handing in my British passport, although I do believe that Brexit is fundamentally a stupid jingoistic thing to do.
I was born in a little village, St. Florence, in the south west corner of Wales, in the county of Pembrokeshire. Now, Pembrokeshire is a county that is split in to two. The north/east part is Welsh, whilst the south/west corner is called Little England beyond Wales.
There is a dividing line called the Landsker that runs though Pembrokeshire, apparently Landsker is a old Anglo-Saxon word that has a meaning related to land divisions.
Way back in history, when England’s kings and Queen Elizabeth I were trying to impose their rule on Ireland, this south west corner of Pembrokeshire was used as a military base from which the English could nip over to Ireland. This part of Pembrokeshire had to be a safe base for the English, so ultimately the welshness of the area was, over many centuries, subdued. This got the south west corner of Pembrokeshire the name Little England beyond Wales .
When I started primary school in 1959, there was no Welsh language teaching in the school. The school was built in the late 1800’s so it had things such as honour rolls of the village people who had died in the Great War of 1914-1918. These rolls, and all of the other paraphernalia and regalia, were in English, although the names were clearly Welsh: Jones, Lewis, Thomas, Williams,… But one should note that these are common throughout the UK, but Welsh names such as Blethyn, Prytherch, Iwan, Rhys did not appear on the rolls.
Indeed, the only time I heard Welsh in St. Florence was if my mum was talking to Mrs. Lewis the back. One trace of welshness that we did have was a tendency to identify people by their job (hence the milkman Mr. Rowe was Rowe the milk) or by location (hence Mrs. Lewis the back who lived at the back of the village). Apart from Mrs. Lewis and my mum I do not recall ever hearing Welsh in the village.
The other time that I regularly encountered Welsh was when we visited my maternal grandmother who lived on the Welsh side of the Landsker. Granny Meaker could speak English but avoided it when possible especially when we came to visit. My mum and her mum would talk away in Welsh whilst my father and my brother/sisters and I would drink tea, eat Welsh cakes, and wait to go home. (My father was English, born in Birmingham.)
I believe that Granny Meaker hated my father on principle, and that she avoided English so she could avoid speaking to him. By all accounts my father did not want to speak to her either. Aren’t families fun!
When I was 11 and moved-up to the big school in Tenby there were one or two kids in the class who spoke Welsh, but they were bussed in from the
north, and were invariable farm children.
It was not until I went to university in Bristol that I was really confronted with an identity issue. To my English mates I was Welsh, but to the Welsh ones I was English.
Since then I have been critically aware that my nationality falls between two stools. I love the heritage of England (and the National Trust) and yet I feel the pain felt by many (the non-English British people and the Irish people) created by the English in the past.
Just for fun, check out Jane Austen and the speech made by the Baronet Sir Walter Elliot in the story “Persuasion”.
A widow Mrs Smith lodging in Westgate Buildings! A poor widow barely able to live, between thirty and forty; a mere Mrs Smith, an every-day Mrs Smith, of all people and all names in the world, to be the chosen friend of Miss Anne Elliot, and to be preferred by her to her own family connections among the nobility of England and Ireland! Mrs Smith! Such a name!
I find it strange and sad, and yet so very believable, that Scotland and Wales are not mentioned. However, this little speech strikes a chord with me. In a way it reminds me how my self identity is of little consequence.
I can stand-up and fight for Wales, or I can stand-up and fight for England. It is my choice.
But I find that I abhor divides. I consider reglious belief to be, 99%, depending on the self-identity that once assumes. Born in the UK, then probably protestant. Born in the Middle East, then possibly Islamic.
This insight suggests most strongly to me that religion and nationality are just other names for jingoism, or tribalism.
It is probably no surprise that I do not follow any football team, or rugby team, or indeed any other team. I disagree with the idea of us and them.
I do not mind a game, I do not mind people being in teams, but I do object to the tribalistic attitude that so often comes from teams.
As a general rule I believe that together is better than apart.
Now, to bring this blog to a close:
- I saw the EU as a step toward together and away from apart.
- I see Brexit as just another team playing at jingoism and the old mine is bigger than yours.
One of the drivers for me taking on Germany nationality was to support together, and one of the reasons why I will not give up my British nationality is I will not promote apart.
PSTN and Switching-Routing
I have noticed over the last 20 years a tendency by some people to consider PSTN to mean the Public Telephone Switched Network. It should come as no surprise to people who know me, that I take a different position.
Let us take a step back to the first 100 hundred years of the telephone. Independent of who has the right to be called the inventor of the telephone, Alexander Graham Bell certainly brought the telephone to the public.
Each call across those telephone networks would consist of a set-up phase, a connected phase and a clear-down phase. Typically, at least in the days of the manual operator, the calling party would identify the called party by one of two means:
- A description of the end subscriber, such as Mr. Sherlock Holmes, 221B Baker Street, London
or - The identity of the end point on the telephone network, such as London, Whitehall, 1212 i.e. the telephone exchange and the “local number” on that exchange. (Whitehall 1212 was, from about 1934 till the 1960s, the London Metropolitan Police station known as Scotland Yard.)
In the first case the operator would do a check in the telephone directory to convert the subscriber identity to an end point identity. Once the end point identity was known the operator would select a transport path that would extend the call in the appropriate direction. This decision, based on the context of the call (target destination ), took in to account the resources available to the operator, and the decision was and still is called routing.
Every telephone call over the PSTN is routed. Sorry, but I see no room for discussion on this.
Once the call set-up has reached the called party, and the called party answers the call, then the call set-up phase ends and the call connection phase starts. In the call connection phase there is an identifiable semi-permanent route (often called a path) between the caller and called party. That route/path took the form of a galvanic connection between the parties (in the analogue telephone system).
In the implementation of the telephone service that started in the mid 1980s the galvanic connection was replaced by a sequence of logical transformations on digital signals in time and space
It was common, even in the analogue telephone days, to refer to the infrastructure that handled the routing decision and that interconnected the transport paths as a telephone switch.
Now we must step back to the 1970’s and 1980’s. In the early 1970’s the basics of the Internetworking Protocol were established by Bob Kahn and Vincent Cerf. The resulting telecommunications networks, based on the Internetworking Protocol, led to the establishment of the Internet as we know it today:
a set of interconnected infrastructure that has a shared end-point addressing scheme and a shared understanding of the structure and interpretation of data packets that the infrastructure transports.
Now we enter the period in which the fledgling Internet caught the attention of financially orientated concerns.
One of the topics that was turned in to an issue, was whether companies who provided public access to the Internet were subject to the regulations normally applicable to providers of telecommunications services.
One argument against the applicability of the telecommunications regulations to the Internet hinged on questionable logic:
- The PSTN is subject to regulations.
- PSTN “stands” for the Public Switched Telephone Network.
- The Internet is routed, and has nothing to do with “switched”.
- The Internet should therefore not be subject to telecommunications regulations.
I think that an appropriate phrase to some up this logic, and its conclusion, is horse feathers.
Hmmm, this was a wonderful application of the now common alternative facts, and yes, it was spearheaded by companies based in the USA.
It was of course, totally ignored by such non-regulation preferring companies, that the Internet in the last 20 or so years makes extensive (i.e. massive) use of switching in the MPLS cores and in the Ethernet access networks.
I have said it before, and I will say it again.
“Wishy washy words lead to wishy washy thinking”.
If you want to muddy the waters of your opposition, start using wishy washy words, obfuscate the issue.
To quote that author whom I have already referred to:
Terry Pratchett – ‘A lie can run round the world before the truth has got its boots on.’
If you really want to understand something, then consider this: the tools of comprehension are words and sentences. If you use the wrong tools do not be surprised if the results are sub-optimal.
Curse the darkness, or speak out.
Once more I ask myself why I have created this blog.
I have spent some time discussing this with my son (studying physics at university and just starting his M.Sc. thesis), and about the only conclusion I have reached is summed up by the following quotation which I understand is too old to be definitivly attributed to anyone:
Yet it is far better to light the candle than to curse the darkness
I suppose that my use of this blog is similar to the classical 1950’s letter that took the form:
To the Editor of the Local Newpaper.
Dear Sir
It has come to my notice that …
Yours faithfuly, a concerned citizen of our good village.
Well, the truth is out, I am I suppose a concerned citizen of our good village, except maybe I should consider myself to be a concerned citizen of our global village.
Is a blog an opportunity to speak out. If so, are there better ways?
Wishy washy words and wishy washy thinking.
I try to take words seriously. That means that I believe communications between people is easier if we use the right words.
I have many phrases which I spout forth, one of which is wishy washy words lead to wishy washy thinking. I often think of this phrase when I read about the USA and the ongoing saga of network neutrality in the context of telecommunications.
If you have seen my earlier blogs you might have noticed that I have a very clear interpretation of what a telecommunication service is.
A telecommunications service is when a service provider agrees to transport valid user-defined input, from an incoming service access point to one or more, user nominated, outgoing service points, and that transport is carried out to a understood service level agreement.
I get the feeling that some of the USA discussions about network neutrality hinge on the Internet being an information service and not a telecommunications service. Hmm, looks like we are getting the now famous American alternative facts from such people.
I will try to highlight some relevant facts about telecommunications.
- The legacy public telephone service, whether realised by analogue switching, digital (fixed network ISDN or its wireless version)) technology , is a telecommunications service providing network. The PSTN (Public Service Telephone Network and not Public Switched Telephone Network as many people would like to name it!) has been carrying data (machine-to-machine) since at least the 1920’s. In the early 2000’s the PSTN in many countries was carring more data (machine-to-machine), measured in transport volume, than speech conversations.
- Even if we restrict our analysis to speech communications across the PSTN (please remember the PSTN includes both fixed and wireless access technologies), we can easily argue that the PSTN supported the exchange of information between users. Even if I only phone my family back in Wales and ask “how are you”, it is a classical case of information exchange! Fortunately no-one succeeded in reclassifing the PSTN as an information service since the PSTN is clearly the transporter and not itself the information provider.
- If we now consider the current situation as presented in various online news sites about the USA / FCC and network neutrality. It appears that the USA has classified the Internet as an Information service. Not strictly wrong, unless you try to twist that into meaning that the transport provider(s) are providing information services. They are clearly not providing information, they are transporting.
- We do not say that the postal service is an information service, even though they deliver large volumes of information, sometimes written, sometimes on DVDs or CDs.
- Why do some people try to twist the Internet transporters as providing an inforamtion service. A rhetorical question, to which the answer is for an advantage!
I take the position that is it not in any way technically justifiable to classify the transportation of data (irrespective of how that data is encoded or packeted or routed or switched) as an informational service.
Now, please note that I have not commented here on whether network neutrality is good/bad/right/wrong! I have only considered whether it is justifiable to label the transport providers of the Internet as providing an information or telecommunications service.
My prime concern is that when we start applying incorrect labels to things we start thinking about them incorrectly.
Before we can really understand the whole network neutrality issue we must must must understand correctly what we are talking about.
One of the facts in the network neutrality debate is that telecommunications services are regulated differently to information services.
One of the alternative facts that is popular in the network neutrality debate is that the Internet is an information service for all involved parties, including the transport providers.
When key players start trying to change the classification of a transport service to an information service so that they can avoid telecommunications regulations, well that’s when I get to intensely dislike the morals of some of my fellow human beings.
Or possibly not quite so sad, but probably more common, I get heartily disillusioned at the lack of understanding shown by people who should know better.