Technology News Worth Reading

Here are a few technology news stories that I’ve read in the past week or so.

News Headlines

Microsoft’s 10 app store principles to promote choice, fairness and innovation

For software developers, app stores have become a critical gateway to some of the world’s most popular digital platforms. We and others have raised questions and, at times, expressed concerns about app stores on other digital platforms. However, we recognize that we should practice what we preach. So, today, we are adopting 10 principles – building on the ideas and work of the Coalition for App Fairness (CAF) – to promote choice, ensure fairness and promote innovation on Windows 10, our most popular platform, and our own Microsoft Store on Windows 10. Read Microsoft’s blog post.

PostMan’s 2020 State of the API Report

Every year, Postman surveys industry members to get a picture of the API industry—to understand who is working with APIs, how they are getting their work done, and where they see the industry going. More than 13,500 developers, testers, executives, and others took our 2020 survey and provided insights on everything from how they spend their time to what they see as the biggest issues and opportunities for APIs. Three key findings: API investments stay strong, The pandemic has changed the world, but it didn’t stop APIs, and APIs are the nucleus of digital transformation. Read and download the report on the Postman website.

Hybrid cloud is where the action is

Multicloud is definitely a thing. However, it’s not exactly clear what that “thing” is. According to new survey data from database vendor MariaDB, 71% of survey respondents report running databases on at least two different cloud providers today. Yet when asked what would keep them from going all in on a cloud database, a vendor’s “lack of a multicloud offering” ranked dead last. In other words, everyone is doing multicloud, but no one knows why. Read Matt Assay’s InfoWorld article.

Nvidia claims Cambridge-1 is the U.K.’s fastest supercomputer

Cambridge-1, which Nvidia expects to come online by year-end 2020, is a joint project between GSK, AstraZeneca, Guy’s and St Thomas’ NHS Foundation Trust, King’s College London, and Oxford Nanopore. Built on Nvidia’s DGX SuperPOD architecture, it’s anticipated to deliver over 400 petaflops of AI performance and 8 petaflops of Linpack performance. That would rank it 29th on the TOP500 list of the world’s most powerful supercomputers and among the top three most-energy-efficient machines in the Green500. Read Kyle Wiggers’ VentureBeat article.

Survey finds cloud complexity increases challenges

Aptum’s Global Cloud Impact Study reveals this with 62 percent of respondents citing complexity and abundance of choice as a hindrance when planning a cloud transformation. One of the biggest sources of complexity that crops up in more advanced cloud projects are legacy systems. The “abundance of choice” or the need to select the best of breed is a prime culprit. This usually results in a technological smorgasbord, where hundreds of decoupled cloud dev and migration teams make their own calls around what technology to use. Complexity naturally arises when it’s time to join and coordinate those apples and oranges. Read David Linthicum’s InfoWorld article.

The art of code reviews

According to Phil Hughes, front-end engineer at GitLab, it’s about how you provide and convey that feedback — and that’s an art form and a skill that is learned over time. “Reviewing code efficiently is a skill that gets learned the more you do it. Spending time coming up with a workflow that works for yourself is just as important”. Read the SD Times article by Christina Cardoza.

An AI can simulate an economy millions of times to create fairer tax policy

Scientists at the US business technology company Salesforce think AI can help. Led by Richard Socher, the team has developed a system called the AI Economist that uses reinforcement learning—the same sort of technique behind DeepMind’s AlphaGo and AlpahZero—to identify optimal tax policies for a simulated economy. The tool is still relatively simple (there’s no way it could include all the complexities of the real world or human behavior), but it is a promising first step toward evaluating policies in an entirely new way. “It would be amazing to make tax policy less political and more data driven,” says team member Alex Trott. Read the MIT Technology Review article by Will Douglas Heaven.

The most valuable software developer skills in 2020

Which developer skills are the most valuable in today’s market? We’ve pored through the data to find the most bankable developer skills for the coming years—and how best to set yourself up for success in a fraught job market: Don’t put all your eggs in one basket, Some skills are hotter than others, Going cloud native, Ordering the full stack, Data is still the new oil, and Formal education isn’t everything. Read the InfoWorld article by By Scott Carey.

Justices wary of upending tech industry in Google v. Oracle Supreme Court fight

The dispute concerns about 11,500 lines of code that Google used to build its popular Android mobile operating system, which were replicated from the Java application programming interface developed by Sun Microsystems. At the end of an hour and a half of arguments, Justice Stephen Breyer, who at one point read aloud some code, seemed to be the only sure vote. Several of the other justices, including Chief Justice John Roberts, suggested they were sympathetic to Oracle’s copyright claims. Several of the court’s conservatives, including Justices Brett Kavanaugh and Samuel Alito, noted that Google’s allies had warned that the “sky will fall” if Oracle won. But those comments were also peppered with skepticism. “I’m not aware that the sky has fallen in the last five or six years,” Kavanaugh said, noting that Google had lost its first appeals court battle in the case in 2014. Read the CNBC article by Tucker Higgins.

Section 230 will be on the Chopping Block at the Next Big US Congressional Hearing

Will Section 230 be on the chopping block at the next US congressional tech hearing. Hearing will focus on Section 230 of the Communications Decency Act, the key law that shields online platforms from legal liability for the content their users create. What is clear: Tinkering with such a foundational law could have a huge cascade of effects for the internet as we know it and isn’t something to be undertaken lightly — if at all. Read the TechCrunch article by Taylor Hatmaker.

To the moon and beyond: How HoloLens 2 is helping build NASA’s Orion spacecraft

When workers for Lockheed Martin began assembling the crew seats for a spacecraft designed to return astronauts to the moon and pave the way for human exploration to Mars, they had no need for paper instructions or tablet screens to work from. Everything they needed to see, including animations of how pieces fit together, engineering drawings and torque values for tightening bolts, was visible in HoloLens 2 devices that they wore. Read the TechXplore article by Jennifer Langston, Microsoft.

Affordable AI: Nvidia Launches $59, 2GB Jetson Nano Computer

While Raspberry Pi boards are great for doing all kinds of tasks and they’re capable of doing object recognition, they can be a little slow when it comes to real-time image recognition. In 2019, Nvidia came out with an A.I.-focused Pi competitor in the $99 Jetson Nano. Fast forward to 2020 and Nvidia is back with a 2GB version of the Jetson Nano that sells for a more reasonable $59 and, for consumers in some markets (including America), comes with a compatible USB Wi-Fi dongle in the box. Due out later this month, the new Nvidia Jetson Nano 2GB is designed to make A.I. more accessible to hobbyists, kids and aspiring developers. Read the Toms Harware article by Avram Piltch.

