Tag Archives: windows api

Delayed Close Programmatically Dropped TComboBox (If Mouse NOT Over Combo and Combo’s List) Using Multi Threading

The Combo Box Windows control (aka TComboBox in Delphi) is one of the most frequently used user interface elements along with buttons and edits in Windows applications. TComboBox control represents an edit box with a scrollable drop-down list attached to it. Users can select an item from the list or type directly into the edit box. When the Style property is set to csDropDownList the combo allows to display a list of predefined items a user can select from the combo’s drop down list.

I’ve had a request from a user of my application: can the selection list be dropped down and then closed if no selection has been made in some period of time? Well, the user is asking. So, certainly it can!

The task to drop combo’s list is super easy: just set DroppedDown property to true (this sends CB_SHOWDROPDOWN to the combo). Then wait – but do not block the main thread !! – so some multithreading needed. Ok, use Delphi’s PPL. Finally, once the wait period is over, close the combo’s list – but, let’s say, only if the user is not hovering the mouse over combo’s items!

Looks pretty straightforward.
Continue reading

Receive Windows Messages In Your Custom Delphi Class – NonWindowed Control/Object

Windows messages are a key ingredient in communication between Windows and (your) application and also in communication between (two) applications.

Even without your knowledge Windows messages are being posted and handled by forms in your application.

For example, when the user closes the form in your application, the WM_CLOSE message is sent to the window/form and the form gets closed (if you do not react programmatically).

For an application to receive a Window message, the application must provide a *window* a message will be sent to. In normal situation this window is the (main) form in your application. You write a procedure to handle a specific message, like WM_NCHitTest, and you are done.

BUT, what if you do NOT have a window to receive a message? What if you want to handle messages in your custom class derived from TObject?
Continue reading

gZoom – Delphi Implementation of the Missing Mode in Windows Magnifier

gZoom in actionAh, nostalgia.
Here’s a small Delphi program I wrote some 20+ years ago. As far as I can remember this was one of my first (maybe even the first one really) Delphi applications which would not fall into the “hello world” category. Back then I was quite impressed how easy was to call Windows API functions directly from Delphi code to create small but powerful (and hopefully not useless) programs. The original code (I think days of Delphi 2 or 3), as the case is with Delphi, compiles without too much editing even today in RAD Studio 10.X.

If you are familiar with the application called “Magnifier” (comes with Windows as a part of Ease of Access features) then you already know its desired purpose: it displays zoomed in portion of the screen. Now, Magnifier has 3 modes: full screen, lens and docked. What is missing in Magnifier (even today with Windows 10) is the ability to enlarge the part of the screen that is below the mouse and display in a separate freely positioned window.
Continue reading