Issues with IFileDialog

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Issues with IFileDialog

Samuel Clark
Been running into issues while trying to get some native dialogs on Windows. I was able to get things to work fine using GetSaveFileName and GetOpenFileName, but the problem is that I also need to be able to select directories sometimes and don't want to use SHBrowseForFolder due to the dialog looking outdated. For this purpose I was switching over to the IFileDialog APIs, but have been getting errors while trying to compile the following.

[[win.cpp]]
#include <windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <shobjidl.h>
#include <stdio.h>
int main(int argc, char** argv)
{
  CoInitialize(NULL);
  HRESULT hr = S_OK;
  IFileDialog* pfd = NULL;
  hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,, IID_PPV_ARGS(&pfd));
  if (SUCCEEDED(hr)) {
    hr = pfd->SetTitle(L"Select a File");
    hr = pfd->Show(NULL);
    if (SUCCEEDED(hr)) {
      printf("selected\n");
    } else {
      printf("nothing selected\n");
    }
  }
}

[[compilation output]]
i686-w64-mingw32-g++ -o win win.cpp -Wl,-subsystem,windows
win.cpp: In function 'int main(int, char**)':
win.cpp:19:13: error: invalid use of incomplete type 'IFileDialog {aka struct IFileDialog}'
     hr = pfd->SetTitle(L"Select a File");
             ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/shlobj.h:124:0,
                 from win.cpp:3:
/usr/i686-w64-mingw32/sys-root/mingw/include/shobjidl.h:672:19: note: forward declaration of 'IFileDialog {aka struct IFileDialog}'
 typedef interface IFileDialog IFileDialog;
                   ^
win.cpp:20:13: error: invalid use of incomplete type 'IFileDialog {aka struct IFileDialog}'
     hr = pfd->Show(NULL);
             ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/shlobj.h:124:0,
                 from win.cpp:3:
/usr/i686-w64-mingw32/sys-root/mingw/include/shobjidl.h:672:19: note: forward declaration of 'IFileDialog {aka struct IFileDialog}'
 typedef interface IFileDialog IFileDialog;
                   ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/objbase.h:14:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/ole2.h:17,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/wtypes.h:12,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/winscard.h:10,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:97,
                 from win.cpp:1:
/usr/i686-w64-mingw32/sys-root/mingw/include/combaseapi.h: In instantiation of 'void** IID_PPV_ARGS_Helper(T**) [with T = IFileDialog]':
win.cpp:16:75:   required from here
/usr/i686-w64-mingw32/sys-root/mingw/include/combaseapi.h:79:5: error: invalid static_cast from type 'IFileDialog*' to type 'IUnknown*'
     static_cast<IUnknown *> (*pp);


This was compiled using the latest packages on Fedora 23, but I was having similar issues on Windows 10 running MSYS2. I was able to compile and run a larger test program in Visual Studio (also on Windows 10) that used the same APIs, so I'm not sure if there's just something I'm failing to pass into the compiler through the command line or if there's an issue in shlobj.h or shobjidl.h. If somebody could point me in the right direction or confirm/deny that there's an issue using these APIs when compiling with MinGW it would be greatly appreciated.

Thanks

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issues with IFileDialog

Lee Shallis
I don't have an actual answer but a suggestion in the event you can't get your answer here, try consulting the makers of allegro or IUP as they both use native look as default for their libraries. Also IUP has a lua extension if you want to give your users the ability to configure the UI themselves, allegro might have too but I haven't gotten round to checking that yet.

On 12 May 2016 at 17:58, Samuel Clark <[hidden email]> wrote:
Been running into issues while trying to get some native dialogs on Windows. I was able to get things to work fine using GetSaveFileName and GetOpenFileName, but the problem is that I also need to be able to select directories sometimes and don't want to use SHBrowseForFolder due to the dialog looking outdated. For this purpose I was switching over to the IFileDialog APIs, but have been getting errors while trying to compile the following.