Microsoft’s VS Code comes to Raspberry Pi and Chromebook – new v1.50 update is out

An official Microsoft build of the Visual Studio Code editor is now available for Linux Armv7 and Arm64 architecture devices, extending Microsoft’s popular cross-platform code editor to Chromebooks, the Raspberry Pi and rival Arm-based single-board Linux computers such as Odroid. Read the ZDNet article by Liam Tung.

Why Apple needed the FDA to sign off on its EKG but not its blood oxygen monitor

The features on the Apple Watch that track heart rate and heart rhythm, though, have a key difference from the blood oxygen monitor: the heart-tracking features are cleared by the Food and Drug Administration (FDA), and the oxygen monitor is not. Apple went through a long, extensive process to develop and validate an EKG feature so that the watch could detect a condition called atrial fibrillation. It didn’t need to do the same thing for the pulse oximeter. Blood oxygen monitors, or pulse oximeters, are considered Class II medical devices by the FDA. Read TheVerge article by Nicole Wetsman.

JDK 16: What’s coming in Java 16 (due March 2021)

Java Development Kit (JDK) 16 has begun to take shape, with proposed features including concurrent thread-stack processing for garbage collection, support for C++ 14 language features, and an “elastic metaspace” capability to more quickly return unused class metadata memory to the OS. Read the InfoWorld article by Paul Krill.

Microsoft launches Playwright for Python for automating testing

Microsoft is trying to make it easier for developers to automate their end-to-end tests. The company has announced a preview of Playwright for Python, which allows developers and testers to write such tests in Python. According to Microsoft, automated end-to-end tests have become more important than ever as teams build apps that run on a number of different kinds of devices. The increase in the number of targets coupled with increased delivery speed has put more pressure on the testing process, and automation is crucial to enable testing at the speed it needs to be done. Playwright for Python provides timeout-free automation, which makes it more reliable. Read the SD Times article by Jenna Sargent.

Definitely not Windows 95: What operating systems keep things running in space?

To deal with unforgiving deadlines, spacecraft like Solar Orbiter are almost always run by real-time operating systems that work in an entirely different way than the ones you and I know from the average laptop. Operating systems used in space add at least one more central criterion: a computation needs to be done correctly within a strictly specified deadline. When a deadline is not met, the task is considered failed and terminated. And in spaceflight, a missed deadline quite often means your spacecraft has already turned into a fireball or strayed into an incorrect orbit. There’s no point in processing such tasks any further; things must adhere to a very precise clock. Read the ArsTechnica article by Jacek Krywko.

GitHub Code scanning is now available!

One year ago, GitHub welcomed Semmle. We’ve since worked to bring the revolutionary code analysis capabilities of its CodeQL technology to GitHub users as a native capability. At GitHub Satellite in May, we released the first beta of our native integration: code scanning. Now, thanks to the thousands of developers in the community who tested and gave feedback, we’re proud to announce that code scanning is generally available. Read the GitHub blog post by Justin Hutchings.

4 common C programming mistakes — and 5 tips to avoid them

Common C mistake: Not freeing malloc-ed memory (or freeing it more than once). Common C mistake: Reading an array out of bounds. Common C mistake: Not checking the results of malloc. Common C mistake: Using void* for generic pointers to memory. Read the InfoWorld article by Serdar Yegulalp.

Windows Printing with C++Builder using VCL and FMX

Do you need to add printer support to your C++ applications using the Visual Component Library (VCL) or FireMonkey (FMX) GUI ? In this blog post I’ll show you how to build Windows applications that support printing image bitmaps using the VCL and FMX frameworks. One of my favorite C++Builder RTL features is that both frameworks provide similar printer components and ways of programming with only a few subtle differences.

Build VCL and FMX Application Projects

Use the “File | New | Windows VCL Application – C++Builder” menu item and create a starting C++ VCL application. Save the product to a folder.

File | New | Windows VCL Application – C++Builder

Next, in the Project Window, right mouse click on the ProjectGroup node and select the “Add New Project…” menu item.

Add New Project to the Project Group

In the popup dialog choose to create a Multi-Device Application.

Add New Multi-Device Application

Click the OK button and on the next screen choose to create a “Blank Application”.

Multi-Device Project templates list – choose Blank Application

Use the File | Save All menu item (or type Shift+Ctrl+S) to save both starting projects and the project group to a folder.

Project Group with VCL and FMX Starting Projects

Each of the VCL and FMX projects have a main form (.dfm and .fmx extensions respectively). While most of the IDE will look the same, if you select each form’s unit you will see different looks for each of their form designers.

VCL Form Designer
FMX Form Designer

There are many videos, articles and help files that describe the details of each designer (check out links in the reference section below). For now, let’s dig into the VCL and FMX printer examples I’ve created.

A Simple UI for each Printer Test Project

On each of the VCL and FMX main forms you’ll see the following components.

VCL form’s components in the Structure Window
FMX form’s components in the Structure Window

Each project’s main menu contains a File and Destination menu. The Destination menu item allows the user to choose to override the printing destination (Printer or File).

The File menu provides an OpenPictureDialog (VCL) or OpenDialog (FMX), PrintPicture dialog for choosing the printer and other printing options, PrinterSetup dialog to set additional printer setup options, Panel (aligned to the top of the form)with a label and ComboBox which will list the available printer device names, and an Image component (aligned to the client area) to contain the picture bitmap.

The VCL and FMX forms look like the following.

VCL app form with components
FMX app form with components

Right mouse click on the form and choose “View as Text” from the popup menu. Now you can see all of the form and component properties and sub-properties that have been set from their default values. You can also make changes in this text form mode but be careful to not make any errors.

To switch back to the form mode click the right mouse button (or hit Alt-F12) and choose “View as Form” from the popup menu.

VCLPrintUnit.dfm (View as Text)

