The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,628 other followers

Archive for the ‘Software Development’ Category

Mercurial/Hg; syntax/tips for amend commit adding/reming files to latest (non-pushed) commit

Posted by jpluimers on 2016/09/01

Sometimes your latest commit isn’t what you intended. Fixing can be done, but isn’t always obvious hence these links:

Remove a new file from a commit:

cp somefile.txt somefile.txt.bak
hg forget somefile.txt
hg commit --amend

If the file was new (i.e. you had used hg add).

If that file already existed try:

cp somefile.txt somefile.txt.bak
hg revert somefile.txt --rev .~1
hg commit --amend
cp somefile.txt.bak somefile.txt

–jeroen

Posted in Development, DVCS - Distributed Version Control, Mercurial/Hg, Software Development, Source Code Management | Leave a Comment »

Workaround for Printing from Delphi (or the Delphi IDE): three strikes and you get “Printer is not currently printing.” – yes I mentioned “Delphi 8!”

Posted by jpluimers on 2016/08/31

Recently when printing the 3rd time and up, you get this error in many Delphi programs and the Delphi IDE:

Printer is not currently printing.

Printer is not currently printing.

In the past this only occurred when you used a TPrinter and forgot to call BeginDoc.

But now it always occurs after reusing the same TPrinter instance for the 3rd time and up. Since the Delphi Galileo based IDEs (8 and higher; likely older ones as well: the source code printing hasn’t changed in a long time). The error actually occurs twice: after starting a source code print job, but also after cancelling the same failed source code print job.

The second error stroke me as odd, so I went searching for “printer is not currently printing” “IDE” leading to this stack overflow question: c++builder – Why is TPrinter (XE7) suddenly having problems today? – Stack Overflow [WayBack].

The pattern there is using the Printer() function which has been the way the (un)official code examples have shown for ages (Delphi 2007 Printers.Printer Function [WayBack]; earlier examples like Delphi 7 [WayBack] usually in PDF files).

Like in the Delphi 7 “5-32 Developer’s Guide” page example:

procedure TForm1.Button1Click(Sender: TObject); 
var
  r: TRect;
  i: Integer;
begin
  with Printer do
  begin
    r := Rect(200,200,(Pagewidth - 200),(PageHeight - 200)); 
    BeginDoc;
    Canvas.Brush.Style := bsClear;
    for i := 0 to Memo1.Lines.Count do
      Canvas.TextOut(200,200 + (i * Canvas.TextHeight(Memo1.Lines.Strings[i])),
    Memo1.Lines.Strings[i]); 
    Canvas.Brush.Color := clBlack;
    Canvas.FrameRect(r);
    EndDoc; 
  end;
end;

(Yes, that’s back in the D7 days when examples were still using with and not using try/finally statements for resource cleanup).

Actual cause and permanent fix

The printing problems are caused by various recent Windows updates part of MS16-098:

Though MS16-098: Security update for Windows kernel-mode drivers: August 9, 2016 mentions the issue without a fix, KB3177725 in MS16-098: Description of the security update for Windows kernel-mode drivers: August 9, 2016 mentions both the issue and a permanent fix:

After you apply this security update and you print multiple documents in succession, the first two documents may print successfully. However, the third and subsequent documents may not print.

To resolve this issue, install update 3187022. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

3187022 Print functionality is broken after any of the MS16-098 security updates are installed

This article describes printing issues that occur after any of the security updates that are described in Microsoft Security Bulletin MS16-098 are installed in Windows. You can fix these issues by installing the update that is described in this article. Before you install this update, check out the Prerequisites section.

This update applies to the following operating systems:

  • Windows Server 2012 R2
  • Windows 8.1
  • Windows RT 8.1
  • Windows Server 2012
  • Windows Server 2008 R2 Service Pack 1 (SP1)
  • Windows 7 SP1
  • Windows Server 2008 Service Pack 2 (SP2)
  • Windows Vista SP2

No solution for Windows 10 yet…

Until you install the fix: workarounds

For your own code (Thanks Remy Lebau for your answer), add this code for your BeginDoc call:

MyPrinter.Copies := MyPrinter.Copies;

You might want to keep including this in your code as you’re never sure when the end-users apply which Windows update.

For the Delphi IDE either:

  1. Press the “Setup…” button in the “Print Selection” dialog when printing source code, then “OK” in the “Print Setup” dialog:
    Print Selection dialog

    Print Selection dialog

    “Print Setup” dialog.

  2. Uninstall the security updated marked in blue (Security Update for Microsoft Windows (KB3177725):

    Security Update for Microsoft Windows (KB3177725)

    Security Update for Microsoft Windows (KB3177725)

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 8, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

UCL as a Delphi package name suffix – remember before the KSDev days?

Posted by jpluimers on 2016/08/31

A while ago, I noticed the UCL as a suffix in a few 3rd party Delphi package names.

It was from a version close to the very first FireMonkey release. FireMonkey is based on the OpenGL based VGScene (and in part DirectX based DXScene) which was bought form KSDev in 2011.

Contrary to VGScene and DXScene, the early versions of FireMonkey were buggy and when updating to a new version you had to cope with a lot of breaking interface changes. In Delphi XE2 for instance, there were two totally different implementations (FMX for Windows and OS X; FMI for iOS) that merged after Delphi XE3.

Around Delphi XE6 it became more stable and now – apart from some design issues I wish they had done differently – it is coming along sort of OK for Windows and OK for cross-platform development.

Compared to the VCL you have a lot less HiDPI issues but the designer is much more layered (which gives you the same design-time pain as WPF) and the default “Live Binding” is still buggy as hell (though if you use something like MVVM or roll your own UI bindings it becomes bearable).

A long time ago – during the Kylix era – Borland developed the cross-platform CLX library which – for the UI part – was based on Qt and ran on both Windows and Linux.

It looks like before the KSDev take over there seemed to be a UCL (would that have been for Universal Component Library or Universal Control Library?) as the name pops up in quite a few package names.

Browsing through the source code I could not find any hints so I really wonder what UCL was about. Was it again based on Qt (which compared to the Kylix era has become much more mature and has widespread use) or a different technology like LCL (given that in Delphi XE2 they used FreePascal to compile for iOS)? I rule out OpenGL as otherwise the VGScene acquisition would have been done a lot earlier.

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 6, Delphi 7, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, FireMonkey, Kylix, OS X FMX, Software Development | Leave a Comment »

defunkt/gist – ruby gist gem to upload github gists from the console

Posted by jpluimers on 2016/08/31

Cool! No more copy-paste, just upload examples directory from the console through the Ruby gist gem:

The gist gem provides a gist command that you can use from your terminal to upload content to https://gist.github.com/.

Yes, you need Ruby and RubyGems. Deal with it (:

Of course there are more of these, see A list of Gist clients..

–jeroen

via: defunkt/gist.

Posted in Development, Ruby, Software Development | Leave a Comment »

Cool little trick to show all the preset variables for your GCC/Clang compiler

Posted by jpluimers on 2016/08/30

Thanks David Berneda for sharing this a while ago:

Cool little trick to show all the preset variables for your GCC/Clang compiler:

clang -E -dM - < /dev/null

I’ve always wondered how to get these. Some are kind of surprising, especially since there are 320 of them, at least on my system.

On my system (Mavericks, I wish the sw_vers console tool would tell that): 170 lines.

Read the rest of this entry »

Posted in C, C++, Development, OS X, Power User, Software Development | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 1,628 other followers

%d bloggers like this: