• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Open/Save Dialogs

Started by James C. Fuller, January 10, 2017, 08:59:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

Patrice,
  What are you using for Open/Save Dialogs?

James

Patrice Terrier

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);
        }
    }
}
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Frederick J. Harris

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'. 

James C. Fuller

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

Patrice Terrier

#4
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.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com