object MainVCLForm: TMainVCLForm
  Left = 0
  Top = 0
  Caption = 'Printer Test (C++, VCL)'
  ClientHeight = 473
  ClientWidth = 667
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  Menu = MainMenu1
  OldCreateOrder = False
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 0
    Top = 41
    Width = 667
    Height = 432
    Align = alClient
    Proportional = True
    ExplicitLeft = 104
    ExplicitTop = 102
    ExplicitWidth = 424
    ExplicitHeight = 317
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 667
    Height = 41
    Align = alTop
    TabOrder = 0
    object Label1: TLabel
      Left = 10
      Top = 12
      Width = 41
      Height = 13
      Caption = 'Printers:'
    end
    object PrintersComboBox: TComboBox
      Left = 57
      Top = 9
      Width = 250
      Height = 21
      TabOrder = 0
      Text = 'PrintersComboBox'
    end
  end
  object PrintDialog1: TPrintDialog
    Options = [poPrintToFile]
    Left = 176
    Top = 56
  end
  object PrinterSetupDialog1: TPrinterSetupDialog
    Left = 304
    Top = 64
  end
  object OpenPictureDialog1: TOpenPictureDialog
    DefaultExt = 'bmp'
    InitialDir = 'c:\temp'
    Left = 56
    Top = 56
  end
  object MainMenu1: TMainMenu
    Left = 424
    Top = 64
    object File1: TMenuItem
      Caption = 'File'
      object File2: TMenuItem
        Caption = 'Open Picture'
        OnClick = File2Click
      end
      object PrintPicture1: TMenuItem
        Caption = 'Print Picture'
        Enabled = False
        OnClick = PrintPicture1Click
      end
      object PrinterSetup1: TMenuItem
        Caption = 'Printer Setup'
        Enabled = False
        OnClick = PrinterSetup1Click
      end
      object PrintPicture2: TMenuItem
        Caption = 'Exit'
        OnClick = PrintPicture2Click
      end
    end
    object Destination1: TMenuItem
      Caption = 'Destination'
      object PrintToPrinterDestinationMenuItem: TMenuItem
        Caption = 'Print to Printer'
        Checked = True
        OnClick = PrintToPrinterDestinationMenuItemClick
      end
      object PrintToFileDestinationMenuItem: TMenuItem
        Caption = 'Print to File'
        OnClick = PrintToFileDestinationMenuItemClick
      end
    end
  end
end

FMXPrintUnit.fmx (View as Text)

object MainFMXForm: TMainFMXForm
  Left = 0
  Top = 0
  Caption = 'Printer Test (C++, FMX)'
  ClientHeight = 380
  ClientWidth = 640
  Position = Designed
  WindowState = wsMaximized
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  OnShow = FormShow
  DesignerMasterStyle = 0
  object Image1: TImage
    MultiResBitmap = <
      item
      end>
    Align = Client
    Size.Width = 640.000000000000000000
    Size.Height = 339.000000000000000000
    Size.PlatformDefault = False
  end
  object PrintDialog1: TPrintDialog
    Options = [poPrintToFile]
    Left = 68
    Top = 40
  end
  object PrinterSetupDialog1: TPrinterSetupDialog
    Left = 190
    Top = 42
  end
  object OpenDialog1: TOpenDialog
    DefaultExt = 'bmp'
    Filter = '*.bmp'
    InitialDir = 'c:\temp'
    Left = 312
    Top = 44
  end
  object MainMenu1: TMainMenu
    Left = 418
    Top = 46
    object FileMenu: TMenuItem
      Text = 'File'
      object OpenBitmapMenuItem: TMenuItem
        Locked = True
        Text = 'Open Bitmap'
        OnClick = OpenBitmapMenuItemClick
      end
      object PrintMenuItem: TMenuItem
        Enabled = False
        Locked = True
        Text = 'Print'
        OnClick = PrintMenuItemClick
      end
      object PrinterSetupMenuItem: TMenuItem
        Enabled = False
        Locked = True
        Text = 'Printer Setup'
        OnClick = PrinterSetupMenuItemClick
      end
      object ExitMenuItem: TMenuItem
        Locked = True
        Text = 'Exit'
        OnClick = ExitMenuItemClick
      end
    end
    object DestinationMenu: TMenuItem
      Text = 'Destination'
      object PrintToPrinterDestinationMenuItem: TMenuItem
        Locked = True
        IsChecked = True
        Text = 'Print to Printer'
        OnClick = PrintToPrinterDestinationMenuItemClick
      end
      object PrintToFileDestinationMenuItem: TMenuItem
        Locked = True
        Text = 'Print to File'
        OnClick = PrintToFileDestinationMenuItemClick
      end
    end
  end
  object Panel1: TPanel
    Align = Top
    Size.Width = 640.000000000000000000
    Size.Height = 41.000000000000000000
    Size.PlatformDefault = False
    object PrintersComboBox: TComboBox
      Position.X = 72.000000000000000000
      Position.Y = 8.000000000000000000
      Size.Width = 233.000000000000000000
      Size.Height = 22.000000000000000000
      Size.PlatformDefault = False
    end
    object Label1: TLabel
      Position.X = 8.000000000000000000
      Position.Y = 9.000000000000000000
      Size.Width = 57.000000000000000000
      Size.Height = 17.000000000000000000
      Size.PlatformDefault = False
      Text = 'Printers:'
    end
  end
end

Additional comments about component properties and event handlers are included in the source code for the projects.

The Source Code

Below you will find the header files for the VCL and FMX form units. The header files will show the component declarations, event handlers and any public/private declarations.

VCLPrintUnit.h

//---------------------------------------------------------------------------

