谢谢、我配置了几次,总是得不到输入的文件名称

解决方案 »

  1.   

    Ofn.lStructSize = sizeof(OPENFILENAME); 
    Ofn.hwndOwner = hWnd; 
    Ofn.lpstrFilter = szFilter; 
    Ofn.lpstrFile= szFile; //在这里,先要申请足够的空间
    Ofn.nMaxFile = sizeof(szFile)/ sizeof(*szFile); 
    Ofn.lpstrFileTitle = szFileTitle; 
    Ofn.nMaxFileTitle = sizeof(szFileTitle); 
    Ofn.lpstrInitialDir = (LPSTR)NULL; 
    Ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT; 
    Ofn.lpstrTitle = szTitle; 
     
    // Display the Filename common dialog box. The 
    // filename specified by the user is passed 
    // to the CreateEnhMetaFile function and used to 
    // store the metafile on disk. 
     
    GetSaveFileName(&Ofn); Ofn.lpstrFile就是
      

  2.   

    OPENFILENAME ofn; 
    ZeroMemory(&ofn, sizeof(ofn)); 
            ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = NULL; 
    ofn.lpstrFilter = "bitmap (*.bmp)\0*.BMP\0All\0*.*\0";  
    ofn.nMaxFile = MAX_PATH; 
    ofn.lpstrTitle="";
    ofn.lpstrDefExt="*.bmp";
    ofn.nMaxFile = 1024;
    ofn.hInstance = AfxGetInstanceHandle ();
    ofn.Flags=OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER  |OFN_HIDEREADONLY;;
    if(GetSaveFileName(&ofn)==true) 
    {
    CString str=ofn.lpstrFile;
    AfxMessageBox(str);

    }为什么得不到值?
      

  3.   

    TCHAR szFile[1024]="";
    ofn.lpstrFile=szFile;
    ...