Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Programmable Change Component Palette of Delphi IDE

This guide covers programmable change component palette of delphi ide with straightforward explanations, key considerations.

Table of Contents

The sections below explain programmable change component palette of delphi ide in a clear and practical way. Review the key details, examples, and considerations before applying the information.

If you often work with Delphi, if Delphi has installed many components and if you always have to use many components in your projects, then you will ever get tired. Are you tired of finding the desired component palette icon on the Component toolbar? The Component Palette of Delphi IDE is simply a TAB-form control with a single-row header, so it will take you a long time to search when there are too many components. This article is intended to help relieve this "frustration" by setting Multi-lines properties for the TAB Component Palette control with simple tricks that you might not expect. Here I use Delphi 7 but with the lower versions there are not many changes. Introduction to Delphi IDE Delphi IDE (Integrated Development Environment) is Delphi's integrated development environment. Depending on the specific version of Delphi, Delphi IDE components also have certain changes. For example, in Delphi 7, the IDE consists of five main components: 1. Delphi main window : The code name of this window is TAppBuilder . This window includes menus, toolbars, and a panel of development tools (Component Palette). 2. FORM design window : This is the actual window for your application program. Start the window as a FORM every time you start Delphi. 3. Object Inspector window : The window Name of the window is TPropertyInspector . This is the window that allows you to change the properties for the component on the FORM such as title, name. in an intuitive way. 4. Code Editor code editor window : The code name of the window is TEditWindow . This is the place to actually show the content of the program, where you type the command, design the content for the procedure, give the function and install the methods for the class. 5. Object TreeView Window : The window Name of the window is TObjectTreeView . The window will show you a visual way of the parent order of components present on FORM. Delphi IDE itself is a assembly environment. Delphi opens up for you many approaches to change and edit to fit and facilitate each individual. For example, the Component Palette Of Delphi IDE is actually a TTabControl Object no more or less. You can see this through a piece of code used to install the TAppBuilder Window. Object TabControl: TComponentPaleAppBuildertteTabControl Left = 0 Top = 0 Width = 64 Height = 47 Align = alClient Constraints. MinWidth = 20 HotTrack = True PopupMenu = PaletteMenu TabOrder = 0 TabStop = False OnChange = TabControlChange OnDragDrop = TabControlDragDrop OnDragOver = TabControlDragOver OnEndDrag = TabControlEndDrag OnMouseDown = TabControlMouseDown OnMouseMove = TabControlMouseMove OnStartDrag = TabControlStartDrag BorderStyle = bsNone OnHelpRequest = ComponentPaletteHelpRequest Object PageScroller1: TPageScroller Left = 32 Top = 6 Width = 31 Height = 39 Align = alClient AutoScroll = True TabOrder = 0 OnScroll = PageScroller1Scroll End Object Panel2: TPanel Left = 4 Top = 6 Width = 28 Height = 39 Align = alLeft BevelOuter = bvNone TabOrder = 1 SelectorButton object: TSpeedButton Left = 0 Top = 0 Width = 28 Height = 28 GroupIndex = 1 Down = True Flat = True End End End End Thus, there are two ways to set Multi-lines properties for the TAB Component Palette control. The idea of the first way is to directly change the binary code of Delphi32. exe File in the Delphi BIN folder. To do this, please add the property settings of TabControl in the code above on the following command: MultiLine = True I tried this way and the results were quite good. However, this way has a slight drawback when your Component Palette is in the Dock state on the Delphi main window, resizing is not possible (see Figure 1).

How Programmable Change Component Palette of Delphi IDE Works

Programmable Change Component Palette of Delphi IDE illustration Figure 1 : Error with how to edit delphi32. exe directly

The idea of the second way is that we will write a small component. Every time Delphi loads this component, it will be tasked to find the Delphi main window, then find the right TAB Component Palette control and directly change the TAB's MultiLine attribute. It looks like a fantasy but as mentioned, Delphi IDE is a professional assembly environment. Delphi IDE itself opens many directions for you to customize. We will step by step understand the code to perform the above tasks. Find the main window of Delphi There are many ways to find the main window of Delphi. Note, the component you are about to write is interacting directly with Delphi IDE, so you get the app window yourself as the Delphi Application window. So, in your own opinion, you can use the following code to find the main window: Function GetIdeMainForm: TCustomForm; Begin Result: = TForm (Application. FindComponent (AppBuilder)); End; Find the TAB Component Palette control To find this TAB control, use the following code: Function GetTabControl: TTabControl; Var MainForm: TCustomForm; Begin Result: = nil; MainForm: = GetIdeMainForm; If MainForm <> nil then Result: = TTabControl (MainForm. FindComponent (TabControl)) End; Find the popup menu of the TAB Component Palette control To do this, use: Function GetComponentPalettePopupMenu: TPopupMenu; Var MainForm: TCustomForm; Begin Result: = nil; MainForm: = GetIdeMainForm; If MainForm <> nil then Result: = TPopupMenu (MainForm. FindComponent (PaletteMenu)); End; We want to find this popup menu because we will add a Multi-Lines option to switch between the two states of the TAB Component Palette (see Figure 2).

