Powerbasic Museum 2020-B

IT-Consultant: Patrice Terrier => C++ programming (SDK style) => Topic started by: James C. Fuller on January 10, 2017, 08:59:59 PM

Title: Open/Save Dialogs
Post by: James C. Fuller on January 10, 2017, 08:59:59 PM
Patrice,
  What are you using for Open/Save Dialogs?

James
Title: Re: Open/Save Dialogs
Post by: Patrice Terrier on January 10, 2017, 11:38:21 PM
Here is a simple one


void OnFileOpen() {
    const WCHAR *lpstrFilter = L"Media Files\0*.aac;*.asf;*.avi;*.m4a;*.mp3;*.mp4;*.wav;*.wma;*.wmv;*.3gp;*.3g2;*.mpeg;*.mpg;*.mov;*.qt;*.mkv;*.flv\0"
                               L"All files\0*.*\0";

    HRESULT hr = S_OK;

    OPENFILENAME ofn;
    ZeroMemory(&ofn, sizeof(ofn));

    WCHAR szFile[MAX_PATH];
    szFile[0] = L'\0';

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = gP.hMain;
    ofn.hInstance = gP.instance;
    ofn.lpstrFilter = lpstrFilter;
    ofn.lpstrFile = szFile;
    ofn.nMaxFile = MAX_PATH;
    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;

    if (GetOpenFileName(&ofn)) {
        PlayMediaFile(gP.hMain, szFile);
    } else {
        // GetOpenFileName can return FALSE because the user cancelled,
        // or because it failed. Check for errors.
        DWORD err = CommDlgExtendedError();
        if (err != 0) {
            NotifyError(L"GetOpenFileName failed.", E_FAIL);
        }
    }
}
Title: Re: Open/Save Dialogs
Post by: Frederick J. Harris on January 17, 2017, 03:32:32 AM
I was half expecting Patrice's reply to indicate he was using the newer COM wrappers for his file open/save work.  I know Jose posted about them a long time ago, and occasionally I see them used elsewhere, but as of yet I haven't explored them.  Guess its a case of 'if it ain't broke, don't fix it'. 
Title: Re: Open/Save Dialogs
Post by: James C. Fuller on January 17, 2017, 10:59:15 AM
Fred,
  I too was a bit surprised. I asked because I was using the COM method and experienced the issues I emailed you about when using UPX. As I indicated in email it was the new version of UPX that was the culprit with both the COM and this version.

James
Title: Re: Open/Save Dialogs
Post by: Patrice Terrier on January 17, 2017, 11:09:10 AM
The one i posted was just a quick cut and paste form the latest SDK examples written by... Microsoft, go figure  :)

Side note: i hate COM, and i am using it when i have no other choice.