#ifndef VCLPrintUnitH
#define VCLPrintUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.Dialogs.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.ExtDlgs.hpp>
#include <Vcl.Menus.hpp>
#include <Vcl.WinXCtrls.hpp>
//---------------------------------------------------------------------------
class TMainVCLForm : public TForm
{
__published:	// IDE-managed Components
	TPrintDialog *PrintDialog1;
	TPrinterSetupDialog *PrinterSetupDialog1;
	TImage *Image1;
	TOpenPictureDialog *OpenPictureDialog1;
	TMainMenu *MainMenu1;
	TMenuItem *File1;
	TMenuItem *File2;
	TMenuItem *PrintPicture1;
	TMenuItem *PrintPicture2;
	TMenuItem *Destination1;
	TMenuItem *PrintToPrinterDestinationMenuItem;
	TMenuItem *PrintToFileDestinationMenuItem;
	TMenuItem *PrinterSetup1;
	TPanel *Panel1;
	TLabel *Label1;
	TComboBox *PrintersComboBox;
	void __fastcall File2Click(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall PrintToPrinterDestinationMenuItemClick(TObject *Sender);
	void __fastcall PrintToFileDestinationMenuItemClick(TObject *Sender);
	void __fastcall PrintPicture1Click(TObject *Sender);
	void __fastcall PrinterSetup1Click(TObject *Sender);
	void __fastcall PrintPicture2Click(TObject *Sender);
private:	// User declarations
    bool PictureLoaded;  // boolean for whether a picture is loaded or not
public:		// User declarations
	__fastcall TMainVCLForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainVCLForm *MainVCLForm;
//---------------------------------------------------------------------------
#endif

FMXPrintUnit.h

//---------------------------------------------------------------------------

#ifndef FMXPrintUnitH
#define FMXPrintUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <FMX.Controls.Presentation.hpp>
#include <FMX.StdCtrls.hpp>
#include <FMX.Types.hpp>
#include <FMX.Objects.hpp>
#include <FMX.Dialogs.hpp>
#include <FMX.Printer.hpp>
#include <FMX.Menus.hpp>
#include <FMX.ListBox.hpp>
//---------------------------------------------------------------------------
class TMainFMXForm : public TForm
{
__published:	// IDE-managed Components
	TImage *Image1;
	TPrintDialog *PrintDialog1;
	TPrinterSetupDialog *PrinterSetupDialog1;
	TOpenDialog *OpenDialog1;
	TMainMenu *MainMenu1;
	TMenuItem *FileMenu;
	TMenuItem *OpenBitmapMenuItem;
	TMenuItem *PrintMenuItem;
	TMenuItem *PrinterSetupMenuItem;
	TMenuItem *ExitMenuItem;
	TPanel *Panel1;
	TComboBox *PrintersComboBox;
	TLabel *Label1;
	TMenuItem *DestinationMenu;
	TMenuItem *PrintToPrinterDestinationMenuItem;
	TMenuItem *PrintToFileDestinationMenuItem;
	void __fastcall PrintMenuItemClick(TObject *Sender);
	void __fastcall OpenBitmapMenuItemClick(TObject *Sender);
	void __fastcall ExitMenuItemClick(TObject *Sender);
	void __fastcall PrinterSetupMenuItemClick(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall PrintToPrinterDestinationMenuItemClick(TObject *Sender);
	void __fastcall PrintToFileDestinationMenuItemClick(TObject *Sender);
private:	// User declarations
	BOOL PictureLoaded;  // boolean for whether a picture is loaded or not
public:		// User declarations
	__fastcall TMainFMXForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TMainFMXForm *MainFMXForm;
//---------------------------------------------------------------------------
#endif

Below you will find the source code for the VCL and FMX form units.

VCLPrinterUnit.cpp

//---------------------------------------------------------------------------

#include <vcl.h>
#include <Vcl.Imaging.GIFImg.hpp>
#include <Vcl.Imaging.jpeg.hpp>
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Printers.hpp>

#pragma hdrstop

#include "VCLPrintUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainVCLForm *MainVCLForm;
//---------------------------------------------------------------------------
__fastcall TMainVCLForm::TMainVCLForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::File2Click(TObject *Sender)
{
	if (OpenPictureDialog1->Execute()) {
		Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
		PictureLoaded = true;
		PrintPicture1->Enabled = true;
        PrinterSetup1->Enabled = true;
	}
}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::FormShow(TObject *Sender)
{

	PictureLoaded = false;
	PrintToPrinterDestinationMenuItem->Checked = true;
	PrintToFileDestinationMenuItem->Checked = false;

	// get printers list and put in combobox
	PrintersComboBox->Items = Printer()->Printers;

	// make the currently selected printer the Item in the ComboBox
	PrintersComboBox->ItemIndex = 0;
	for (int i = 0; i < Printer()->Printers->Count-1; i++) {
		if (Printer()->Printers->Strings[Printer()->PrinterIndex] == PrintersComboBox->Items->Strings[i]) {
			PrintersComboBox->ItemIndex = i;
		}
	}

}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::PrintToPrinterDestinationMenuItemClick(TObject *Sender)
{
	// set menu item checked for print to printer
	PrintToPrinterDestinationMenuItem->Checked = true;
	PrintToFileDestinationMenuItem->Checked = false;
	// set PrintDialog PrintToFile checkbox off
	// Note: to allow user to override the menu item - make sure
	//   PrintDialog Options poPrintToFile is set to true
	//   so that the PrintToFile checkbox appears in the dialog
	PrintDialog1->PrintToFile = false;
}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::PrintToFileDestinationMenuItemClick(TObject *Sender)
{
	// set menu item checked for print to file
	PrintToPrinterDestinationMenuItem->Checked = false;
	PrintToFileDestinationMenuItem->Checked = true;
	// set PrintDialog PrintToFile checkbox on
	// Note: to allow user to override the menu item - make sure
	//   PrintDialog Options poPrintToFile is set to true
	//   so that the PrintToFile checkbox appears in the dialog
	PrintDialog1->PrintToFile = true;
}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::PrintPicture1Click(TObject *Sender)
{

	// check if a picture is loaded
	if (PictureLoaded) {
		if (PrintDialog1->Execute()) {

			// Call BeginDoc - to get the dimensions for selected printer
			Printer()->BeginDoc();

			try {
				// use StretchDraw to do full size bitmap printing
				// notes:
				//   printer settings can be made using the
				//     PrintDialog and PrinterSetupDialog
				//   you can also control page layout in code:
				//     Property is Orientation:
				//       poPortrait
				//       poLandscape
				Printer()->Canvas->StretchDraw(
					Rect(0, 0, Printer()->PageWidth,Printer()->PageHeight),
					Image1->Picture->Graphic);
			}
			__finally {
				// end the document and the printing will begin
				Printer()->EndDoc();
			}
		}
	}

}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::PrinterSetup1Click(TObject *Sender)
{
	// Printer Setup
    PrinterSetupDialog1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TMainVCLForm::PrintPicture2Click(TObject *Sender)
{
    Application->Terminate();
}
//---------------------------------------------------------------------------

FMXPrinterUnit.cpp

//---------------------------------------------------------------------------

#include <fmx.h>
#include "FMX.Printer.hpp"
#include "System.SysUtils.hpp"
#pragma hdrstop

#include "FMXPrintUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TMainFMXForm *MainFMXForm;
//---------------------------------------------------------------------------
__fastcall TMainFMXForm::TMainFMXForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainFMXForm::PrintMenuItemClick(TObject *Sender)
{
	TRectF SrcRect, DestRect;

	if (PrintDialog1->Execute()) {
		// Set the default DPI for the printer. The SelectDPI routine defaults
		//	 to the closest available resolution as reported by the driver.
		// Printer->ActivePrinter->SelectDPI(1200, 1200);

		// Printer->ActivePrinter->ActiveDPIIndex = 1; // you can also the DPI index

		// Set canvas filling style
		// Printer->Canvas->Fill->Color = claBlack;
		// Printer->Canvas->Fill->Kind = TBrushKind(1);

		// Start printing
		Printer::Printer()->BeginDoc();

		// Set the Source and Destination TRects

		SrcRect = TRectF(0, 0, Image1->Bitmap->Width, Image1->Bitmap->Height);
		DestRect = TRectF(0, 0, Printer::Printer()->PageWidth, Printer::Printer()->PageHeight);

		// Print the picture, on all the surface of the page and all opaque.
		Printer::Printer()->Canvas->DrawBitmap(Image1->Bitmap, SrcRect, DestRect, 1);

		// Finish the printing job
		Printer::Printer()->EndDoc();
	}

}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::OpenBitmapMenuItemClick(TObject *Sender)
{
	// open a bitmap for printing
	if (OpenDialog1->Execute()) {
		Image1->Bitmap->LoadFromFile(OpenDialog1->FileName);
		PrintMenuItem->Enabled = true;
		PrinterSetupMenuItem->Enabled = true;
        PictureLoaded = true;
	}
}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::ExitMenuItemClick(TObject *Sender)
{
	// exit the application
    Application->Terminate();
}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::PrinterSetupMenuItemClick(TObject *Sender)
{
	// use the Printer Setup dialog box
	PrinterSetupDialog1->Execute();
}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::FormShow(TObject *Sender)
{
	// on form show event handler

	PictureLoaded = false;
	PrintToPrinterDestinationMenuItem->IsChecked = true;
	PrintToFileDestinationMenuItem->IsChecked = false;

	// populate the ComboBox with the printer device names
	PrintersComboBox->ItemIndex = 0;
	for (int i = 0; i < Printer::Printer()->Count-1; i++) {
		PrintersComboBox->Items->Add(Printer::Printer()->Printers[i]->Title);
		// set the ComboBox ItemIndex to the active printer
		if (Printer::Printer()->Printers[i]->Title == Printer::Printer()->ActivePrinter->Title) {
			PrintersComboBox->ItemIndex = i;
		}
	}
}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::PrintToPrinterDestinationMenuItemClick(TObject *Sender)
{
	// set menu item checked for print to printer
	PrintToPrinterDestinationMenuItem->IsChecked = true;
	PrintToFileDestinationMenuItem->IsChecked = false;
	// set PrintDialog PrintToFile checkbox off
	// Note: to allow user to override the menu item - make sure
	//   PrintDialog Options poPrintToFile is set to true
	//   so that the PrintToFile checkbox appears in the dialog
	PrintDialog1->PrintToFile = false;
}
//---------------------------------------------------------------------------

void __fastcall TMainFMXForm::PrintToFileDestinationMenuItemClick(TObject *Sender)
{
	// set menu item checked for print to file
	PrintToPrinterDestinationMenuItem->IsChecked = false;
	PrintToFileDestinationMenuItem->IsChecked = true;
	// set PrintDialog PrintToFile checkbox on
	// Note: to allow user to override the menu item - make sure
	//   PrintDialog Options poPrintToFile is set to true
	//   so that the PrintToFile checkbox appears in the dialog
	PrintDialog1->PrintToFile = true;
}
//---------------------------------------------------------------------------

The VCL and FMX applications in Action

VCL app in action
FMX app in action

References

VCL Printing

Printing in VCL Applications
Vcl.Printers

FMX Printing

Printing from a FireMonkey Application
FMX.Printer

YouTube Videos

Creating your First VCL Application for Windows with C++Builder
Creating Your First C++ Windows App
Why C++Builder?

Source Code

Source Code for VCL and FMX printing projects (zip file)

About C++Builder

C++Builder Product Page – Native Apps that Perform. Build Windows C++ Apps 10x Faster with Less Code

C++Builder Product Editions – C++Builder is available in four editions – Professional, Enterprise, Architect and Community (free). C++Builder is also available as part of the RAD Studio development suite.

Technology News Worth Reading

Here are a few technology news stories that I’ve read in the past week or so.

News Headlines

Reading Code Is a Skill

The problem is not that we shouldn’t write readable code. Of course we should aim to write readable code, if only for our own poor selves further down the line (there is no one less capable of reading my code the following week than me). The problem is that these two issues are not mutually exclusive. It’s not “write readable code” or “learn to read code”. Read the DZone article by Trisha Gee.

When a digital twin becomes the evil twin

A digital twin is a digital replica of some physical entity, such as a person, a device, manufacturing equipment, or even planes and cars. The idea is to provide a real-time simulation of a physical asset or human to determine when problems are likely to occur and to proactively fix them before they actually arise. Read the InfoWorld article by David Linthicum.

The NVIDIA-Arm merger could change how we work

If the merger between Arm and NVIDIA is approved (I expect Great Britain, the EU, and China will have reservations), the result could be a massive change in AI capability. And, given that Arm is dominant in mobile devices and IoT, and NVIDIA is dominant in both graphics and AI training, it’s a merger that could have a dramatic impact on how we work as well. Read the ComputerWorld article by Rob Enderle.

Don’t write off government algorithms: Responsible AI can produce real benefits

There are many cases in which government bodies can deploy AI technology in lower risk, high-impact scenarios that can improve lives, particularly if they don’t directly use personal data. So before we leap full pelt into AI cynicism we should consider benefits as well as risks it offers, and demand a more responsible approach to AI development and deployment. Read the TechXplore article by Allison Gardner.

Postman’s New Schema Validation Feature Helps Encourage API Spec Literacy

Postman, an API development platform provider, has announced that its API Builder is gaining the ability to validate API schemas in real-time via a new UI pane that is accessible in the tool’s define tab. The addition of this functionality helps to provide developers with real-time feedback and encourage API specification literacy. Read the ProgrammableWeb article by Kevin Sundstrom.

Microsoft open-sources fuzzing test framework

Microsoft is looking to help developers continuously fuzz-test code prior to release, via the open source OneFuzz framework. Described as a self-hosted fuzzing-as-a-service platform, OneFuzz enables developer-driven fuzzing to identify software vulnerabilites during the development process. Read the InfoWorld article by Paul Krill. Access the OneFuzz framework on GitHub.

IoT Platform – Binding the IoT Ecosystem Together

The word IoT has meant many different things to different people, none of it is wrong in any sense. It has been just a matter of perspective. Device and sensor manufacturers think of it as the sensors at the center of the IoT ecosystem with some connectivity and software around the sensors to capture and transmit data. Network services providers think of IoT as a secure network that connects a bunch of commodity sensors to a backend data store. BI and Big Data platform providers think of their role in IoT as the most important; after all if you cannot process a large amount of data coming through and extract intelligence from it, what’s the point in putting all these sensors and networks in place. Read this DZone article by Seemant Ahuja

Tourists on Tech’s Toll Roads

The recent trend is toward systems that are increasingly more closed. Unfortunately it’s only the latest in an ongoing cycle throughout the history of computing between open highways and private roads. Each swing in the pendulum moves from public, open, shared innovation that lays the open roads to private companies who use those public roads to build their for-profit toll roads. Those companies fight to ensure that no matter what signs you follow, you end up on their private road. Read the blog post by Kyle Rankin.

4 Python type checkers to keep your code clean

Over the last few years, though, Python has added support for type annotations, inspiring a whole culture of software devoted to type checking Python during development. Python doesn’t check types at runtime — at least, not yet. But by taking advantage of a good type checker, riding shotgun with you in your IDE of choice, you can use Python’s type annotations to screen out many common mistakes before they hit production. Read the InfoWorld article by Serdar Yegulalp.

Interview with Homage’s Gillian Tee on how technology can serve the world’s aging population

According to the United Nations, the fastest-growing age bracket worldwide is aged 65-years-old and older. At the same time, there is also an acute shortage of caregivers in many countries, complicated by high rates of burnout in the profession. Read the TechCrunch interview with Homage’s co-founder and chief executive Gillian Tee in an article by Catherine Shu.

Refactoring from single to multi purpose

For the second time this year I’m refactoring a program from a single purpose to have two or more modes of operation. Both times the start and end result is similar, just the processing is different. A classic case of using polymorphism. The first program was a tool to process videos from speakers, find a face and export the subframe around it into a new video. The first mode was a good approach to test it, and gave results for some speakers. The second mode did a complete scan first, and then gave a smoother video for some videos. Read the Meeting C++ blog post by Jens Weller.

Two VCL Example Applications that Use C++Builder and the C++ Boost Libraries

Boost is a set of open source C++ libraries that build on the ISO C++ programming language. In some cases, the Boost library functionality has become part of recent ISO C++ standards. RAD Studio allows you to install a subset of Boost that has been fully tested and preconfigured specifically for C++Builder. Use the GetIt Package Manager to install the Boost libraries for the Win32 classic C++ compiler, Win32 Clang-enhanced C++ compiler and Win64 Clang-enhanced compiler.

Boost libraries available in C++Builder’s GetItPackage Manager

boost::filesystem and std:filesystem VCL example

The ISO C++ std::filesystem evolved from the Boost filesystem library. The Filesystem library started in Boost, then became an ISO C++ Technical Specification and was finally merged into the ISO C++17 standard. The first example shows how to create a C++Builder VCL application using the Boost filesystem and the ISO C++ filesystem.

The VCL form contains two TButton, one TEdit and two TMemo components. The TEdit is used to set a path to files and directories on your hard drive. One button OnClick event handler will use the boost::filesystem functions to display the contents of the path. The other button OnCLick event handler will use the std::filesystem functions to display the contents of the same path. Why use both libraries? You may have an application and compiler than does not support the latest C++17 filesystem library standard. There are additional boost library versions available to support a wider range of platform filesystem operations.

VCL form for Boost and Std filesystem libraries application

C++Builder VCL application after using the boost and std filesystem library buttons

Filesystem VCL app mainunit.h:

//---------------------------------------------------------------------------

#ifndef MainUnitH
#define MainUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TButton *BoostButton;
	TEdit *Edit1;
	TMemo *Memo1;
	TButton *Cpp17Button;
	TMemo *Memo2;
	void __fastcall BoostButtonClick(TObject *Sender);
	void __fastcall Cpp17ButtonClick(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Filesystem VCL App MainUnit.cpp:

//---------------------------------------------------------------------------

#include <vcl.h>

/*
	https://en.cppreference.com/w/cpp/filesystem
	The filesystem library was originally developed as boost.filesystem,
	was published as the technical specification ISO/IEC TS 18822:2015,
	and finally merged to ISO C++ as of C++17.

	https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm
*/

#include <boost/filesystem.hpp>
namespace Boostfs = boost::filesystem;

#include <filesystem>
namespace Cpp17fs = std::filesystem;

#pragma hdrstop

#include "MainUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BoostButtonClick(TObject *Sender)
{

	// Boost Filesystem verion

	Memo1->Lines->Clear();
	// use the Boost FileSystem to get directories and files using path in editbox
	Boostfs::path directoryPath = Edit1->Text.c_str();
	for (const auto& entry : Boostfs::directory_iterator(directoryPath)) {
		Boostfs::path p = entry.path();
		// test if the path is a file
		if (is_regular_file(p)) {
			int fsize = file_size(p);
			std::string s = p.string() + " : size = ";
			Memo1->Lines->Add(s.c_str() + IntToStr(fsize));
		}
		// test if the path is a directory
		else if (is_directory(p)) {      // is p a directory?
			std::string s = p.string() + " : directory";
			Memo1->Lines->Add(s.c_str());
		}
		// otherwise it is something else :)
		else {
			std::string s = p.string() + " not a file or directory";
			Memo1->Lines->Add(p.c_str());
		}
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Cpp17ButtonClick(TObject *Sender)
{
	// C++17 FileSystem version

	Memo2->Lines->Clear();
	// use C++17 std FileSystem library to get directories given a path in the editbox
	Cpp17fs::path directoryPath = Edit1->Text.c_str();
	for (const auto& entry : Cpp17fs::directory_iterator(directoryPath)) {
		Cpp17fs::path p = entry.path();
		if (Cpp17fs::is_directory(p)) {
			std::string s = p.string() + " : directory";
			Memo2->Lines->Add(s.c_str());
		}
		else if (Cpp17fs::is_regular_file(p)) {
			int fsize = Cpp17fs::file_size(p);
			std::string s = p.string() + " : size = ";
			Memo2->Lines->Add(s.c_str() + IntToStr(fsize));
		}
		else {
			std::string s = p.string() + " not a file or directory";
			Memo2->Lines->Add(p.c_str());
		}
	}
}
//---------------------------------------------------------------------------

boost::circular_buffer VCL example

The boost circular buffer (also known as a ring or cyclic buffer) library allows for the storing of data. The boost is designed to support fixed capacity storage. When the buffer is full, additional elements will overwrite existing elements at the front and back of the buffer (depending on the operations used).

The VCL form contains three TButton, one TSpinEdit and one TMemo components. One TButton OnClick event handler shows the contents of the circular buffer (originally populated by the Form’s OnShow event handler. The other two TButton OnClick event handlers use the boost circular buffer push_front and push_back public member functions.

Boost circular buffer C++Builder VCL form
C++Builder VCL form with Circular Buffer populated by OnShow event handler
Application showing contents of Circular Buffer after Add to front button is clicked
Application showing contents of Circular Buffer after Add to back button is clicked
Circular Buffer VCL app mainunit.h:

//---------------------------------------------------------------------------

#ifndef MainUnitH
#define MainUnitH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.Samples.Spin.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TButton *AddToCircularQueueFrontButton;
	TSpinEdit *SpinEdit1;
	TMemo *Memo1;
	TButton *ShowCircularBufferButton;
	TButton *AddToCircularQueueBackButton;
	void __fastcall FormShow(TObject *Sender);
	void __fastcall ShowCircularBufferButtonClick(TObject *Sender);
	void __fastcall AddToCircularQueueFrontButtonClick(TObject *Sender);
	void __fastcall AddToCircularQueueBackButtonClick(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Circular Buffer VCL app mainunit.cpp:

//---------------------------------------------------------------------------

#include <vcl.h>
#include <boost/circular_buffer.hpp>
#pragma hdrstop

#include "MainUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

// Create a circular buffer with a capacity for 3 integers.
boost::circular_buffer<int> cb(3);

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
	// initialize circular buffer with 3 integers
	cb.push_back(1);
	cb.push_back(2);
	cb.push_back(3);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ShowCircularBufferButtonClick(TObject *Sender)
{
	int circularbuffersize = cb.size();
	Memo1->Lines->Clear();
	Memo1->Lines->Add("Circular Buffer Size = "+IntToStr(circularbuffersize));
	Memo1->Lines->Add("Items:");
	// display items in the circular buffer
	for (int i : cb)
		Memo1->Lines->Add("  "+IntToStr(i));
}
//---------------------------------------------------------------------------

void __fastcall TForm1::AddToCircularQueueFrontButtonClick(TObject *Sender)
{
	cb.push_front(SpinEdit1->Value);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::AddToCircularQueueBackButtonClick(TObject *Sender)
{
	cb.push_back(SpinEdit1->Value);
}
//---------------------------------------------------------------------------

References

Boost C++Builder DocWiki

Boost C++ Libraries home page

Boost version 1.70

Converting from Boost to std::filesystem by Scott Furry as a guest post on Bartlomiej Filipek (Bartek) blog.

boost::filesystem library documentation

C++ std::filesystem documentation

boost::circular_buffer documentation

boost and std filesystem VCL app source code project (zip file)

boost circular buffer VCL app source code project (zip file)

C++Builder Product Information

C++Builder Product Page – Native Apps that Perform. Build Windows C++ Apps 10x Faster with Less Code
C++Builder Product Editions – C++Builder is available in four editions – Professional, Enterprise, Architect and Community (free). C++Builder is also available as part of the RAD Studio development suite.

Building a C++Builder RSS Feeds VCL Application with XMLDocument, NetHTTPClient, NetHTTPRequest and WebBrowser Components

I have many favorite prebuilt components that are included with C++Builder 10.4 Sydney. In this blog post I’ll show you how to create an RSS Feeds VCL (you can also use the same approach for a FireMonkey FMX) application using the XMLDocument, NetHTTPClient, NetHTTPRequest and WebBrowser components.

Start by creating a C++Builder VCL application. Set the form’s WindowState property to wsMaximized. Add a Panel, Button, ListBox (used to hold the list of RSS feed URLs to process) and a few labels and align them to the top of the form. Add Memo (to display the Feed XML), ListBox (to contain the title and URL for each article found in the feeds) and WebBrowser (to display the web page when you click on an item in the articles list box) components to the rest of the form.

Main Form
The RSS Feed application’s main form.

To populate the Panel’s listbox, I use a text file, “FeedsList.txt”, which contains a number of RSS feed URLs. The panel listbox is populated in the Form’s OnShow event handler.

Clicking on the button will process all of the RSS feed URLs and add each article and URL item found into the list box of articles found.

The XMLDocument component has a DOMVendor property to select the DOM implementation to use for parsing and manipulating the XML document.

DOMVendor choices

Clicking on an item in the articles list box uses the OnClick event handler to call the WebBrowser Navigate method  for the selected article URL. In C++Builder 10.4 Sydney there is a new property added to the WebBrowser component that lets you choose which browser engine will be used on Windows. I’ve chosen the EdgeIfAvailable engine.

SelectedEngine

Here is the contents of the FeedsList.txt file:

https://isocpp.org/blog/rss
https://herbsutter.com/feed/
http://feeds.hanselman.com/scotthanselman
http://feeds.dzone.com/home
https://news.ycombinator.com/rss
http://www.odbms.org/feed/
https://www.techmeme.com/feed.xml
https://techcrunch.com/feed/
http://feeds.feedburner.com/oreilly/radar/atom
http://feeds.feedburner.com/appdevelopermagazine
https://www.infoworld.com/index.rss
https://newsroom.ibm.com/announcements?pagetemplate=rss
https://www.computerworld.com/index.rss
https://techxplore.com/rss-feed/
https://sdtimes.com/feed/
https://www.geeksforgeeks.org/feed/
https://feeds.feedburner.com/venturebeat/SZYF
http://feeds.feedburner.com/ProgrammableWeb

Here is a bitmap of the running application:

Finally here is the source code for the application:

//---------------------------------------------------------------------------

#include <vcl.h>
#include <fstream>
#pragma hdrstop

#include "MainFeedUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ArticlesFoundListBoxClick(TObject *Sender)
{
	// for the ListBox item clicked - get the URL and Browse to the article
	LabelStatus->Caption = ArticlesFoundListBox->Items->Names[ArticlesFoundListBox->ItemIndex];
	ArticleWebBrowser->Navigate(ArticlesFoundListBox->Items->Values[ArticlesFoundListBox->Items->Names[ArticlesFoundListBox->ItemIndex]]);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
	// Find and save Title and URL for items found
	std::ofstream fs (AnsiString(FormatDateTime("yyyy-mm-dd-hhnnss",Now())+"_RSSFound.txt").c_str());
	fs << AnsiString("RSS Feed for: "+ NetHTTPRequest1->URL).c_str() << std::endl;
	fs << AnsiString(FormatDateTime("dddd mmmm dd, yyyy @ hh:nn:ss",Now())).c_str() << std::endl;
	fs << std::endl;

	// Clear the Articles Found List Box to prepare for the title and URL of articles
	ArticlesFoundListBox->Clear();
	FeedsItemsCountLabel->Caption = "Items Found = 0";

	// get all articles and URLs in all feeds
	for (int i = 0; i < FeedsListBox->Count; i++) {
		// Get the RSS feed URL string from the ListBox
		NetHTTPRequest1->URL = FeedsListBox->Items->Strings[i];

		UrlLabel->Caption = "Feed URL: "+NetHTTPRequest1->URL;
        UrlLabel->Update();

		// Use NetHTTPRequest Execute method to get the RSS Feed XML
		UnicodeString FeedString = NetHTTPRequest1->Execute()->ContentAsString();

		// copy the XML string to the Memo
		MemoFeedXML->Lines->Clear();
		MemoFeedXML->Lines->Text = FeedString;
		MemoFeedXML->Update();

		// load the RSS Feed XML into the XMLDocument
		XMLDocument1->LoadFromXML(FeedString);
		XMLDocument1->Active = True;

		LabelStatus->Caption = "Processing RSS for "+NetHTTPRequest1->URL;
		LabelStatus->Update();

		// find the RSS feed channel node
		_di_IXMLNode ChannelNode = XMLDocument1->DocumentElement->ChildNodes->FindNode ("channel");
		// test to make sure the ChannelNote is found
		if (ChannelNode != NULL) {
			for (int I=0;I<ChannelNode->ChildNodes->Count;I++) {
				// iterate through child nodes
				_di_IXMLNode ItemNode = ChannelNode->ChildNodes->Get(I);
				// if child node is an item then get the title, pubDate and URL
				if (ItemNode->NodeName == "item") {
					LabelStatus->Caption = "Processing Node " + IntToStr(I);
					LabelStatus->Update();
					UnicodeString title = ItemNode->ChildValues ["title"];
					UnicodeString pubDate = ItemNode->ChildValues ["pubDate"];
					// author := ItemNode.ChildValues ['author'];    // could be nil
					UnicodeString url = ItemNode->ChildValues ["link"];

					// populate the articles found ListBox with the pair of title and URL
					ArticlesFoundListBox->Items->AddPair(title,url);
					ArticlesFoundListBox->Update();
					FeedsItemsCountLabel->Caption = "Items Found = "+IntToStr(ArticlesFoundListBox->Count);
					FeedsItemsCountLabel->Update();

					// write the Title, pubDate and URL to the text file
					fs << AnsiString(title).c_str() << std::endl;
					fs << AnsiString(pubDate).c_str() << std::endl;
					fs << AnsiString(url).c_str() << std::endl;
					fs << std::endl;
				}
			}
		}

	}

	fs << std::endl;
	fs << AnsiString("Items Found = "+IntToStr(ArticlesFoundListBox->Count)).c_str() << std::endl;
	fs << "end of file" << std::endl;
	fs.close();   // close the text file
	LabelStatus->Caption = "RSS Processing Done!";
    UrlLabel->Caption = "";
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
	// load RSS Feeds ListBox with the "FeedsList.txt" text file
    // I put the text file in the same folder as the app .EXE file
	FeedsListBox->Items->Clear();
	FeedsListBox->Items->LoadFromFile("FeedsList.txt");
	LabelStatus->Caption = "RSS Feed Urls Loaded = "+IntToStr(FeedsListBox->Count);
	LabelStatus->Update();

}
//---------------------------------------------------------------------------

References

Using TXMLDocument

Using the Document Object Model

Using an HTTP Client

System.Net.HttpClientComponent.TNetHTTPClient

System.Net.HttpClientComponent.TNetHTTPRequest

Using TEdgeBrowser Component and Changes to the TWebBrowser Component

RSS 2.0 Specification

Download Source Code ZipFile for RSSFeedListsUsingTextFileVCLCpp

C++Builder Product Information

C++Builder Product Page – Native Apps that Perform. Build Windows C++ Apps 10x Faster with Less Code
C++Builder Product Editions – C++Builder is available in four editions – Professional, Enterprise, Architect and Community (free). C++Builder is also available as part of the RAD Studio development suite.

Using C++Builder to list all available VCL styles in a ComboBox and apply a selected style using the ComboBoxChange event

Back in June a developer asked a C++Builder question on StackOverflow. The question was “How can I list all the available VCL styles in a combo box and in the ComboBoxChange event, apply that style in C++ Builder?” I answered the question and gave the example code.

One of my favorite RTL features for the VCL and FMX frameworks is the ability to customize the look and feel of your applications using Styles. The first step is to create a C++Builder VCL project and select a few of the VCL Styles in the Project | Options | Application | Appearance settings. The C++Builder 10.4 Sydney DocWiki explains that “the VCL Styles architecture has been significantly extended to support High-DPI graphics and 4K monitors. In 10.4 Sydney all graphical elements are automatically scaled for the proper resolution of the monitor the element is displayed on. This means that the scaling depends on the DPI resolution of the target computer or the current monitor, in case of multi-monitor systems.”

The C++ Application User Interface

For the application user interface I have a TButton (has code to populate the ComboBox with selected application styles) and a TComboBox (to display and allow selection of a style).

The C++ code

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include <Vcl.Themes.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	// populate the ComboBox with VCL styles that are selected
	//    in Project | Options | Application | Appearance
	ComboBox1->Items->BeginUpdate();
    try
    {
		ComboBox1->Items->Clear();

		DynamicArray<String> styleNames = Vcl::Themes::TStyleManager::StyleNames;

        for(int i = 0; i < styleNames.Length; ++i)
        {
            String styleName = styleNames[i];
			ComboBox1->Items->Add(styleName);
        }
    }
    __finally
    {
		ComboBox1->Items->EndUpdate();
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
	// set the style for the selected combobox item

	Vcl::Themes::TStyleManager::TrySetStyle(ComboBox1->Items->Strings[ComboBox1->ItemIndex],false);
}
//---------------------------------------------------------------------------

The Application in Action

TComboBox populated with VCL styles selected
Application Style Changed by TComboBox selection

References

VCL Styles Overview

Project Options Application Appearance

VCL Styles Support for High-DPI Graphics

C++Builder Product Information

C++Builder Product Page – Native Apps that Perform. Build Windows C++ Apps 10x Faster with Less Code
C++Builder Product Editions – C++Builder is available in four editions – Professional, Enterprise, Architect and Community (free). C++Builder is also available as part of the RAD Studio development suite.