Programmable Change Component Palette of Delphi IDE illustration 2 Figure 2 : New selection

The entire content of the component code can be seen in the "Source code" section. Install and use To use the newly created component, you need to install into Delphi IDE. Step 1 . Save the entire contents of the above code into a file, for example I select the file named IdeEnhancement. pas . Step 2 . Select the Install Component Function on the Component menu of Delphi IDE. A new window appears. Please declare the information as shown in Figure 3. Then click OK .

Programmable Change Component Palette of Delphi IDE illustration 3 Figure 3 : Set up information for the component

Step 3 . Delphi will ask if you immediately compile this component or not. Please boldly choose "no". Then record what you have just done. Step 4 . In the IDE's Package window, select the Install Function (see Figure 4).

Programmable Change Component Palette of Delphi IDE illustration 4 Figure 4 : Component Installation

That's it. Please close the package and then try to right-click the TAB Component Palette. You will be surprised to see the appearance of a new item named Multi-Lines . Click this option and observe the difference. (See Figure 5)

Programmable Change Component Palette of Delphi IDE illustration 5 Figure 5. Illustrating the result

If you are a bit more observant, you can easily see that my Delphi IDE is supported by Style XP (when running on Windows XP). To do this, simply create a file named Delphi32. exe. manifest With the following content:

L version="1.0" encoding="UTF-8" standalone="yes Ngo Quoc Anh Language = "*" />

Then save the same folder as the Delphi32. exe File (see Figure 6).

Programmable Change Component Palette of Delphi IDE illustration 6 Figure 6 : Illustrating XP Style for Delphi IDE

This article is really just a brief introduction to customizing Delphi IDE. Hopefully I will have another opportunity to present better tricks in programming for Delphi IDE.

Source code

