On Friday, 10 January 2020 at 14:48:49 UTC, Marcone wrote:
How create "Open" and "Save as" Dialog using "Win32 Api" and Dlang? Please send me a simple example code in Dlang. Thank you very much.

This code works, but I can't get file Path. Someone can help me?

import std;
import core.sys.windows.windows;
pragma(lib, "comdlg32");

void main(){
    OPENFILENAME ofn;
    wchar* szFileName;
    (cast(byte*)& ofn)[0 .. ofn.sizeof] = 0;
    ofn.lStructSize = ofn.sizeof;
    ofn.hwndOwner = null;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
    ofn.lpstrFile = szFileName;
    ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    ofn.lpstrDefExt = "txt";
    if(GetOpenFileNameW(&ofn)){
      writeln(szFileName); // Print null
      writeln(ofn.lpstrFile); // Print null
    }
}

Reply via email to