-
Доброе время суток. Делаю по демке. http://kolmck.net/demos/DemoMDI.zipвот что получается код: program Project1;
uses
windows,messages,
kol;
const
N5: Integer = 1;
N3: Integer = 3;
N4: Integer = 4;
var
form,form2,MDIClient1,
Panel1:PControl;
MainMenu1:pMenu;
procedure MainMenu1N5Menu(Dummy:pointer;Sender: PMenu; Item: Integer);
begin
form2 := NewMDIChild( Form, 'Form2' ).SetSize( 333, 223 );
form2.Border := 10;
Panel1 := NewPanel(form2, esRaised ).SetAlign ( caClient );
Panel1.Border := 2;
end;
procedure MainMenu1N3Menu(Dummy:pointer;Sender: PMenu; Item: Integer);
begin
MDIClient1.Perform( WM_MDITILE, MDITILE_VERTICAL, 0 );
end;
procedure MainMenu1N4Menu(Dummy:pointer;Sender: PMenu; Item: Integer);
begin
MDIClient1.Perform( WM_MDICASCADE, 0, 0 );
end;
Begin
Applet := NewApplet('form');
form:=NewForm(Applet,'form').SetPosition( 246, 107 ).SetClientSize( 363, 273 );
form.Font.FontName := 'MS Sans Serif';
MDIClient1:=NewMDIClient( Form,Form.handle).SetAlign ( caClient );
applet.Add2AutoFree(MDIClient1);
applet.Add2AutoFree(form);
MainMenu1 := NewMenu( Form, 0, [ 'Item1', '('
, 'Create MDI child', ')', 'Item2', '(', 'Tile', 'Cascade'
, ')', '' ], nil );
MainMenu1.AssignEvents( 1, [TOnMenuItem(MakeMethod(nil,@MainMenu1N5Menu))] );
MainMenu1.AssignEvents( 3, [TOnMenuItem(MakeMethod(nil,@MainMenu1N3Menu))] );
MainMenu1.AssignEvents( 4, [TOnMenuItem(MakeMethod(nil,@MainMenu1N4Menu))] );
Run(Applet);
end.
При закрытии главной формы вылетает.
-
Remove this line: applet.Add2AutoFree(form);
-
> Remove this line: > > applet.Add2AutoFree(form);
Thank you. But this is not enough still flies on the event form is closed.
-
Try this:
program MDI_Demo;
uses
Windows, Messages, KOL;
var
MDIClient, MDIChild, Panel: PControl;
MainMenu: PMenu;
procedure CreateMDIChild;
begin
MDIChild := NewMDIChild(MDIClient, 'MDI Client').SetClientSize(320, 200);
MDIChild.Border := 10;
Panel := NewPanel(MDIChild, esRaised).SetAlign(caClient);
Panel.Border := 2;
MDIClient.CreateWindow;
end;
procedure MenuItems(Dummy: Pointer; Sender: PMenu; Item: Integer);
begin
case Item of
1: CreateMDIChild;
3: MDIClient.Perform(WM_MDITILE, MDITILE_VERTICAL, 0);
4: MDIClient.Perform(WM_MDICASCADE, 0, 0);
end;
end;
begin
Applet := NewForm(nil, 'MDI Demo').SetPosition(240, 120).SetClientSize(380, 280);
Applet.Font.FontName := 'MS Sans Serif';
MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade', ')', ''], TOnMenuItem(MakeMethod(nil, @MenuItems)));
MDIClient := NewMDIClient(Applet, 0).SetAlign(caClient);
CreateMDIChild;
Run(Applet);
end.
-
Доброе время суток. to Jon: Just one question: This example works on your computer? Во общем хотел поделится следующим. Покопавшись архиве нашел следующее: Fregl © (11.01.07 13:15) [13]
у меня проблема в MDI следующая - если созать несколько MDI окон, а потом их закрывать, то после закрытия последнего вылетает ошибка, либо же при закрытии приложения вылетает ошибка на RefDec. Нужно ли дочерние окна добавлять в список AutoFree контрола MDIClient?В моём примере, если убрать Dummy:pointer;, то становиться понятным, что ошибка или это не ошибка одна и та же. Идём дальше в при компиляции используется файл KOL_ASM.inc в который и входит function TObj. RefDec: Integer; Смотрим в следующем контексте возникнет ли эта ошибка в более ранней версии кол. Взял то что было у меня VERSION 1.91 другой по рукой не было. Компилим запускаем смотрим закрываем всё нормально. Идём ещё дальше. Решил посмотреть под другим взглядом. Берём SpeedKompiler. Из ветки http://pda.delphimaster.net/?id=1279707215&n=10.Готовим проект в новой папке оставляем только Project1.dpr+ файл Project1.res. Компилим SpeedKompilerом. Запускаем запускаем смотрим закрываем всё нормально.:) http://zalil.ru/29682480Берём пример Jon'а снова готовим. Компилим SpeedKompilerом. Запускаем запускаем смотрим закрываем и опять всё нормально.:) http://zalil.ru/29682483
-
> to Jon: Just one question: This example works on your computer?
Yes, it works. No errors. Here is my project: http://zalil.ru/29683785What problems are you having? I shall try to help if I can.
-
Спасибо Jon. Твой вариант работает, но при компиляции на моёй машине и закрытии главной формы появляется ошибка: CPU ntdll.DbgBreakPoint: 7C90120E CC int 3 ->7C90120F C3 ret ____________________________ KOL_ASM.inc.9323:ret 00404587 C3 Но если запустить ехешник, то ошибки нет. Всё работает. А здесь нормально.:) В этих случаях http://zalil.ru/29682480http://zalil.ru/29682483ошибка возникает при закрытии 1ой MDIChild. Если их больше не возникает.
-
Very strange - the exe in "Mdiforms_by_Jon_on_kompiler.rar" works correctly for me. What version of Delphi and what version of KOL? I use D7 and KOL 2.94++ Maybe try this:
procedure CreateMDIChild;
begin
MDIChild := NewMDIChild(MDIClient, 'MDI Client').SetClientSize(320, 200);
MDIClient.Add2AutoFree(MDIChild);
...
-
Спасибо Jon. "Mdiforms_by_Jon_on_kompiler.rar" works correctly for me. Yes, it works correctly. I took your project and do compilation in my D7, and KOL 2.90. error occurs when closing the first MDIChild. MDIChild := NewMDIChild(MDIClient, 'MDI Client').SetClientSize(320, 200);
MDIClient.Add2AutoFree(MDIChild); does not work the same I'll try the same test in the newer versions of KOL.
-
MDIChild := NewMDIChild(MDIClient, 'MDI Client').SetClientSize(320, 200); MDIClient.Add2AutoFree(MDIChild); does not help, the same error
I'll try the same test in the newer versions of KOL.
-
Do you want me to send you my KOL files?
-
What files do I need to send you? If your program works. :) It's my error. Through speedkompiler will compile and it will work. It works correctly.
-
There seems to be a bug in the MDI implementation.
In the example from [3] try this: - Start the program - Maximise the existing MDI child - Menu > New > Create MDI Child
Bug #1: All child windows return to restored state Bug #2: Existing MDI child has no caption Bug #3: New MDI child cannot be manipulated
- Close the application
Bug #4: Application crash with error
The problem seems to be with maximising the MDI child. I have tested with both KOL v2.xx and v3.00..
-
program MDI_test;
uses
Windows, Messages, KOL;
var
MDIClient, MDIChild, Panel: PControl;
MainMenu: PMenu;
procedure CreateMDIChild;
begin
MDIChild := NewMDIChild(MDIClient, 'MDI Client').SetClientSize(320, 200);
MDIChild.Border := 10;
Panel := NewPanel(MDIChild, esRaised).SetAlign(caClient);
Panel.Border := 2;
MDIClient.CreateWindow;
end;
procedure MenuItems(Dummy: Pointer; Sender: PMenu; Item: Integer);
begin
case Item of
1: CreateMDIChild;
3: MDIClient.Perform(WM_MDITILE, MDITILE_VERTICAL, 0);
4: MDIClient.Perform(WM_MDICASCADE, 0, 0);
end;
end;
begin
UseDelphiMemoryManager;
Applet := NewForm(nil, 'MDI test').SetPosition(240, 120).SetClientSize(380, 280);
Applet.Font.FontName := 'MS Sans Serif';
MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade', ')', ''], TOnMenuItem(MakeMethod(nil, @MenuItems)));
MDIClient := NewMDIClient(Applet, 0).SetAlign(caClient);
CreateMDIChild;
Run(Applet);
end.
-
No, UseDelphiMemoryManager is only valid when using the replacement system files. The bugs that I reported are present all of the time. Hopefully Vladimir has an answer...
-
Suggestions, anyone, please?
-
program MDI_test;
uses Windows, Messages, KOL;
var MDIClient, MDIChild, Panel: PControl; MainMenu: PMenu; i:integer; procedure CreateMDIChild; begin inc(i); MDIChild := NewMDIChild(MDIClient, 'MDI Client '+int2str(i)+' '+Date2StrFmt('ddMMyyyy',Date)).SetClientSize(320, 200); MDIChild.Border := 10; Panel := NewPanel(MDIChild, esRaised).SetAlign(caClient); Panel.Border := 2; MDIClient.CreateWindow; MDIClient.Perform(WM_MDICASCADE, 0, 0) end;
procedure MenuItems(Dummy: Pointer; Sender: PMenu; Item: Integer); var j:integer; begin case Item of 1: CreateMDIChild; 3: MDIClient.Perform(WM_MDITILE, MDITILE_VERTICAL, 0); 4: MDIClient.Perform(WM_MDICASCADE, 0, 0); 5: begin for j:=0 to 699 do CreateMDIChild end; end; end;
begin //UseDelphiMemoryManager; Applet := NewForm(nil, 'MDI test').SetPosition(240, 120).SetClientSize(380, 280); Applet.Font.FontName := 'MS Sans Serif'; MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade','MaxMDIChild', ')', ''], TOnMenuItem(MakeMethod(nil, @MenuItems))); MDIClient := NewMDIClient(Applet, 0).SetAlign(caClient); CreateMDIChild; Run(Applet); end.
- Start the program Maximise the existing MDI child with Select MaxMDIChild create 701 MDIChild
- Close the application No error KOL v3.00 M
-
Confirmed. Sorry, if you close Application without IDE-> the Application crash with error.
-
As I said, the problem is with a MDI maximise (WM_MDIMAXIMIZE):
procedure CreateMDIChild;
begin
MDIChild := NewMDIChild(MDIClient, 'MDI Client ' + Date2StrFmt('ddMMyyyy', Date)).SetClientSize(320, 200);
MDIChild.Border := 10;
Panel := NewPanel(MDIChild, esRaised).SetAlign(caClient);
Panel.Border := 2;
MDIClient.CreateWindow;
MDIClient.Perform(WM_MDIMAXIMIZE,MDIChild.Handle,0); end;
-
SendMessage(MDIChild.Handle,WM_SYSCOMMAND,SC_MAXIMIZE,0); //something like this
-
Yes. Also tried to create 10 windows in the cycle could close only two. Eight MDIChild windows did not closed.When all MDIChild windows MAXIMIZEd no caption.
-
program MDI_Demo;
uses
Windows, Messages, KOL;
var
MDIClient: PControl;
MainMenu: PMenu;
i: Integer;
procedure CreateMDIChild;
var MDIChild: PControl; ActiveWnd: HWnd; Maximized: BOOL;
begin
ActiveWnd := MdiClient.Perform(WM_MDIGETACTIVE, 0, Integer(@Maximized));
if Maximized then
MdiClient.Perform(WM_MDIRESTORE, ActiveWnd, 0);
MDIChild := NewMDIChild(MDIClient, 'MDI Child '+ int2str(i)).SetClientSize(320, 200);
MDIChild.Border := 10;
NewPanel(MDIChild, esRaised).SetAlign(caClient);
MDIChild.CreateWindow;
inc(i);
if Maximized then
MdiClient.Perform(WM_MDIMAXIMIZE, MDIChild.Handle, 0);
end;
procedure MenuItems(Dummy: Pointer; Sender: PMenu; Item: Integer);
begin
case Item of
1: CreateMDIChild;
3: MDIClient.Perform(WM_MDITILE, MDITILE_VERTICAL, 0);
4: MDIClient.Perform(WM_MDICASCADE, 0, 0);
end;
end;
begin
Applet := NewForm(nil, 'MDI Demo').SetPosition(240, 120).SetClientSize(380, 280);
Applet.Font.FontName := 'MS Shell Dlg';
MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade', ')', ''], TOnMenuItem(MakeMethod(nil, @MenuItems)));
MDIClient := NewMDIClient(Applet, 0).SetAlign(caClient);
CreateMDIChild;
Run(Applet);
end.
-
Still the same problem:
1- maximize mdi child window 2- menu > new > create mdi child 3- exit application = error
-
Version 3.00.S is uploaded with fixes for MDI. First, add USE_MDI symbol to defines of a project! Second, to obtain automatic windows enumeration, do the following: var m: Integer;
begin
Applet := NewForm(nil, 'MDI test').SetPosition(240, 120).SetClientSize(380, 280);
Applet.Font.FontName := 'MS Sans Serif';
MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade','MaxMDIChild', ')', ''],
TOnMenuItem(MakeMethod(nil, @MenuItems)));
m := GetSubMenu( MainMenu.Handle, 1 );
MDIClient := NewMDIClient(Applet, m).SetAlign(caClient);
CreateMDIChild;
Run(Applet);
end.
-
Thank you very very much (yet again) Vladimir. I though that I was going crazy with this one!
-
FYI, just needs a little tidying up...
dcc32.exe -b KOL.pas -dUSE_MDI
Borland Delphi Version 15.0
Copyright (c) 1983,2002 Borland Software Corporation
KOLDEF.INC(253)
KOLDEF.INC(253)
delphidef.inc(48)
delphicommctrl.inc(1569)
KOL_ansi.inc(2317)
KOL_ansi.inc(2317)
KOL_ASM.inc(14875)
KOL.pas(65635)
87261 lines, 0.59 seconds, 188142 bytes code, 4256 bytes data.
dcc32.exe -b KOL.pas
Borland Delphi Version 15.0
Copyright (c) 1983,2002 Borland Software Corporation
KOLDEF.INC(253)
KOLDEF.INC(253)
delphidef.inc(48)
delphicommctrl.inc(1569)
KOL_ansi.inc(2317)
KOL_ansi.inc(2317)
KOL.pas(34181) Error: Undeclared identifier: 'MDIClient'
KOL.pas(34181) Error: Operator not applicable to this operand type
KOL.pas(34182) Error: Undeclared identifier: 'MDIClient'
KOL.pas(34182) Error: 'END' expected but ',' found
KOL.pas(34185) Error: '.' expected but ';' found
KOL.pas(34198) Error: Undeclared identifier: 'MDIClient'
KOL.pas(34311) Error: Undeclared identifier: 'fMDIClient'
KOL_ASM.inc(14875)
KOL.pas(65635)
-
R+ is on the site.
-
S+, certainly. S++ now on site (compiling with D2 restored, it don't know about WideString).
-
Excellent, thanks. Just one more question, is it possible to remove the separator bar in the new menu?
MainMenu := NewMenu(Applet, 0, ['New', '(', 'Create MDI Child', ')', 'Window', '(', 'Tile', 'Cascade', ')', 'MDI', '(', ')', ''], TOnMenuItem(MakeMethod(nil, @MenuItems)));
MDIClient := NewMDIClient(Applet, GetSubMenu(MainMenu.Handle, 2)).SetAlign(caClient);
The menu looks like this:
MDI == Menu caption
---- == Unwanted separator
1 MDI == List of MDI's
2 MDI
-
Do not see any separator except some space. Space can be removed just setting Applet.Border := -4;
-
-
-
-
If you about menu it is handled by system. You can use tail of you menu rather then standalone. I think it is not possible to remove this separator except you pass 0 and handle menu by your code entirely.
-
OK, thank you.
-
Bug found:
Compile with USE_MDI;UNICODE_CTRLS; then new MDI child window position is shifted to right and down of last created child.
Compile with USE_MDI; only then new MDI child window is always at the top left.
|