IdeEnhancement unit; Interface Dùng Windows, Messages, SysUtils, Classes, Graphics, Controls, ExtCtrls, Forms, Dialogs, ComCtrls, Menus, Registry; Type TMyExpertObject = class (TComponent) Private App: TCustomForm; TabControl: TTabControl; MultiLine: Boolean; ComponentPalette Menu: TPopupMenu; // Two items selected for the popup menu that we added MultiLineItem, SeperatorItem: TMenuItem; Procedure UpdateOtherWindows (OldHeight: Integer); Procedure ResizeMultiLineComponentPalette (Sender: TObject); Function GetIdeMainForm: TCustomForm; Function GetTabControl: TTabControl; Function GetComponentPalettePopupMenu: TPopupMenu; Procedure OnMenuPopup (Sender: TObject); Procedure OnMultiLineItemClick (Sender: TObject); Procedure SetMultiLineComponentPalette (_multiLine: Boolean); Procedure CreateMenuItem (_multiLine: Boolean); Procedure DestroyMenuItem; Procedure SaveSettings; Public Constructor Create (AOwner: TComponent); override; Destructor Destroy; override; End; Var MyExpertObject: TMyExpertObject; Implementation {This is the method that will be called by Delphi every time the component is loaded. Chúng ta c?n g?i ph??ng th?c này ?? ??c thu?c tính MultiLines trong Registry} We need to call this method to read MultiLines properties in the Registry} Constructor TMyExpertObject. Create; Begin Inherited; With TRegistry. Create due Begin RootKey: = HKEY_CURRENT_USER; If OpenKey (SoftwareNgo Quoc Anh, False) then If KeyExists (MultiLines) then MultiLine: = ReadBool (MultiLines); End; End; {This is the method that will be called by Delphi every time the component frees} TMyExpertObject. Destroy destructor; Begin Inherited; End; {Record information about MultiLines in the Registry every time there is a change} Procedure TMyExpertObject. SaveSettings; Begin With TRegistry. Create due Begin RootKey: = HKEY_CURRENT_USER; If OpenKey (SoftwareNgo Quoc Anh, True) then WriteBool (MultiLines, MultiLine) End; End; {Recalculate the size of the TAB control every time there is a change} Procedure TMyExpertObject. ResizeMultiLineComponentPalette (Sender: TObject); Var AHeight: Integer; Begin V?i Sender as TTabControl Begin AHeight: = Height - (DisplayRect. Bottom - DisplayRect. Top) + 29; Constraints. MinHeight: = AHeight; ((Sender as TTabControl). Parent as TWinControl). Constraints. MaxHeight: = AHeight; End; End; {Adjust the position of the TObjectTreeView and TEditWindow Windows each time changing the size of the main form} Procedure TMyExpertObject. UpdateOtherWindows (OldHeight: Integer); Const WinClasses: array [0.1] of string = (TObjectTreeView, TEditWindow); Var AForm: TCustomForm; I, J, MainTop, HeightDelta: Integer; Begin AForm: = GetIdeMainForm; If AForm = nil then Exit; HeightDelta: = AForm. Height - OldHeight; If HeightDelta = 0 then Exit; MainTop: = AForm. Top; For I: = Low (WinClasses) to High (WinClasses) due Begin // Browse all Windows For J: = 0 to Screen. CustomFormCount - 1 due Begin // If found, resize If Screen. CustomForms [J]. ClassNameIs (WinClasses [I]) then Begin AForm: = Screen. CustomForms [J]; AForm. Top: = AForm. Top + HeightDelta; AForm. Height: = AForm. Height - HeightDelta; End; End; End; End; {Find the main window of Delphi} Function TMyExpertObject. GetIdeMainForm: TCustomForm; Begin Result: = TForm (Application. FindComponent (AppBuilder)); End; {Search TAB Component Palette} Function TMyExpertObject. GetTabControl: TTabControl; Var MainForm: TCustomForm; Begin Result: = nil; MainForm: = GetIdeMainForm; If MainForm <> nil then Result: = TTabControl (MainForm. FindComponent (TabControl)) End; {Find popup menu for TAB Component Palette control} Function TMyExpertObject. GetComponentPalettePopupMenu: TPopupMenu; Var MainForm: TCustomForm; Begin Result: = nil; MainForm: = GetIdeMainForm; If MainForm <> nil then Result: = TPopupMenu (MainForm. FindComponent (PaletteMenu)); End; This depends on your subjective mind. Procedure TMyExpertObject. OnMenuPopup (Sender: TObject); Begin End; {Settings for the OnClick event of the new selection item in the TAB popup menu} Procedure TMyExpertObject. OnMultiLineItemClick (Sender: TObject); Begin If Sender is TMenuItem then Begin MultiLine: = not (Sender as TMenuItem). Checked; // Change the Checked status of the selected item (Sender as TMenuItem). Checked: = MultiLine; // Set and record the status into the Registry SetMultiLineComponentPalette (MultiLine); SaveSettings; End; End; {Add menu item for popup menu of TAB Component Palette control} Procedure TMyExpertObject. CreateMenuItem (_multiLine: Boolean); Begin ComponentPaletteMenu: = TPopupMenu. Create (nil); ComponentPaletteMenu. OnPopup: = OnMenuPopup; ComponentPaletteMenu: = GetComponentPalettePopupMenu; // Check the existence of the previous item, if it does not already exist, create a new one If ComponentPaletteMenu. Items. Find (& Multi-Lines) = nil then Begin SeperatorItem: = TMenuItem. Create (nil); SeperatorItem. Caption: = -; // Add a separator bar ComponentPaletteMenu. Items. Add (SeperatorItem); MultiLineItem: = TMenuItem. Create (nil); MultiLineItem. Checked: = _multiLine; MultiLineItem. OnClick: = OnMultiLineItemClick; MultiLineItem. Caption: = & Multi-Lines; // Add a selection with the name Multi-Lines ComponentPaletteMenu. Items. Add (MultiLineItem); End; End; {Delete the selection of the popup menu every time the Component is released} Procedure TMyExpertObject. DestroyMenuItem; Var MI: TMenuItem; Pos: Integer; Begin MI: = ComponentPaletteMenu. Items. Find (& Multi-Lines); If MI <> nil then Begin Pos: = ComponentPaletteMenu. Items. IndexOf (MI); ComponentPaletteMenu. Items. Delete (Pos - 1); ComponentPaletteMenu. Items. Delete (Pos - 1); End; End; {Setting Multi-Lines properties} Procedure TMyExpertObject. SetMultiLineComponentPalette (_multiLine: Boolean); Var OldHeight: Integer; Begin App: = GetIdeMainForm; If App <> nil then Begin OldHeight: = App. Height; TabControl: = GetTabControl; If TabControl <> nil then Begin TabControl. MultiLine: = _multiLine; If _multiLine then Begin TabControl. OnResize: = ResizeMultiLineComponentPalette; TabControl. OnResize (TabControl); CreateMenuItem (_multiLine); End Else TabControl. OnResize: = nil; UpdateOtherWindows (OldHeight); End; App. Invalidate; End; End; {Calling every time Component is loaded} Initialization MyExpertObject: = TMyExpertObject. Create (nil); MyExpertObject. CreateMenuItem (MyExpertObject. MultiLine); MyExpertObject. SetMultiLineComponentPalette (MyExpertObject. MultiLine); {The call whenever Component is canceled} Finalization MyExpertObject. SetMultiLineComponentPalette (False); MyExpertObject. DestroyMenuItem; MyExpertObject. Free; End.

Ngo Quoc Anh VNU University, Hanoi National University Email : bookworm_vn@yahoo. com

FAQ

What is the main benefit of programmable change component palette of delphi ide?

The main benefit is a clearer understanding of the topic and a practical way to apply the information covered in this guide.

What should I check before using programmable change component palette of delphi ide?

Confirm compatibility, review the required settings, protect important data, and use the latest supported version whenever possible.

What should I do if the result is different?

Repeat the steps carefully, verify permissions and version differences, and consult the product's official support documentation for changes not shown in the article.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.