Solved

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

Posted on 2004-04-22
6
443 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 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