Solved

How to create Dockable and floatable forms that can be pinnable and tabbed?

Posted on 2004-04-22
6
440 Views
Last Modified: 2010-08-05
sites, links, tutorials, readings, book recommendation?

0
Comment
Question by:Jerry_Pang
  • 4
  • 2
6 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 10887723
Excuse me if I misunderstand, may be you talking about the MDI - Multi Document Interface.
If I am right:
 - About the Main Form   set the property FormStyle as fsMDIForm
 - About the Child Forms set the property FormStyle as fsMDIChild
emil
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 10895497
looks like this (VC++ component) http://www.codejock.com/products/dockingpane/tour_06.asp

I just want a simple native code, not buy if possible.
the only feature i want is to snap the form on the side.

another question, how do you make the application remember your last setting?
i mean, if you ran internet application, click show history, close the application.
next time you open the internet application, it remembers and displays 'show history'.
Same goes for menus, if the menu is currently uncheck, next time you open the application, it remembers that you uncheck it or not.
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 10895542
i think i found how to snap it on the side. I guess i have to add a code in the onDrag and set it to snap if x & y coordinates exceeds the parent x & y coordinates.
Now, how do i make the application remember the setting when i close the application?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:esoftbg
ID: 10896196
You can store the x & y coordinates into the Windows registry, or into a .ini file (located usualy into the application path) or into a database table - if your application uses some kind of database....
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 125 total points
ID: 10896524
An example abot the storing and retrieving Main-Form Position and Align into / from Windows registry:

unit Unit_Q_20963205;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, ToolWin, ComCtrls, Registry;

type
  TPos_Rec      =record
    App:         string;
    KeyName:     string;
    Align:       string;
    Left:        Integer;
    Top:         Integer;
    Height:      Integer;
    Width:       Integer;
  end;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private   { Private declarations }
  public    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetRegKeyName(Pos_Rec: TPos_Rec): string;
var
  S:     string;
begin
  S := '';
  with Pos_Rec do
  try
    if (KeyName<>'') then
      S := KeyName;
    if (App<>'') then
      S := S + '\' + App;
  finally
    Result := S;
  end;
end;

function  GetPosFromReg(var Pos_Rec: TPos_Rec): Boolean;
var
  B:      Boolean;
  I:      Integer;
  Reg:    TRegistry;
  S_List: TStringList;
  RegName:string;
  SA:     string;
  SL:     string;
  ST:     string;
  SH:     string;
  SW:     string;
begin
  B := False;
  SA := '';
  SL := '';
  ST := '';
  SH := '';
  SW := '';
  S_List := TStringList.Create;
  try
    Reg := TRegistry.Create;
    with Pos_Rec,Reg do
    try

      RegName := GetRegKeyName(Pos_Rec);

      if OpenKey(RegName, False) then
      try
        SA := ReadString('Align');
        SL := ReadString('Left');
        ST := ReadString('Top');
        SH := ReadString('Height');
        SW := ReadString('Width');
      except
        B := False;
      end;
    finally
      Reg.Free;
    end;
  finally
    S_List.Free;
    Pos_Rec.Align := SA;
    Val(SL, Pos_Rec.Left, I);
    if (I=0) then
    begin
      Val(ST, Pos_Rec.Top, I);
      if (I=0) then
      begin
        Val(SH, Pos_Rec.Height, I);
        if (I=0) then
        begin
          Val(SW, Pos_Rec.Width, I);
          if (I=0) then
            B := True;
        end;
      end;
    end;
    Result := B;
  end;
end;

function  SetPosIntoReg(var Pos_Rec: TPos_Rec): Boolean;
var
  Reg:    TRegistry;
  S_List: TStringList;
  RegName:string;
begin
  S_List := TStringList.Create;
  try
    Reg := TRegistry.Create;
    try
      with Pos_Rec,Reg do
      begin
        RegName := GetRegKeyName(Pos_Rec);
        OpenKey(RegName, True);
        WriteString('Align', Pos_Rec.Align);
        WriteString('Left', IntToStr(Pos_Rec.Left));
        WriteString('Top', IntToStr(Pos_Rec.Top));
        WriteString('Height', IntToStr(Pos_Rec.Height));
        WriteString('Width', IntToStr(Pos_Rec.Width));
      end;
      Result := True;
    finally
      Reg.Free;
    end;
  finally
    S_List.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  Pos_Rec:TPos_Rec;
begin
  with Pos_Rec do
  begin
    App := Application.Title;
    KeyName := 'Software\Jerry_Pang';
    Left := Self.Left;
    Top := 0;
    Height := 0;
    Width := 0;
  end;
  if GetPosFromReg(Pos_Rec) then
  begin
    Left := Pos_Rec.Left;
    Top := Pos_Rec.Top;
    Height := Pos_Rec.Height;
    Width := Pos_Rec.Width;
  end
  else
  begin
    Left := 0;
    Top := 0;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  Pos_Rec: TPos_Rec;
begin
  with Pos_Rec do
  begin
    App := Application.Title;
    KeyName := 'Software\Jerry_Pang';
    Left := Self.Left;
    Top := Self.Top;
    Height := Self.Height;
    Width := Self.Width;
  end;
  SetPosIntoReg(Pos_Rec);
end;

end.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10896598
If you use RxLibrary there is a component TFormStorage into Rx Tools palette....
If you use JEDI VCL (http://jvcl.sourceforge.net) there is a component TJvFormStorage into JvX Tools palette....

The both components are identical by usage and properties:
 if you want to use .ini file:
  - set the property IniFileName as you want to be places;
  - set the property UseRegistry as False (it is the Default value);

 if you want to use Registry:
  - set the property UseRegistry as True.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now