Weird problem with LoadDialogResource()



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

    On 18/06/2011 at 14:35, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R12 
    Platform:      
    Language(s) :     C++  ;

    ---------
    I have a very odd problem when loading a resource. Basically, I have a dialog which needs to open another dialog. I've done this before without problems. With this project, everything compiles okay but when trying to open the second dialog, LoadDialogResource() fails. C4D shows three message boxes and one looks like this:

    The other two are similar. If you look at the file which C4D says it can't load, everything is correct until you get to the "...\dialogs\idc_rlog_buttonclear.str" part. It should be "...\dialogs\dialogtest.str". 'idc_rlog_buttonclear' is actually the ID of an element in the main dialog! Where C4D got this from, I just don't know. All the resources are created with ResEdit.

    Here's the code I use to open the new dialog:

      
    dlgtest.Open(DLG_TYPE_ASYNC, NULL);   
    

    And here's the CreateLayout() function in the dialog to be opened:

      
    Bool DialogTest::CreateLayout(void)   
    {   
         // call the base class function first   
         GeDialog::CreateLayout();   
      
         // create resource object and load the resource   
         GeResource dlg_res;   
         dlg_res.Init(GeGetPluginPath());   
         if(!LoadDialogResource(IDD_DIALOGTEST, &dlg;_res, 0))   
         {   
              GePrint("DialogTest: could not load resource file.");   
              return FALSE;   
         }   
      
         return TRUE;   
    }   
    

    Identical code works fine in several other plugins. I've tried with another dialog and different resource file, same problem except the erroneous string is different (but uses the ID of another element in the main dialog resource).

    I must be doing something wrong but I just can't see what.

    Anyone have any ideas?

    Steve



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

    On 18/06/2011 at 15:45, xxxxxxxx wrote:

    Personally, I create my dialog layouts manually so that I can control every nook and cranny. :)

    Start by checking the return of your Init().

    Also, make sure that your ID values are unique.  It may be that IDD_DIALOGTEST also belongs to another of your IDs and confusing C4D.  I typically start dialog element IDs at 5000 and make dialog IDs themselves at least 10000 or larger (in between element IDs and plugin IDs).

    Finally, if none of that works, look elsewhere at your code.  I can't count the number of times stepping on memory or IDs has cost me time hunting down the wrong trail.



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

    On 19/06/2011 at 00:20, xxxxxxxx wrote:

    Many thanks Robert. The problem was indeed the ID values. The IDD_DIALOGTEST was the same as another dialog, no wonder Cinema got confused! I was coming to the point of thinking it looked as though I was overwriting memory somewhere, so that's save me a lot of time and headaches :-)

    And there was I thinking that ResEdit would not let that happen, so I didn't even check. I probably should build my dialogs manually... but I like to see how they are going to look before compilation.

    Thanks again,

    Steve


Log in to reply