Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFileDialog trouble

CFileDialog trouble

Scheduled Pinned Locked Moved C / C++ / MFC
csharphelpvisual-studiosysadminquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrew Medvedev
    wrote on last edited by
    #1

    Hi. I'll trying to open simple file dialog from view of my single document application. MSDN->Help... ////////////////////// begin /////////////////////////////////////// // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." char szFilters[]= "MyType Files (*.my)|*.my|All Files (*.*)|*.*||"; // Create an Open dialog; the default file name extension is ".my". CFileDialog *fileDlg =new CFileDialog(TRUE, "my", "*.my", OFN_EXPLORER | OFN_HIDEREADONLY, szFilters, this); // Display the file dialog. When user clicks OK, fileDlg.DoModal() // returns IDOK. if( fileDlg->DoModal ()==IDOK ) { CString pathName = fileDlg->GetPathName(); // Implement opening and reading file in here. ... //Change the window's title to the opened file's title. CString fileName = fileDlg->GetFileTitle (); } delete fileDlg; /////////////////////////////// end //////////////////////////////// fileDlg->DoModal() return IDCANCEL and dialog window is not showed... :(( I try to create dialog based application, insert this block of code and get my dialog... Where is mistake???? :eek: This bug is ONLY on windows NT4 server... XP works fine. :~ :confused: Used Visual Studio .NET (VC7++) Thanks for help and sorry for bad english. ;)

    L N 2 Replies Last reply
    0
    • A Andrew Medvedev

      Hi. I'll trying to open simple file dialog from view of my single document application. MSDN->Help... ////////////////////// begin /////////////////////////////////////// // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." char szFilters[]= "MyType Files (*.my)|*.my|All Files (*.*)|*.*||"; // Create an Open dialog; the default file name extension is ".my". CFileDialog *fileDlg =new CFileDialog(TRUE, "my", "*.my", OFN_EXPLORER | OFN_HIDEREADONLY, szFilters, this); // Display the file dialog. When user clicks OK, fileDlg.DoModal() // returns IDOK. if( fileDlg->DoModal ()==IDOK ) { CString pathName = fileDlg->GetPathName(); // Implement opening and reading file in here. ... //Change the window's title to the opened file's title. CString fileName = fileDlg->GetFileTitle (); } delete fileDlg; /////////////////////////////// end //////////////////////////////// fileDlg->DoModal() return IDCANCEL and dialog window is not showed... :(( I try to create dialog based application, insert this block of code and get my dialog... Where is mistake???? :eek: This bug is ONLY on windows NT4 server... XP works fine. :~ :confused: Used Visual Studio .NET (VC7++) Thanks for help and sorry for bad english. ;)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I'm sorry I can't help you. But I have one question: Why do you create the file dialog on the heap? It's enough to create the variable on the stack since the dialog is modal anyway

      A 1 Reply Last reply
      0
      • L Lost User

        I'm sorry I can't help you. But I have one question: Why do you create the file dialog on the heap? It's enough to create the variable on the stack since the dialog is modal anyway

        A Offline
        A Offline
        Andrew Medvedev
        wrote on last edited by
        #3

        I agree with you... I've just tested. :-O In original MSDN article dialog created normaly, as variable. I will correct my post...

        1 Reply Last reply
        0
        • A Andrew Medvedev

          Hi. I'll trying to open simple file dialog from view of my single document application. MSDN->Help... ////////////////////// begin /////////////////////////////////////// // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." char szFilters[]= "MyType Files (*.my)|*.my|All Files (*.*)|*.*||"; // Create an Open dialog; the default file name extension is ".my". CFileDialog *fileDlg =new CFileDialog(TRUE, "my", "*.my", OFN_EXPLORER | OFN_HIDEREADONLY, szFilters, this); // Display the file dialog. When user clicks OK, fileDlg.DoModal() // returns IDOK. if( fileDlg->DoModal ()==IDOK ) { CString pathName = fileDlg->GetPathName(); // Implement opening and reading file in here. ... //Change the window's title to the opened file's title. CString fileName = fileDlg->GetFileTitle (); } delete fileDlg; /////////////////////////////// end //////////////////////////////// fileDlg->DoModal() return IDCANCEL and dialog window is not showed... :(( I try to create dialog based application, insert this block of code and get my dialog... Where is mistake???? :eek: This bug is ONLY on windows NT4 server... XP works fine. :~ :confused: Used Visual Studio .NET (VC7++) Thanks for help and sorry for bad english. ;)

          N Offline
          N Offline
          Nitron
          wrote on last edited by
          #4

          try changing this:

          CFileDialog *fileDlg = new CFileDialog(TRUE, "my", "*.my",
          OFN_EXPLORER | OFN_HIDEREADONLY,
          szFilters, this);

          to either

          NULL
          

          or

          AfxGetMainWnd()
          

          - Nitron


          "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

          A 1 Reply Last reply
          0
          • N Nitron

            try changing this:

            CFileDialog *fileDlg = new CFileDialog(TRUE, "my", "*.my",
            OFN_EXPLORER | OFN_HIDEREADONLY,
            szFilters, this);

            to either

            NULL
            

            or

            AfxGetMainWnd()
            

            - Nitron


            "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

            A Offline
            A Offline
            Andrew Medvedev
            wrote on last edited by
            #5

            Thanks for your reply... "NULL", "AfxGetMainWnd()","this" perfectly work, but under win2k and XP. NT4 don't want to show dialog. DoModal() returns IDCANCEL after call.:((

            N 1 Reply Last reply
            0
            • A Andrew Medvedev

              Thanks for your reply... "NULL", "AfxGetMainWnd()","this" perfectly work, but under win2k and XP. NT4 don't want to show dialog. DoModal() returns IDCANCEL after call.:((

              N Offline
              N Offline
              Nitron
              wrote on last edited by
              #6

              Andrew Medvedev wrote: NT4 don't want to show dialog. Hmm... I just noticed u said you are using VS7. I wonder if it's a .net thing. Try re-posting in the .net forum and see if anyone there has experienced this. Good luck. - Nitron


              "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups