Solved

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

Posted on 2004-04-22
6
441 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 213
Help on project with Soap 10 48
FMX and jaudiotracker playing memory stream 29 67
JAudiorecorder record freezing the app 29 60
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

18 Experts available now in Live!

Get 1:1 Help Now