Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

0
Comment
Question by:Jerry_Pang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 500 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

670 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