Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Main DockManager are properly saved, but not Child DockManager

Hello to all,

Maybe someone can help me with certain issue that I am having. In one app that I am developing, we want to use two DockManager components. Just think that our app allow to create "projects", so, the main form of our app, can contain docked "projects", and, every project, have their own DockManager, DockSite, DockPanels, etc.

Everything is working like a charm, except when we try to save and read a changed panels layout. Please, let me to explain:

1º In the app's main form, we float a dock tool panel, and, then close the app: before the app is finally close we use the DockManager's SaveToFile method in order to save the layout into a XML file. When the app starts again, look for a possible previosly saved layout, and, load it if exists.

2º We create a new "project" in our app, so the project's dockmanager, docksite and dockpanels enter in the stage. Now we float a tool panel of the project, and close the project: before close it, we do the same than before: use the project's DockManager's SaveToFile method to save the layout into a XML file, to be loaded when a project is created again, in a similar way than the main app.

In the first case the things works like a charm, that is, when the app starts, we use the DockManager's LoadFromFile method to load a previously saved layout, and, everything works as expected: even the floated tool panel appear like expected, so there is no problem here.

However, when a new project is created, and we load their previusly saved layout, the position and sizes of the non floated panels are recover without problem, but, non the float tool panel... this panel are not shown at all, even more, we can't show it using their Show method.

We can see that the app's main layout XML file have a "sitelist" node, and, inside that note, we can see a "site floating="1"", in which the float panel's properties are saved. We can't see the same in the project's layout XML file. The floating panel are just not saved there, so of course cannot be loaded later...

Taking a look at the main DockManager, DockSite and DockPanels, in comparisson with the project's DockManager, DockSite and DockPanels, we can't see any different in their properties. In fact, everything works fine also for the saved layouts of the projects: except for the floating panels.

Anybody can provide to us some idea about what can happen?

Please, if more information is needed, don't hesitate to reply to this post and ask for it: I will try to provide the required information as quickly as possible.

Thanks in advance for any possible help!

Comments

  • 11 Comments sorted by Votes Date Added
  • When the user drags a panel (and later leave it floating) new form with special floating dock-site is created. This form can't decide to which dock-manager it should be attached. So, if several dock-managers are exist at dragging start time, the system will fire OnAttachFloatingSite event for each dock manager.
    Your application should analyze which project draggning panel belongs to, and attach it to the corresponding dock-manager setting Attach event parameter to True.
  • Hello Eugene,

    Thanks for your reply. Right now I am here recording a sample video of a preparing sample which reproduce the issue. I am sorry for don't post something like that before, however, I think that you certainly know about what I am talking...

    Yes; I think you are right because I try to float the main panel... when a project's (child) DockManager is already in the stage... and certainly now the main float panel is also missing when save and load the layout: so the cause is what you refer.

    I will take a look at your instructions and then I will post here if I continue having the issue or if finally I can solve it, thanks to your help.

    P.S. I attach the sample to this post: I can't attach the video that I prepare... since it's beyond the upload size limit. Please, forget the mistakes in the sample (free the objects, etc.),... it's just a sample that reproduce the issue, no more, no less.
    zip
    zip
    DockPanels.zip
    55K
  • Hello Eugene,

    I am trying to use the "OnAttachFloatingSite" event of both "main" and "child" DockManagers... but without success... I am probably using bad the referred event. What I do is to place the below two lines in the event handler:

      ASite := LMDDockSite1;
      Attach := True;

    That... for the main... and, as you can imagine, the below for the "childs"...

      ASite := LMDDockSite2;
      Attach := True;

    But that don't work as expected, of course... can you please, Eugene, give me a little help on this?
  • The code of event handler in your project's dock-manager should look like this:

    if IsPanelsOnTheSiteAreProjectPanels(ASize) then
      Attach := True;

    And its up to you how to implement IsPanelsOnTheSiteAreProjectPanels function.
  • Hello Eugene,

    Thanks for your reply. And please, sorry if I bored you too much... I can be ready with events like "DockSiteGetSiteInfo", so I know that "CanDock" (in this case) it's my responsability. But I am not sure what "IsPanelsOnTheSiteAreProjectPanels" means... :-(

    What I understand, for the case of the sample that I prepare, is something like this:

      Attach := ASite = LMDDockSite2;

    ... when "LMDDockSite2" is the site used to place the project's panels...

    But that don't work as expected, so, for sure I am missing something... :-(
  • Let me some time to check deeper...
  • Hello Eugene,

    Please no hurry! Always thanks for your help.
  • What you trying to achieve is a crazy complex thing. Do you really want it? Just think about the following:

    - Any site, including floating sites (which are created for each floating form) can be attached to only one dock manager, and saved using only it. So, when user drag panels in your application, you should prevent docking project panels in application sites (including floating) and vice versa.
    - Similarly you should prevent docking panels from one project into sites from another project.
    Also, each project form should have its own unique name (or Id), and you should be familar with OnGetComp/OnGetCompId dock manager events to distinguish panels from one project from panels from another one project.

    I've changed your demo project for you. Please read comments in code.
    rar
    rar
    DockPanels.rar
    54K
  • Hello Eugene,

    Thanks for your reply. Honestly I don't think that what I wanted are a crazy thing... in fact, I handle perfectly what you refer in your two first paragraphs. There is no problem with that: main dock panels are only draggable to main site, and project panels are only draggable to their own site, not the main site, not other project's sites. As I say, this work like a charm.

    In fact, everything works like a charm, that is, except the float panels. We can perfectly save and load the layouts after moving the positions of the panels, in both, the main and any projects' panels. The problem become if one of these panels become floating... yes... I know... but please, note that everything else works as expected: so I don't think it's a crazy thing...

    In fact I think it's quite logic: main docks for the main site, project's docks, for the project's site. No more. No less.

    About to provide a unique name for the project, certainly there is already an "ID" which is unique for every project. I think this is not exactly what you are refer... since certainly what forms are of a project depend on the app...

    As you can imagine, I did not create the projects like in the sample that I prepare before: we use objects, objects lists, etc., in order to maintain the order, free the right objects at the end, etc., etc.

    So let me to take a look at your modified code: I hope that I can adapt it to my own one. But, again, I think there is not crazy thing here... except, of course, that, if we can "miss" floating panels... (because it's not a question that we loss the position of the panel, but, we really miss the panel... we can't shown it later...) then we must avoid floating panels (which made the panels less useful, since I read here in this forum that this is only possible for VS2005 styles or earlier), or try some other possible "workaround".

    Thanks again for your help.
  • Hello Eugene,

    First of all, sorry for the delay... I have too much work these days and just minutes ago I can try your modified sample. Apparently works like expected, that is, I can implement in the main DockManager the same that you already implement in the "child" projects DockManager and now both panels can be saved and then loaded even if they are floating.

    Now it's my duty to see how I can implement the same idea in my own app, since there we have several panels, etc. I think that follow your sample it's possible to do it, so it's a question of time and work. I will post here if I think that you can help me in some particular point of if I get stuck, and also if I can see something useful around this issue.

    Thanks again for your help, Eugene!
Sign In or Register to comment.