Конференция "KOL" » DemoMDI kol(без мск) [Delphi, Windows]
 
  • RusSun © (14.09.10 20:44) [0]
    Доброе время суток.
    Делаю по демке.
    http://kolmck.net/demos/DemoMDI.zip
    вот что получается
    код:

    program Project1;

    uses
     windows,messages,
     kol;
    const
    N5: Integer = 1;
    N3: Integer = 3;
    N4: Integer = 4;
    {$R *.res}
    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;
    //form.Add2AutoFree( form2 );
    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);

    {form2 := NewMDIChild( Form, 'Form2' ).SetSize( 333, 223 );
    form2.Border := 10;
    Panel1 := NewPanel(form2, esRaised ).SetAlign ( caClient );
    Panel1.Border := 2;
    Form.Add2AutoFree( form2 );  }


    MainMenu1 := NewMenu( Form, 0, [ 'Item1', '('
         , 'Create MDI child', ')', 'Item2', '(', 'Tile', 'Cascade'
         , ')', '' ], nil );
    //.centeronparent.Tabulate;
    //область для работы                                                      
    MainMenu1.AssignEvents( 1, [TOnMenuItem(MakeMethod(nil,@MainMenu1N5Menu))] );
    MainMenu1.AssignEvents( 3, [TOnMenuItem(MakeMethod(nil,@MainMenu1N3Menu))] );
    MainMenu1.AssignEvents( 4, [TOnMenuItem(MakeMethod(nil,@MainMenu1N4Menu))] );
    Run(Applet);
    end.


    При закрытии главной формы вылетает.
  • Jon © (15.09.10 04:23) [1]
    Remove this line:

    applet.Add2AutoFree(form);

  • RusSun © (15.09.10 05:01) [2]

    > Remove this line:
    >
    > applet.Add2AutoFree(form);

    Thank you. But this is not enough still flies on the event form is closed.
  • Jon © (15.09.10 14:32) [3]
    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.

  • RusSun © (15.09.10 20:43) [4]
    Доброе время суток.
    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
  • Jon © (15.09.10 23:51) [5]

    > to Jon: Just one question: This example works on your computer?


    Yes, it works. No errors. Here is my project: http://zalil.ru/29683785
    What problems are you having? I shall try to help if I can.
  • RusSun © (16.09.10 05:51) [6]
    Спасибо Jon. Твой вариант работает, но при компиляции на моёй машине и закрытии главной формы появляется ошибка:
    CPU
    ntdll.DbgBreakPoint:
      7C90120E CC int 3
    ->7C90120F C3 ret
    ____________________________
    KOL_ASM.inc.9323:ret
      00404587 C3
    Но если запустить ехешник, то ошибки нет. Всё работает.
    А здесь нормально.:)

    В этих случаях
    http://zalil.ru/29682480

    http://zalil.ru/29682483
    ошибка возникает при закрытии 1ой MDIChild.
    Если их больше не возникает.
  • Jon © (16.09.10 06:08) [7]
    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);
    ...

  • RusSun © (16.09.10 17:17) [8]
    Спасибо 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.
  • RusSun © (16.09.10 17:23) [9]
    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.
  • Jon © (17.09.10 16:08) [10]
    Do you want me to send you my KOL files?
  • RusSun © (19.09.10 05:38) [11]
    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.
  • Jon © (21.10.10 00:40) [12]
    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..
  • RusSun © (21.10.10 05:50) [13]
    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.

  • Jon © (21.10.10 12:27) [14]
    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...
  • Jon © (23.10.10 16:03) [15]
    Suggestions, anyone, please?
  • RusSun © (23.10.10 16:58) [16]
    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
  • RusSun © (23.10.10 17:10) [17]
    Confirmed. Sorry, if you close  Application without IDE-> the Application crash with error.
  • Jon © (23.10.10 19:46) [18]
    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); // WM_MDIMAXIMIZE is the problem
    end;

  • RusSun © (23.10.10 20:48) [19]
    SendMessage(MDIChild.Handle,WM_SYSCOMMAND,SC_MAXIMIZE,0);
      //something like this
  • RusSun © (23.10.10 21:39) [20]
    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.
  • Дмитрий К © (23.10.10 23:45) [21]
    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.

  • Jon © (24.10.10 00:01) [22]
    Still the same problem:

    1- maximize mdi child window
    2- menu > new > create mdi child
    3- exit application = error
  • Vladimir Kladov © (24.10.10 00:53) [23]
    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.

  • Jon © (24.10.10 01:15) [24]
    Thank you very very much (yet again) Vladimir.
    I though that I was going crazy with this one!
  • Jon © (24.10.10 01:39) [25]
    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)

  • Vladimir Kladov © (24.10.10 06:50) [26]
    R+ is on the site.
  • Vladimir Kladov © (24.10.10 07:28) [27]
    S+, certainly. S++ now on site (compiling with D2 restored, it don't know about WideString).
  • Jon © (24.10.10 13:27) [28]
    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

  • Vladimir Kladov © (24.10.10 15:59) [29]
    Do not see any separator except some space. Space can be removed just setting
    Applet.Border := -4;

  • Vladimir Kladov © (24.10.10 17:41) [30]
    S+++. Now it is possible Applet.MarginTop := -3; MDIChild.Border := 1;
    and results are looking like
    http://www.ipicture.ru/uploads/101024/At5cE75YtW.jpg
    http://www.ipicture.ru/uploads/101024/QwGtctR6VD.jpg
  • Vladimir Kladov © (24.10.10 17:49) [31]
  • Jon © (24.10.10 19:19) [32]
    I am afraid that you misunderstood me.
    Please see the menu in the screenshot:
    http://www.ipicture.ru/uploads/101024/57YR5RoE3z.gif
  • Vladimir Kladov © (24.10.10 19:45) [33]
    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.
  • Jon © (24.10.10 19:49) [34]
    OK, thank you.
  • Jon © (25.10.10 00:37) [35]
    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.
 
Конференция "KOL" » DemoMDI kol(без мск) [Delphi, Windows]
Есть новые Нет новых   [134430   +3][b:0][p:0.006]