At the Pascal Conference 2025 in Sundern Heiko Rompel (kralle) made a presentation about a plugin (or was it a patch?) for Lazarus that automatically switched between two desktop layouts whenever you toggled between the form designer and the code editor with F12. The reasoning was simple: some windows, such as the Object Inspector, are only useful while you work in the form designer, while others only make sense next to the code editor. So why not show a different arrangement of IDE windows for each?
I found that to be a useful feature and tried adding the same capability to GExperts. It turned out to be easier than I thought and the result was the Auto Switch Desktop expert, which shipped already in GExperts 1.3.26, but I never blogged about it.
The Delphi IDE has supported named desktop layouts for a long time (the “Desktops” entries in the View menu and the toolbar combo box). You arrange the IDE windows the way you like, save that arrangement under a name, and can recall it later. The Auto Switch Desktop expert ties two of those saved layouts to the F12 key: one for the form designer and one for the code editor.
Because it builds on the IDE’s existing desktop feature, there is a bit of setup to do first:
- Arrange and save a desktop layout for working in the form designer (for example one that shows the Object Inspector).
- Arrange and save a second layout for working in the code editor.
- Open the GExperts configuration, enable the Auto Switch Desktop expert and open its configuration.
- In the “Auto Switch Desktop configuration” dialog, pick the saved desktop for the Form Designer and the saved desktop for the Code Editor.
From then on, pressing F12 to switch between the code editor and the form designer also switches to the matching desktop layout.
One important limitation: the switch is triggered only by the F12 key. If you move between the form designer and the code editor by clicking the tabs below the editor window (or otherwise with the mouse), the desktop is not switched. That is because the expert works by intercepting the F12 key press rather than by watching which view is currently active.
The feature is currently available in Delphi 2007 as well as in 10.2 Tokyo, 11 Alexandria, 12 and 13 (including the 64-bit IDE). I plan to make it available in more versions over time. For the curious, the implementation lives in GX_AutoSwitchDesktop.pas.
Since it is already part of GExperts 1.3.26 and later, you only need a current GExperts release to use it (on one of the supported Delphi versions listed above).
Discussion about this in the corresponding post in the international Delphi Praxis forum.