docking forms
2 отговора
3 прегледа
docking forms
I have the following problem:
I have 2 dockable windows(forms) . And when they are docked to one the same panel , and i close the application everything is alright. But afterwards when i start the application one of them(forms) is docked properly, but the other one is not aligned properly and it's "invisible". All the information about their dockSite and coordinates i write in an *.INI file. But the major problem is that i can not determine the proper dockRect when i start the program, because there is not such an object like TDragDropObject , which is generated when the object is dragged or dropped.
Please tell me how to make those 2 dockable forms to dock properly when start the program(source or idea ).
Thanks in advance
I have 2 dockable windows(forms) . And when they are docked to one the same panel , and i close the application everything is alright. But afterwards when i start the application one of them(forms) is docked properly, but the other one is not aligned properly and it's "invisible". All the information about their dockSite and coordinates i write in an *.INI file. But the major problem is that i can not determine the proper dockRect when i start the program, because there is not such an object like TDragDropObject , which is generated when the object is dragged or dropped.
Please tell me how to make those 2 dockable forms to dock properly when start the program(source or idea ).
Thanks in advance
Аnswer... (Source)
//------------------- Project1.dpr -------------------
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
//------------------ Unit1.pas -------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, IniFiles;
type
TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Splitter1: TSplitter;
Label1: TLabel;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.ManualDock(Panel1);
if not Form2.Visible then
Form2.Show;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form2.ManualFloat(Rect(50, 200, 138, 500));
if not Form2.Visible then
Form2.Show;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('OptionsPrj.ini');
with Ini do
begin
Panel1.Width := ReadInteger('Panel', 'Width', 160);
Free;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('OptionsPrj.ini');
with Ini do
begin
WriteInteger('Panel', 'Width', Panel1.Width);
Free;
end;
end;
end.
//------------------- Unit1.dfm -------------------
object Form1: TForm1
Left = 231
Top = 231
Width = 406
Height = 276
Caption = 'Form1'
Color = 16574654
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Splitter1: TSplitter
Left = 88
Top = 39
Width = 3
Height = 210
Cursor = crHSplit
Beveled = True
Color = 14320701
ParentColor = False
end
object Label1: TLabel
Left = 0
Top = 0
Width = 398
Height = 39
Align = alTop
AutoSize = False
end
object Panel1: TPanel
Left = 0
Top = 39
Width = 88
Height = 210
Align = alLeft
BevelOuter = bvNone
Caption = 'Panel1'
Color = 15715983
DockSite = True
DragMode = dmAutomatic
TabOrder = 0
end
object Button1: TButton
Left = 4
Top = 5
Width = 75
Height = 25
Caption = 'Dock'
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 80
Top = 5
Width = 75
Height = 25
Caption = 'Undock'
TabOrder = 2
OnClick = Button2Click
end
object Memo1: TMemo
Left = 91
Top = 39
Width = 307
Height = 210
Align = alClient
Color = 16710861
Lines.Strings = (
'Super Delphi site:'
'[линк]')
TabOrder = 3
end
end
//------------------- Unit2.pas -------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, IniFiles;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
ComboBox1: TComboBox;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.DFM}
procedure TForm2.FormDestroy(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('OptionsPrj.ini');
with Ini do
begin
WriteInteger('DockForm', 'Top', Top);
WriteInteger('DockForm', 'Left', Left);
WriteInteger('DockForm', 'Width', Width);
WriteInteger('DockForm', 'Height', Height);
if Parent is TPanel then
WriteInteger('DockForm', 'Dock', 1)
else
WriteInteger('DockForm', 'Dock', 0);
Free;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create('OptionsPrj.ini');
with Ini do
begin
Top := ReadInteger('DockForm', 'Top', 169);
Left := ReadInteger('DockForm', 'Left', 120);
Width := ReadInteger('DockForm', 'Width', 138);
Height := ReadInteger('DockForm', 'Height', 310);
if ReadInteger('DockForm', 'Dock', 0) = 1 then
ManualDock(Form1.Panel1);
Free;
end;
end;
end.
//------------------- Unit2.dfm -------------------
object Form2: TForm2
Left = 120
Top = 169
Width = 138
Height = 310
Caption = 'List objects'
Color = clBlue
DockSite = True
DragKind = dkDock
DragMode = dmAutomatic
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Visible = True
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 0
Top = 0
Width = 130
Height = 23
Align = alTop
AutoSize = False
end
object ListBox1: TListBox
Left = 0
Top = 23
Width = 130
Height = 260
Align = alClient
ItemHeight = 13
TabOrder = 0
end
object ComboBox1: TComboBox
Left = 1
Top = 1
Width = 127
Height = 21
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
TabOrder = 1
Items.Strings = (
'----- 1'
'----- 2'
'----- 3'
'----- 4')
end
end
Re: Аnswer... (Source)
Blagodaria ti mnogo Towa iawno e trudna zada4aka ]oto dosta wreme 4akah dokato ti se poiawi - moia spasitel
Velaia ti wsi4ko nai-rozowo
Velaia ti wsi4ko nai-rozowo