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. C / C++ / MFC
  4. MFC App (Visual Studio 6) hangs when you click File, Open.

MFC App (Visual Studio 6) hangs when you click File, Open.

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiodata-structuresdebugging
15 Posts 5 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.
  • K Offline
    K Offline
    Keith MapMan
    wrote on last edited by
    #1

    I have an MFC, multi-document template application, built using Visual Studio 6, which has been working for a long time now. Recently I moved to a new development machine and now my application hangs whenever I click the File menu and choose Open. I have run it in debug mode and traced into the MFC code. The point of failure is in DlgFile.cpp(part of Microsoft's MFC source) at line 108 where it calls ::GetOpenFileName(&m_ofn). It goes in there never to return. I spotted that the m_ofn structure points at a hook function _AfxCommDlgProc so I set a break point in that. The dialog receives the following windows messages before the application hangs: WM_SETFONT, WM_INITDLG, WM_SHOWWINDOW, WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_CHILDACTIVATE, WM_WINDOWPOSCHANGED then WM_SIZE. The WM_SIZE message is processed OK and AfxCommDlgProc then exits back to code for which source is unavailable. My dialog never receives another message. As a control I then tried exactly the same experiment on another MFC application of mine - one which doesn't fail. It acts exactly the same except that the WM_SIZE message is followed (after a short but noticable delay) by a WM_SETREDRAW after which the Open File dialog box appears. If I let the failing application hang then click on Debug, Break, the call stack is singularly uninformative: NTDLL! 7c90eb94() USER32! 7e4195f9() USER32! 7e4196a8() BROWSEUI! 75f8afc9() BROWSEUI! 75f8b591() SHLWAPI! 77f69588() NTDLL! 7c927545() NTDLL! 7c927583() NTDLL! 7c927645() NTDLL! 7c92761c() KERNEL32! 7c80b683() I am at my wits end. I am using the standard MFC file open mechanism with no undue cleverness. I can see no tangible difference between the failing application and a different application which works, apart from the file types it's looking for. Has anyone any sensible suggestions what to try next? Keith

    M C 2 Replies Last reply
    0
    • K Keith MapMan

      I have an MFC, multi-document template application, built using Visual Studio 6, which has been working for a long time now. Recently I moved to a new development machine and now my application hangs whenever I click the File menu and choose Open. I have run it in debug mode and traced into the MFC code. The point of failure is in DlgFile.cpp(part of Microsoft's MFC source) at line 108 where it calls ::GetOpenFileName(&m_ofn). It goes in there never to return. I spotted that the m_ofn structure points at a hook function _AfxCommDlgProc so I set a break point in that. The dialog receives the following windows messages before the application hangs: WM_SETFONT, WM_INITDLG, WM_SHOWWINDOW, WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_CHILDACTIVATE, WM_WINDOWPOSCHANGED then WM_SIZE. The WM_SIZE message is processed OK and AfxCommDlgProc then exits back to code for which source is unavailable. My dialog never receives another message. As a control I then tried exactly the same experiment on another MFC application of mine - one which doesn't fail. It acts exactly the same except that the WM_SIZE message is followed (after a short but noticable delay) by a WM_SETREDRAW after which the Open File dialog box appears. If I let the failing application hang then click on Debug, Break, the call stack is singularly uninformative: NTDLL! 7c90eb94() USER32! 7e4195f9() USER32! 7e4196a8() BROWSEUI! 75f8afc9() BROWSEUI! 75f8b591() SHLWAPI! 77f69588() NTDLL! 7c927545() NTDLL! 7c927583() NTDLL! 7c927645() NTDLL! 7c92761c() KERNEL32! 7c80b683() I am at my wits end. I am using the standard MFC file open mechanism with no undue cleverness. I can see no tangible difference between the failing application and a different application which works, apart from the file types it's looking for. Has anyone any sensible suggestions what to try next? Keith

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Does it timeout and eventually show or hang forever? Is it waiting for a reply from a network drive?

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      K 1 Reply Last reply
      0
      • K Keith MapMan

        I have an MFC, multi-document template application, built using Visual Studio 6, which has been working for a long time now. Recently I moved to a new development machine and now my application hangs whenever I click the File menu and choose Open. I have run it in debug mode and traced into the MFC code. The point of failure is in DlgFile.cpp(part of Microsoft's MFC source) at line 108 where it calls ::GetOpenFileName(&m_ofn). It goes in there never to return. I spotted that the m_ofn structure points at a hook function _AfxCommDlgProc so I set a break point in that. The dialog receives the following windows messages before the application hangs: WM_SETFONT, WM_INITDLG, WM_SHOWWINDOW, WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_CHILDACTIVATE, WM_WINDOWPOSCHANGED then WM_SIZE. The WM_SIZE message is processed OK and AfxCommDlgProc then exits back to code for which source is unavailable. My dialog never receives another message. As a control I then tried exactly the same experiment on another MFC application of mine - one which doesn't fail. It acts exactly the same except that the WM_SIZE message is followed (after a short but noticable delay) by a WM_SETREDRAW after which the Open File dialog box appears. If I let the failing application hang then click on Debug, Break, the call stack is singularly uninformative: NTDLL! 7c90eb94() USER32! 7e4195f9() USER32! 7e4196a8() BROWSEUI! 75f8afc9() BROWSEUI! 75f8b591() SHLWAPI! 77f69588() NTDLL! 7c927545() NTDLL! 7c927583() NTDLL! 7c927645() NTDLL! 7c92761c() KERNEL32! 7c80b683() I am at my wits end. I am using the standard MFC file open mechanism with no undue cleverness. I can see no tangible difference between the failing application and a different application which works, apart from the file types it's looking for. Has anyone any sensible suggestions what to try next? Keith

        C Offline
        C Offline
        Cosmic Egg
        wrote on last edited by
        #3

        I had a similar problem in which the standard MFC application was crashing on certain action inside file open dialog on few machines with a simple code..... The problem for me was solved for me after downloading a windows hotfix refer to this link if you can find something http://www.bokebb.com/dev/english/1960/posts/196055272.shtml[^]

        J K 2 Replies Last reply
        0
        • M Mark Salsbery

          Does it timeout and eventually show or hang forever? Is it waiting for a reply from a network drive?

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          K Offline
          K Offline
          Keith MapMan
          wrote on last edited by
          #4

          Mark Salsbery wrote:

          Does it timeout and eventually show or hang forever? Is it waiting for a reply from a network drive?

          So far as I know it hangs forever - but forever is a long time :) I may just not have stuck around long enough. I don't think it's a network drive issue because I have two similar applications. One always hangs and the other always works. There is clearly a tangible difference between the two but I can't figure out what it is. Keith

          M 1 Reply Last reply
          0
          • C Cosmic Egg

            I had a similar problem in which the standard MFC application was crashing on certain action inside file open dialog on few machines with a simple code..... The problem for me was solved for me after downloading a windows hotfix refer to this link if you can find something http://www.bokebb.com/dev/english/1960/posts/196055272.shtml[^]

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #5

            Wow, great link, I've had this problem for a good while on one particular machine, kind of forgot about until now.

            1 Reply Last reply
            0
            • C Cosmic Egg

              I had a similar problem in which the standard MFC application was crashing on certain action inside file open dialog on few machines with a simple code..... The problem for me was solved for me after downloading a windows hotfix refer to this link if you can find something http://www.bokebb.com/dev/english/1960/posts/196055272.shtml[^]

              K Offline
              K Offline
              Keith MapMan
              wrote on last edited by
              #6

              Thanks for the suggestion. I did follow up the link you posted but I think that situation is different. It was a crash, rather than a hang, and it occurred after the open-file dialog box was displayed. In my case the dialog is never displayed. It hangs before it gets to that point. Keith

              C 1 Reply Last reply
              0
              • K Keith MapMan

                Mark Salsbery wrote:

                Does it timeout and eventually show or hang forever? Is it waiting for a reply from a network drive?

                So far as I know it hangs forever - but forever is a long time :) I may just not have stuck around long enough. I don't think it's a network drive issue because I have two similar applications. One always hangs and the other always works. There is clearly a tangible difference between the two but I can't figure out what it is. Keith

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Does this code ripped right from the docs fail as well?

                TCHAR szFilters[]= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||");
                CFileDialog fileDlg(TRUE, _T("my"), _T("*.my"),
                OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);
                if(fileDlg.DoModal() == IDOK)
                {
                }

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                K 1 Reply Last reply
                0
                • K Keith MapMan

                  Thanks for the suggestion. I did follow up the link you posted but I think that situation is different. It was a crash, rather than a hang, and it occurred after the open-file dialog box was displayed. In my case the dialog is never displayed. It hangs before it gets to that point. Keith

                  C Offline
                  C Offline
                  Cosmic Egg
                  wrote on last edited by
                  #8

                  I just meant some other hotfix might be able to solve the problem...any way good luck this is all I know

                  1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Does this code ripped right from the docs fail as well?

                    TCHAR szFilters[]= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||");
                    CFileDialog fileDlg(TRUE, _T("my"), _T("*.my"),
                    OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);
                    if(fileDlg.DoModal() == IDOK)
                    {
                    }

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    K Offline
                    K Offline
                    Keith MapMan
                    wrote on last edited by
                    #9

                    Mark I was wrong. It doesn't hang forever. I decided to leave it whilst running a stop watch. After clicking File, Open there is (on my laptop) a 1 minute and 50 seconds delay before the standard open dialog appears. This is solidly repeatable. If I cancel the open-file dialog and then click File Open again then there is another 1:50 delay until the open-file dialog reappears. I pasted in your code snippet and that also takes nearly 2 minutes before the dialog appears so it's not the filters which are the problem. The identical code, pasted into another application, works without any delay. Keith

                    M D 2 Replies Last reply
                    0
                    • K Keith MapMan

                      Mark I was wrong. It doesn't hang forever. I decided to leave it whilst running a stop watch. After clicking File, Open there is (on my laptop) a 1 minute and 50 seconds delay before the standard open dialog appears. This is solidly repeatable. If I cancel the open-file dialog and then click File Open again then there is another 1:50 delay until the open-file dialog reappears. I pasted in your code snippet and that also takes nearly 2 minutes before the dialog appears so it's not the filters which are the problem. The identical code, pasted into another application, works without any delay. Keith

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #10

                      Keith (MapMan) wrote:

                      The identical code, pasted into another application, works without any delay.

                      That's not good :) I'm thinking...

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      K 2 Replies Last reply
                      0
                      • M Mark Salsbery

                        Keith (MapMan) wrote:

                        The identical code, pasted into another application, works without any delay.

                        That's not good :) I'm thinking...

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        K Offline
                        K Offline
                        Keith MapMan
                        wrote on last edited by
                        #11

                        >>I'm thinking... I'm giving up for today so no rush. One more bit of information. File Save As exhibits same long delay before displaying dialog. Keith

                        1 Reply Last reply
                        0
                        • K Keith MapMan

                          Mark I was wrong. It doesn't hang forever. I decided to leave it whilst running a stop watch. After clicking File, Open there is (on my laptop) a 1 minute and 50 seconds delay before the standard open dialog appears. This is solidly repeatable. If I cancel the open-file dialog and then click File Open again then there is another 1:50 delay until the open-file dialog reappears. I pasted in your code snippet and that also takes nearly 2 minutes before the dialog appears so it's not the filters which are the problem. The identical code, pasted into another application, works without any delay. Keith

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          Keith (MapMan) wrote:

                          I pasted in your code snippet and that also takes nearly 2 minutes before the dialog appears so it's not the filters which are the problem. The identical code, pasted into another application, works without any delay.

                          That makes it sounds as though CFileDialog may not be the problem. How about just creating a dummy MDI application to see what it does with all of the default settings and code?

                          "Love people and use things, not love things and use people." - Unknown

                          "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                          K 1 Reply Last reply
                          0
                          • D David Crow

                            Keith (MapMan) wrote:

                            I pasted in your code snippet and that also takes nearly 2 minutes before the dialog appears so it's not the filters which are the problem. The identical code, pasted into another application, works without any delay.

                            That makes it sounds as though CFileDialog may not be the problem. How about just creating a dummy MDI application to see what it does with all of the default settings and code?

                            "Love people and use things, not love things and use people." - Unknown

                            "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                            K Offline
                            K Offline
                            Keith MapMan
                            wrote on last edited by
                            #13

                            I think you're probably right that it's not CFileDialog's problem as such. Something else about the application is causing the problem. I'm pretty confident that if I created another dummy MDI app it would not exhibit the problem because I already have other real, not dummy, MDI apps which don't exhibit this behaviour. What I think I might do is take a copy of the failing application and start knocking bits out of it to see if I can find something which makes it work. If I don't get anywhere that way then I may try as you suggest, start with a brand new project then gradually add back in the functionality of my app. It's going to be a long haul, though. There's rather a lot of it. Keith

                            1 Reply Last reply
                            0
                            • M Mark Salsbery

                              Keith (MapMan) wrote:

                              The identical code, pasted into another application, works without any delay.

                              That's not good :) I'm thinking...

                              Mark Salsbery Microsoft MVP - Visual C++ :java:

                              K Offline
                              K Offline
                              Keith MapMan
                              wrote on last edited by
                              #14

                              Mark >>I'm thinking... If you are still thinking, stop. What my computer needed (apparently) was a good night's sleep. This morning I cannot reproduce the problem. The application works perfectly! Contrary or what? I've not even rebooted in the interim. At the end of the day I just shut the lid on my laptop and it hibernates. I fired it up briefly at home yesterday evening to check my emails (didn't even try to run the failing app) then this morning I started again, connected to the same office network environment as yesterday, and the problem has magically gone away. I guess we shall just have to put it down to one of those strange abberations that computers seem to have from time to time. If anyone has any theories I'd be interested to hear them but I suspect they will have to remain just that, theories. Keith

                              M 1 Reply Last reply
                              0
                              • K Keith MapMan

                                Mark >>I'm thinking... If you are still thinking, stop. What my computer needed (apparently) was a good night's sleep. This morning I cannot reproduce the problem. The application works perfectly! Contrary or what? I've not even rebooted in the interim. At the end of the day I just shut the lid on my laptop and it hibernates. I fired it up briefly at home yesterday evening to check my emails (didn't even try to run the failing app) then this morning I started again, connected to the same office network environment as yesterday, and the problem has magically gone away. I guess we shall just have to put it down to one of those strange abberations that computers seem to have from time to time. If anyone has any theories I'd be interested to hear them but I suspect they will have to remain just that, theories. Keith

                                M Offline
                                M Offline
                                Mark Salsbery
                                wrote on last edited by
                                #15

                                Crazy :) Thanks for the update! Mark

                                Mark Salsbery Microsoft MVP - Visual C++ :java:

                                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