Caves Travel Diving Graphics Mizar Texts Cuisine Lemkov Contact Map RSS Polski
Trybiks' Dive Texts VCL Forms as Frames YAC Software
  Back

List

Charsets

Charts

DBExpress

Delphi

HTML

Intraweb

MSTest

PHP

Programming

R

Rhino Mocks

Software

Testing

UI Testing

VB.NET

VCL

WPF

Forms as Frames
Somehow I could never convince myself to using frames in Delphi (TFrame). My biggest issue was all those missing events that TForm has, such as OnCreate and OnShow. So, for some time now, I'm using standard forms that behave like frames, but descend from TForm (thus, they inherit all standard events of TForm).

The implementation of such forms is really simple - just override the CreateParams method:
  type
    TPaneForm = class(TForm)
    protected
      procedure CreateParams(var AParams: TCreateParams); override;
    end;
  ...
  procedure TPaneForm.CreateParams(var AParams: TCreateParams);
  begin
    inherited CreateParams(AParams);
    AParams.Style := AParams.Style or WS_CHILD;
  end;
TCreateParams holds the information necessary for creating a window in Windows. Things like caption, position and dimensions, style. Although CreateParams is not documented, its meaning here should be obvious. Finally, WS_CHILD creates a child window without a menu bar.

To use these forms as frames on other forms, override the CreateParams procedure in your form and then create it as any other Delphi control that is then embedded in another form:
  LPane := TPaneForm.Create(AOwner);
  LPane.Parent := AOwner;
  LPane.Visible := TRUE; // not necessary if Visible is set to TRUE in TPaneForm
And, of course, you have all TForm's properties and events, as well as full handling of Visual Form Inheritance.

Another plus side to this solution is that any form that you might have can be hosted by another form. For instance, let's say that we have several forms that configure something (a program, a component, etc.). On the one hand, sometimes you might want to show a single form only (such as formatting of an axis of a chart) or host all forms in another form (such as different tabs in a preferences dialog window).

Top

Comments
Alas!
No comments yet...

Top

Add a comment (fields with an asterisk are required)
Name / nick *
Mail (will remain hidden) *
Your website
Comment (no tags) *
Enter the text displayed below *
 

Top

Tags

VCL

Delphi


Related pages

Delphi interfaces... again

Checking "Dangling" Event Handlers in Delphi Forms

Drag-n-drop files onto the application window

Intraweb and MaxConnections

A Case for FreeAndNIL

Intraweb as an Apache DSO module

"Device not supported" in Intraweb

Automated GUI Testing

Rounding and precision on the 8087 FPU

SessionTimeout in Intraweb

Using TChart with Intraweb

Unknown driver: MySQL

TIdMessage's CharSet

Software Guarantees

Automated Testing of Window Forms

TChart - Missing Labels in Axes

Memory Leaks and Connection Explosions in DBExpress

Controlling Conditional Defines and Compilation Switches

Detecting Memory Leaks with DUnit

last_insert_id() and DBExpress

Registering Extensions

DBExpress and Thread Safety

Checking Dangling Pointers vs. the New Memory Manager

Accessing Protected Members

Objects, interfaces, and memory management in Delphi