User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Yet Another ExtDev Question

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yet Another ExtDev Question

    Sorry for so many extension development questions, but I hope you will all like my final product.

    I am using the OPENFILENAME structure in my extension. Upon compiling, I get a warning saying I used an uninitialized variable. How should I go about initializing the structure?

    Thanks for your time,
    Jaffob

  2. #2
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    OPENFILENAME Filename;

    will initialise it, whereas

    OPENFILENAME * Filename;

    will just create an empty pointer. If you want to use a pointer,

    OPENFILENAME * Filename=new OPENFILENAME;

    and then when you are done with it

    delete Filename;

  3. #3
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    Thanks.
    Another problem has arrived. When I enter my structure into the GetOpenFileName function, it compiles fine, but the MMF runtime crashes when the action is run. The Code:

    Code:
    OPENFILENAME sfn;
    	sfn.lStructSize = sizeof(sfn);
    	sfn.hwndOwner = MainHwnd;
    	sfn.lpstrFilter = NULL;
    	sfn.lpstrTitle = (char *)Param(TYPE_STRING);
    	sfn.lpstrFilter = (char *)Param(TYPE_STRING);
    	sfn.lpstrCustomFilter = NULL;
    	sfn.nFilterIndex = Param(TYPE_INT);
    	sfn.lpstrDefExt = (char *)Param(TYPE_STRING);
    	sfn.lpstrFile = (char *)Param(TYPE_STRING);
    	sfn.nMaxFile = MAX_PATH;
    	sfn.lpstrFileTitle = NULL;
    
    	GetOpenFileName(&sfn);
    One more question: Is there a good way to set flags based on variables. Meaning, if the action accepts 5 variables of value 0 or 1, can I set flags some way that does not result in uncountable if statements.

  4. #4
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    sfn.lpstrFile needs to point to a WRITABLE string of max size sfn.nMaxFile. A Param() isn't writable.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    I created a variable at the top of main.cpp like this:

    char * FilePath = NULL;

    Then for lpstrFile I put:

    sfn.lpstrFile = FilePath;

    It still does not work. Is there something else I need to do?

  6. #6
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    Of course it's going to crash if you use a NULL pointer. You need to allocate some memory-

    char * FilePath=new char[MAX_PATH];

    and if you want to load the parameter into it,

    strcpy(FilePath,(char *)Param(TYPE_STRING));

    although it's sensible to do a check on the length, which you can figure out yourself

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    Don't forget to delete the string after:
    delete[] FilePath;

  8. #8
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    Alternatively, you can use rdPtr->rRd->GetStringSpace(MAX_PATH); instead of new, which borrows the memory from the runtime. MMF2 will free it automatically.

  9. #9
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    New code:

    Code:
    	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    	HWND MainHwnd = rhPtr->rhHMainWin;
    
    	char * FilePath = new char[MAX_PATH];
    
    	OPENFILENAME sfn;
    	sfn.lStructSize = sizeof(sfn);
    	sfn.hwndOwner = MainHwnd;
    	sfn.lpstrFilter = NULL;
    	sfn.lpstrTitle = (char *)Param(TYPE_STRING);
    	sfn.lpstrFilter = (char *)Param(TYPE_STRING);
    	sfn.lpstrCustomFilter = NULL;
    	sfn.nFilterIndex = Param(TYPE_INT);
    	sfn.lpstrDefExt = (char *)Param(TYPE_STRING);
    	sfn.lpstrFile = FilePath;
    	sfn.nMaxFile = MAX_PATH;
    	sfn.lpstrFileTitle = NULL;
    	
    	int exist = Param(TYPE_INT);
    	int showhidden = Param(TYPE_INT);
    	int readonly = Param(TYPE_INT);
    	int shortcut = Param(TYPE_INT);
    	int recent = Param(TYPE_INT);
    
    // This is where I need help with flags
    
    	if(exist==0 && showhidden==0 && readonly==0 && shortcut==0 && recent==0)  sfn.Flags = OFN_HIDEREADONLY;
    	if(exist==0 && showhidden==0 && readonly==0 && shortcut==0 && recent==1)  sfn.Flags = OFN_HIDEREADONLY|OFN_DONTADDTORECENT;
    	if(exist==0 && showhidden==0 && readonly==0 && shortcut==1 && recent==0)  sfn.Flags = OFN_HIDEREADONLY|OFN_NODEREFERENCELINKS;
    	if(exist==0 && showhidden==0 && readonly==1 && shortcut==0 && recent==0)  sfn.Flags = 0;
    	if(exist==0 && showhidden==1 && readonly==0 && shortcut==0 && recent==0)  sfn.Flags = OFN_HIDEREADONLY|OFN_FORCESHOWHIDDEN;
    	if(exist==1 && showhidden==0 && readonly==0 && shortcut==0 && recent==0)  sfn.Flags = OFN_HIDEREADONLY|OFN_FILEMUSTEXIST;
    	if(exist==0 && showhidden==0 && readonly==0 && shortcut==1 && recent==1)  sfn.Flags = OFN_HIDEREADONLY|OFN_NODEREFERENCELINKS|OFN_DONTADDTORECENT;
    	if(exist==0 && showhidden==0 && readonly==1 && shortcut==0 && recent==1)  sfn.Flags = OFN_DONTADDTORECENT;
    	if(exist==0 && showhidden==1 && readonly==0 && shortcut==0 && recent==1)  sfn.Flags = OFN_HIDEREADONLY|OFN_DONTADDTORECENT|OFN_FORCESHOWHIDDEN;
    	if(exist==1 && showhidden==0 && readonly==0 && shortcut==0 && recent==1)  sfn.Flags = OFN_HIDEREADONLY|OFN_DONTADDTORECENT|OFN_FILEMUSTEXIST;
    	if(exist==0 && showhidden==0 && readonly==0 && shortcut==1 && recent==1)  sfn.Flags = OFN_HIDEREADONLY|OFN_DONTADDTORECENT|OFN_NODEREFERENCELINKS;
    
    
    	GetOpenFileName(&sfn);
    
    	delete[] FilePath;
    The Good News: It does not crash when the action is run.
    The Bad News: Nothing at all happens when the action is run.

    Why doesn't it do anything?

    Thanks again for all the help.

  10. #10
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Yet Another ExtDev Question

    What do you expect it to do?

    Also, your huge block of if statements can be replaced by:

    Code:
    sfn.Flags=0;
    
    if(!readonly)	sfn.Flags |= OFN_HIDEREADONLY;
    if(recent)	sfn.Flags |= OFN_DONTADDTORECENT;
    if(shortcut)	sfn.Flags |= OFN_NODEREFERENCELINKS;
    if(showhidden)	sfn.Flags |= OFN_FORCESHOWHIDDEN;
    if(exist)	sfn.Flags |= OFN_FILEMUSTEXIST;

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •