SubId for dialogs?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/08/2003 at 09:06, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.100 
    Platform:   Windows  ; Mac  ;  Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    I have a non-modal dialog (Async_Dialog). When the user clicks on a certain button I am opening another dialog (Layer_dialog) like this:

        
        
        class AsyncDialog : public GeDialog  
        {  
         private:  
          LayerDialog ldlg;
        
        
        
        
        [...]
        
        
        
        
        ldlg.Open(TRUE,MY_ID,-1,-1);
    

    Ok, now when I dock those two dialogs in my interface and save my layout, next time Cinema 4D starts the AsyncDialog is restored correctly but the second dialog is not. :
    I know I can use several Command datas to probably workaround this problem but I don´t like it. It´s kind of dirty to me :) (thanks anyway Thomas ;)
    Well, the real problem now is that it should be possible anyway with the RestoreLayout function that I am overloading like:
    Bool AsyncTest::RestoreLayout(void *secret)
    {
     globaldialog = &dlg;
     return dlg.RestoreLayout(ID_ASYNCTEST,1,secret);
    }
    Ok so this works for the AsyncDialog. The Documentation though says:
    "If you have more than one dialog you need to look at _<_a class=link href= "mk:@msitstore:d:\programme\microsoft%20visual%20studio\common\msdev98\addins\c4d_sdk_chm_reference.chm::/pages/c4d_commanddata/struct_restorelayout675.html"_>_RestoreLayoutSecret::subid."
    Well, but it somehow doesn´t work. But I am sure I am doing something wrong? So I tried to set the subid value of the RestoreLayout() function to my LayerDialog id like this:

        
        
        Bool AsyncTest::RestoreLayout(void *secret)  
        {  
         globaldialog = &dlg;  
         RestoreLayoutSecret* s = (RestoreLayoutSecret* )secret;  
         s->subid = MY_ID;  
         return dlg.RestoreLayout(ID_ASYNCTEST,MY_ID,s);  
        }
    

    But this doesn´t seem to work. I still get a "Plugin not found". To make a long story short: How is this done???
    Thank you
    Samir



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2003 at 00:33, xxxxxxxx wrote:

    I cannot tell from your post if you do that, but I think the subids of each dialog instance needs to be unique. I.e. you cannot just pass one unique ID to all, but each one needs a unique ID of its own. (Only unique within your plugin, so you can use a simple counter.)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2003 at 06:06, xxxxxxxx wrote:

    Yes, I am already having a unique id (even from plugincafe :) for the second dialog (the MY_ID definition) and the  main dialog has a unique ID too (ID_ASYNCTEST) . I don´t need more dialogs so I am sure they are both unique. Any ideas? :\



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/08/2003 at 13:02, xxxxxxxx wrote:

    Looking closer at your code, you don't seem to do things in the right order. (You should never need to change the secret.) Here's an internal example of an asynchronous manager with multiple instances:

        
        
          virtual Bool [CommandData::]RestoreLayout(void *secret)  
          {  
           RestoreLayoutSecret *data = (RestoreLayoutSecret* )secret;
        
        
        
        
           if (data && data->subid>=0 && data->subid<MAXDLG)  
           {  
            LONG subid = data->subid;  
            if (!dlg[subid]) dlg[subid] = gNew [Dialog]();  
            if (!dlg[subid]) return FALSE;  
            if (dlg[subid] && dlg[subid]->IsOpen())  
            {  
             LONG t;  
             for (t=0;t<MAXDLG;t++)  
             {  
              if (!dlg[t]) dlg[t] = gNew [Dialog]();  
              if (!dlg[t]) return FALSE;  
              if (!dlg[t]->IsOpen())  
               { subid = t; break; }  
             }  
             if (dlg[subid] && dlg[subid]->IsOpen()) return FALSE;  
            }  
            return dlg[subid]->RestoreLayout(ID,subid,secret);  
           }  
           return FALSE;  
          }
        
        
        
        
            OpenManager([...])  
            {  
              LONG i,j;  
              for (i=0;i<MAXDLG;i++)  
              {  
                if (!dlg[i])  
                {  
                  dlg[i] = gNew ActiveObjectManager();  
                }  
                if (!dlg[i]) return NULL;
        
        
        
        
                if (!dlg[i]->IsOpen())  
                {  
                  [...]  
                  dlg[i]->Open(TRUE,[ID],-1,-1,250,400,i);  
                  [...]  
                  return dlg[i];  
                }  
              }  
              return NULL;  
            }
        
        
        
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/12/2003 at 07:37, xxxxxxxx wrote:

    I have the same problem here.....did work on it for a couple of hours, and after this thread, at least I understand a little where the problem may be.....
    The thing I want to program is a kind of object manager ( dialog1 ), and if I double click on an item in it, I want to open a preview window ( dialog 2 )....both should be async ones. My first attemp was like Samir did....a GeDialog ( dialog 1 ), called by my CommandPlugin. And, in my case by doubleclick, I open from that one my dialog 2.....create it within dialog 1 and open it within dialog 1, like Samir did above. The docking thing I didnt test in fact....my problem was, when I close dialog 2, and then want to open it again by doubleclick in dialog 1, my app crashes with access violation.....
    By testing alot of things I finally have the following constellation: I have my CommandData Plugin, this one has a unique id. In that CommandData I open the two async dialogs. Now needs to write the RestoreLayout.....and there the problems start. First I gave both dialogs the ID of the CommandData Plugin....well....did understand now, that this is not possible....each of the dialogs need to have an own id. But........I would understand it if I make TWO CommandData Plugins, and from within each one I start ONE Dialog, giving each dialog the according ID of the CommandData Plugin....but then I also would have TWO RestoreLayout functions, one from each CommandData, and only would restore ONE dialog in it........but the secret pointer provides the possibility to restore TWO dialogs within ONE RestoreLayout...so within ONE CommandData Plugin. But then I have only ONE PluginID, that one of the CommandData...so I cannot give each of the dialogs theire own unique ID......*isconfused* I tried to give each Dialogs just an ID.....but then I get "plugin not found" within my dialogs...because the two IDs are not the ONE CommandPlugin ID....so I would need to make two CommandPlugins...then I have two IDs....and then I dont need that secretpointerthing....*evenmoreconfused*
    I think I did not understand something very important about Plugins and IDs.....please have some help!!!!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/12/2003 at 22:56, xxxxxxxx wrote:

    Ok....at least to reopen the second dialog as often as I want to now works....but still haves the problem when I try to dock them, save that to a layout, and reload that one....then inside the dialogs is written "plugin not found"....of course not, because I dont use a plugin id for them, because I only have one....the only way to get a second one I see is to create a second commanddata plugin....but that seems not logical, as said, because one commanddata provides the possibility to restore two dialogs....so one commanddata should be enough.....



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/12/2003 at 01:42, xxxxxxxx wrote:

    .......found it....its logical, and its easy.....was just to blind to see it after hours of working in it....just in case someone will be the same blind in future:
    With GeDialog->Open you cannot only specify a pluginID, but also a subID....this subID has to be exclusive within your plugin. If you open them that they, than the subid value of the secret pointer will specify which dialogs restorelayout is intended to be called.....for example:
    Bool YourCommandPlugin::Execute(BaseDocument* doc)
    {
     dialog1.Open( TRUE, PLUGINID, -1, -1, 0, 0, IDD_DIALOG1 );
     dialog2.Open(TRUE, PLUGINID, -1, -1, 0, 0, IDD_DIALOG2 );
     return true;
    }
     
    Bool YourCommandPlugin::RestoreLayout(void* secret)
    {
     
     LONG subid = ((RestoreLayoutSecret* )secret)->subid ;
     if( subid == IDD_DIALOG1 )
         return dialog1.RestoreLayout(PLUGINID,IDD_DIALOG1,secret);
     if( subid == IDD_DIALOG2 )
        return dialog2.RestoreLayout(PLUGINID,IDD_DIALOG2,secret);
    }


Log in to reply