[[win.cpp]]
#include <windows.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <shobjidl.h>
#include <stdio.h>
int main(int argc, char** argv)
{
  CoInitialize(NULL);
  HRESULT hr = S_OK;
  IFileDialog* pfd = NULL;
  hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER,, IID_PPV_ARGS(&pfd));
  if (SUCCEEDED(hr)) {
    hr = pfd->SetTitle(L"Select a File");
    hr = pfd->Show(NULL);
    if (SUCCEEDED(hr)) {
      printf("selected\n");
    } else {
      printf("nothing selected\n");
    }
  }
}

[[compilation output]]
i686-w64-mingw32-g++ -o win win.cpp -Wl,-subsystem,windows
win.cpp: In function 'int main(int, char**)':
win.cpp:19:13: error: invalid use of incomplete type 'IFileDialog {aka struct IFileDialog}'
     hr = pfd->SetTitle(L"Select a File");
             ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/shlobj.h:124:0,
                 from win.cpp:3:
/usr/i686-w64-mingw32/sys-root/mingw/include/shobjidl.h:672:19: note: forward declaration of 'IFileDialog {aka struct IFileDialog}'
 typedef interface IFileDialog IFileDialog;
                   ^
win.cpp:20:13: error: invalid use of incomplete type 'IFileDialog {aka struct IFileDialog}'
     hr = pfd->Show(NULL);
             ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/shlobj.h:124:0,
                 from win.cpp:3:
/usr/i686-w64-mingw32/sys-root/mingw/include/shobjidl.h:672:19: note: forward declaration of 'IFileDialog {aka struct IFileDialog}'
 typedef interface IFileDialog IFileDialog;
                   ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/objbase.h:14:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/ole2.h:17,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/wtypes.h:12,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/winscard.h:10,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:97,
                 from win.cpp:1:
/usr/i686-w64-mingw32/sys-root/mingw/include/combaseapi.h: In instantiation of 'void** IID_PPV_ARGS_Helper(T**) [with T = IFileDialog]':
win.cpp:16:75:   required from here
/usr/i686-w64-mingw32/sys-root/mingw/include/combaseapi.h:79:5: error: invalid static_cast from type 'IFileDialog*' to type 'IUnknown*'
     static_cast<IUnknown *> (*pp);


This was compiled using the latest packages on Fedora 23, but I was having similar issues on Windows 10 running MSYS2. I was able to compile and run a larger test program in Visual Studio (also on Windows 10) that used the same APIs, so I'm not sure if there's just something I'm failing to pass into the compiler through the command line or if there's an issue in shlobj.h or shobjidl.h. If somebody could point me in the right direction or confirm/deny that there's an issue using these APIs when compiling with MinGW it would be greatly appreciated.

Thanks

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issues with IFileDialog

Samuel Clark
In reply to this post by Samuel Clark
> IUP, allegro

Thanks for the suggestion. I went ahead and pulled the source code for
both of these projects, but they seem to be using GetOpenFileName,
GetSaveFileName, and SHBrowseForFolder.

As mentioned, I was able to get these API calls to work as well, but
unfortunately they don't give me the control that I'm looking for.
Compilation issues only seem to arise when trying to use stuff from
the shell interfaces Windows module (IFileDialog, IFileSaveDialog,
IFileOpenDialog, etc.).

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Issues with IFileDialog

Lee Shallis
Perhaps you're suppost to derive your own class from it and fill in any virtuals, check how the class and it's inherited classes are defined, they may give you hints as to what is going wrong

On 12 May 2016 at 23:09, Samuel Clark <[hidden email]> wrote:
> IUP, allegro

Thanks for the suggestion. I went ahead and pulled the source code for
both of these projects, but they seem to be using GetOpenFileName,
GetSaveFileName, and SHBrowseForFolder.

As mentioned, I was able to get these API calls to work as well, but
unfortunately they don't give me the control that I'm looking for.
Compilation issues only seem to arise when trying to use stuff from
the shell interfaces Windows module (IFileDialog, IFileSaveDialog,
IFileOpenDialog, etc.).

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Loading...