Mar 122017
 

For my dzComputerInfo tool I created a window without a title that can still be moved with the mouse. This is quite easy to do:

  1. To remove the title, set BorderStyle to bsNone.
  2. To let the user move it with the mouse, add the following message handler:
type
  TMyForm = class(TForm)
  private
    procedure WMNCHitTest(var Msg: TWMNcHitTest); message WM_NCHITTEST;
  end;

procedure TMyForm .WMNCHitTest(var Msg: TWMNcHitTest);
begin
  inherited;
  if (Msg.Result = htClient) then
    Msg.Result := htCaption;
end;

It tells Windows, that the user clicked on the title rather than the client area. Windows then does the rest, and the user can move the window with the mouse as if he clicked on the window title.

If you also want the window to have a context menu, you’ll have to change the message handler, so it does not affect right mouse clicks:

procedure TMyForm .WMNCHitTest(var Msg: TWMNcHitTest);
var
  Res: SmallInt;
begin
  inherited;
  Res := GetKeyState(VK_RBUTTON);
  if Res >= 0 then
    // only if the right mouse button was not pressed
    // (otherwise the popup menu wont show)
    if (Msg.Result = htClient) then
      Msg.Result := htCaption;
end;
Mar 122017
 

USB serial converters from FTDI are quite popular. We also use them at work quite a lot because they do not have the problem of the competing products (like Prolific): Windows does not detect devices on them as Microsoft ball point devices.

These converters can be configured interactively using a dialog accessible from the hardware manager’s device property dialog, page “Port Settings” by pressing the “Advanced …” button.

There are various settings, the most common ones to change are

  • COM Port Number
  • BM Options: Latency Timer
  • Miscellaneous Options: Serial Enumerator

The first one is obvious: It sets the COM port number of the emulated serial port. Every converter ever connected to the computer will reserve one COM port, so if you attach many of them you will sooner or later get rather high port numbers which many tools cannot use. The workaround is to force the driver to use a particular COM port here.

The second one, Latency Timer is not that obvious: It sets the latency timer in milliseconds to be used when the data received is not large enough to fill the buffer. Reducing this value from the default 16 to e.g. 4 solves many problems where data is being received with a delay of several seconds (e.g. the GPS position displayed is lagging behind your vehicle position by several seconds, which results in several 10th of metres at higher velocities. I have seen 4 seconds which at 60 km/h equals about 80 metres.)

The last one, Serial Enumerator, solves the Microsoft Ball Point detection mentioned above. As long as it is checked and a device is attached that sends data, Windows might mistakenly think it’s a mouse and the mouse cursor will jump all around the screen and even randomly click everywhere. This is quite annoying when it happens (and it happens very often when you connect a GPS). To resolve the problem, uncheck this option.
(Btw: Microsoft Ball Point devices have not been in use for over a decade, but the bug is still present in Windows XP, 7 and 8/8.1. (don’t know about Windows 10) despite users having problems because of it for many years. Shame on you, Microsoft!)

Mar 122017
 

I managed to mess up my blog. The content is still there, but all the screenshots are missing since apparently they are not part of the export. Fortunately my hoster 1&1 makes a daily backup of my webspace which is stored for 6 days, so I could restore the pictures. (After praising them, let me add that I lost the data because their automatic conversion from managed to normal blog did not work, so I tried to revert, which deleted everything.)

%d bloggers like this: