File Dialog Issues
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: File Dialog Issues

  1. #1
    Join Date
    Mar 2014
    Posts
    2

    File Dialog Issues

    Hi
    I have a problem that I don't understand yet. Someone here might be able tell me what to look for.

    The problem is related in to the open and save file dialog. I am learning the windows API for the file dialog by hacking on the Common File Dialog example written by Microsoft. My app runs fine but it crashes when I call exit or when I return from main.

    The program does not crash if I display the task dialog from the example. What kind of problem am I facing? Could it be some kind of memory corruption in another part of the program or is it just a matter of calling release somewhere? Does something in the BasicFileDialog really depend on the task dialog?

    The working looks like this:
    Code:
    void showTaskDialog () {
          TASKDIALOGCONFIG taskDialogParams = { sizeof(taskDialogParams) };
          taskDialogParams.dwFlags = TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION;
    
          TASKDIALOG_BUTTON const buttons[] =
          {
                { 0, L"OK" },
          };
    
          taskDialogParams.pButtons = buttons;
          taskDialogParams.cButtons = ARRAYSIZE(buttons);
          taskDialogParams.pszWindowTitle = L"OK";
    	
    	  int selectedId;
          TaskDialogIndirect(&taskDialogParams, &selectedId, NULL, NULL);
    }
    
    void openFileDialog () {
        HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
    
    	if (SUCCEEDED(hr))
        {
    		showTaskDialog ();
    		BasicFileOpen();
    		CoUninitialize();
    	}
    }
    The code that causes the crash on exit looks like this:

    Code:
    void openFileDialog () {
        HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
    
    	if (SUCCEEDED(hr))
        {
    		BasicFileOpen();
    		CoUninitialize();
    	}
    }
    The stack trace looks like this:
    Code:
    Program received signal SIGSEGV, Segmentation fault.
    0xfeeefeab in ?? ()
    (gdb) bt
    #0  0xfeeefeab in ?? ()
    #1  0x74c23085 in FindGadgetFromPoint () from C:\Windows\system32\duser.dll
    #2  0x74c22e7e in FindGadgetFromPoint () from C:\Windows\system32\duser.dll
    #3  0x7735a604 in ntdll!RtlRemovePrivileges ()
       from C:\Windows\system32\ntdll.dll
    #4  0x7732a303 in ntdll!RtlRegisterWait () from C:\Windows\system32\ntdll.dll
    #5  0x7732a38e in ntdll!RtlExtendMemoryBlockLookaside ()
       from C:\Windows\system32\ntdll.dll
    #6  0x75bed863 in KERNEL32!ExitThread () from C:\Windows\system32\kernel32.dll
    #7  0x00000000 in ?? ()
    The window crash reports claims that it is an access violation in ntshrui.dll

    Cheers
    Johan

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: File Dialog Issues

    1. What does BasicFileDialog have to do with your code snippet? with Visual C++?
    2. Where is your main you refers to:
    Quote Originally Posted by johanm
    it crashes when I call exit or when I return from main
    Note that you must not call exit in Win32 application.
    Last edited by VictorN; March 13th, 2014 at 08:41 AM.
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2014
    Posts
    2

    Re: File Dialog Issues

    Thank you for the exit call information.

    The entire example code with my two functions at the bottom is too long to post at codeguru but it is available here: https://etherpad.mozilla.org/uvyNTUwklF

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: File Dialog Issues

    You did not answer my questions.
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,920

    Re: File Dialog Issues

    As victor pointed out.

    It looks like you're trying to do something with the taskdialog (or command dialog), which is 'sort of' a more elaborate form of the messagebox.

    This has nothing to do at all with the common dialog to open/save files.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,990

    Re: File Dialog Issues

    My test doesn't show any issue.
    test-basicfiledialog.zip
    Best regards,
    Igor

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center