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
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. std::cout Messes Up Filter in OpenFileDialog

std::cout Messes Up Filter in OpenFileDialog

Scheduled Pinned Locked Moved .NET (Core and Framework)
c++csharpwinformsquestion
4 Posts 1 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.
  • R Offline
    R Offline
    ricecake
    wrote on last edited by
    #1

    Does anybody else experience the following behavior? When I comment out the line std::cout << 0; in f(), everything works fine. However, if I uncomment the line, then when I change the filter in the OpenFileDialog, all the files in the list disappear. This is using Visual C++ .NET 2003 (Managed Extensions to C++, not C++/CLI).

    1. I created a new Visual C++ Windows Forms Application (.NET).

    2. I added a button to this form.

    3. I added an event handler for this button that consists of the following: OpenFileDialog* dlg = new OpenFileDialog; dlg->Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; dlg->ShowDialog();

    4. I added a native C++ file that consists of the following:

      #include <iostream>
      
      void f()
      {
          // Comment the following line to get correct behavior
          std::cout << 0;
      }
      
    5. I turned off Precompiled Headers for the project. (not essential, otherwise you need to add #include "stdafx.h" to the native file).

    6. Compile and run (click the button then change the file filter).

    Note that nowhere in the program did I actually call the function f(). It seems that its mere existence in the project is enough to mess this up. -- Marcus Kwok

    R 3 Replies Last reply
    0
    • R ricecake

      Does anybody else experience the following behavior? When I comment out the line std::cout << 0; in f(), everything works fine. However, if I uncomment the line, then when I change the filter in the OpenFileDialog, all the files in the list disappear. This is using Visual C++ .NET 2003 (Managed Extensions to C++, not C++/CLI).

      1. I created a new Visual C++ Windows Forms Application (.NET).

      2. I added a button to this form.

      3. I added an event handler for this button that consists of the following: OpenFileDialog* dlg = new OpenFileDialog; dlg->Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; dlg->ShowDialog();

      4. I added a native C++ file that consists of the following:

        #include <iostream>
        
        void f()
        {
            // Comment the following line to get correct behavior
            std::cout << 0;
        }
        
      5. I turned off Precompiled Headers for the project. (not essential, otherwise you need to add #include "stdafx.h" to the native file).

      6. Compile and run (click the button then change the file filter).

      Note that nowhere in the program did I actually call the function f(). It seems that its mere existence in the project is enough to mess this up. -- Marcus Kwok

      R Offline
      R Offline
      ricecake
      wrote on last edited by
      #2

      Hmm, OK something is really weird now. I sent the code to a colleague of mine and the issue does not appear on his machine. I even sent him both versions of the executable, and neither version shows the bug on his machine, though the exact same exe's do show the bug on mine. :confused: -- Marcus Kwok

      1 Reply Last reply
      0
      • R ricecake

        Does anybody else experience the following behavior? When I comment out the line std::cout << 0; in f(), everything works fine. However, if I uncomment the line, then when I change the filter in the OpenFileDialog, all the files in the list disappear. This is using Visual C++ .NET 2003 (Managed Extensions to C++, not C++/CLI).

        1. I created a new Visual C++ Windows Forms Application (.NET).

        2. I added a button to this form.

        3. I added an event handler for this button that consists of the following: OpenFileDialog* dlg = new OpenFileDialog; dlg->Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; dlg->ShowDialog();

        4. I added a native C++ file that consists of the following:

          #include <iostream>
          
          void f()
          {
              // Comment the following line to get correct behavior
              std::cout << 0;
          }
          
        5. I turned off Precompiled Headers for the project. (not essential, otherwise you need to add #include "stdafx.h" to the native file).

        6. Compile and run (click the button then change the file filter).

        Note that nowhere in the program did I actually call the function f(). It seems that its mere existence in the project is enough to mess this up. -- Marcus Kwok

        R Offline
        R Offline
        ricecake
        wrote on last edited by
        #3

        I posted a workaround here: http://groups.google.com/group/microsoft.public.dotnet.languages.vc/msg/3f5536f97758b712[^] but unfortunately I don't think it will be of much use, since no one else was able to reproduce the bug. -- Marcus Kwok -- modified at 14:52 Tuesday 4th April, 2006

        1 Reply Last reply
        0
        • R ricecake

          Does anybody else experience the following behavior? When I comment out the line std::cout << 0; in f(), everything works fine. However, if I uncomment the line, then when I change the filter in the OpenFileDialog, all the files in the list disappear. This is using Visual C++ .NET 2003 (Managed Extensions to C++, not C++/CLI).

          1. I created a new Visual C++ Windows Forms Application (.NET).

          2. I added a button to this form.

          3. I added an event handler for this button that consists of the following: OpenFileDialog* dlg = new OpenFileDialog; dlg->Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; dlg->ShowDialog();

          4. I added a native C++ file that consists of the following:

            #include <iostream>
            
            void f()
            {
                // Comment the following line to get correct behavior
                std::cout << 0;
            }
            
          5. I turned off Precompiled Headers for the project. (not essential, otherwise you need to add #include "stdafx.h" to the native file).

          6. Compile and run (click the button then change the file filter).

          Note that nowhere in the program did I actually call the function f(). It seems that its mere existence in the project is enough to mess this up. -- Marcus Kwok

          R Offline
          R Offline
          ricecake
          wrote on last edited by
          #4

          Solution here: http://www.codeproject.com/script/comments/forums.asp?msg=1611776&forumid=3785#xx1611776xx[^]

          -- Marcus Kwok

          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