Solved

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

Posted on 2004-04-22
6
442 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi application Soap connection 5 103
Run video youtube webbrowse 10 61
select query - oracle 16 100
Installshield for Embarcadero EX 10.1 Berlin 4 40
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 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