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. DoModal in DropFiles Error ?!

DoModal in DropFiles Error ?!

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
17 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.
  • C Cedric Moonen

    Stephen was asking for some code of your own. So, use the call stack to find in which function it crashes (or you can also use your debugger, which is very very helpfull).

    G Offline
    G Offline
    GrumbleWeedster
    wrote on last edited by
    #6

    int RetVal; int nFiles = DragQueryFile(hDrop, -1, szDroppedFile, 2048); for(int i=0;i-1) // if x>-1 a duplicate filename already exists { CFileReplace md; md.ReturnValue=&RetVal; md.DoModal(); // Depending on RetVal value either replace the file or skip ... } ... If I comment out the 3 lines regarding the CFileReplace function and assign a value to RetVal the function works fine, it's only by calling DoModal that the error occurs.

    D 1 Reply Last reply
    0
    • G GrumbleWeedster

      Hi, I've coded a dialog based app that allows you to drop files into a listbox. Once the drop has taken place I've written some code to check if the files dropped are already listed in the lisbox - and if so a dialog box shows asking the user if they want to replace their existing files (pretty much like windows explorer). My problem is, everything works fine until the end of the DropFiles function is reached..when it returns the program crashes from the following Assert: ASSERT(::IsWindow(m_hWnd)); Anyone know how to fix this? :confused: Thanks in advance.

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #7

      This error can occours if you destroyed that CWnd object into the DropFiles function. else, be more clear to understand how the error comes, or how work the function. Have a nice code day ;)

      1 Reply Last reply
      0
      • G GrumbleWeedster

        int RetVal; int nFiles = DragQueryFile(hDrop, -1, szDroppedFile, 2048); for(int i=0;i-1) // if x>-1 a duplicate filename already exists { CFileReplace md; md.ReturnValue=&RetVal; md.DoModal(); // Depending on RetVal value either replace the file or skip ... } ... If I comment out the 3 lines regarding the CFileReplace function and assign a value to RetVal the function works fine, it's only by calling DoModal that the error occurs.

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

        What does the CFileReplace dialog do when it is being dismissed?


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        G 1 Reply Last reply
        0
        • D David Crow

          What does the CFileReplace dialog do when it is being dismissed?


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          G Offline
          G Offline
          GrumbleWeedster
          wrote on last edited by
          #9

          it exits with OnOK()

          D 1 Reply Last reply
          0
          • G GrumbleWeedster

            it exits with OnOK()

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

            GrumbleWeedster wrote:

            it exits with OnOK()

            That's all that's in CFileReplace::OnOK()? Is CFileReplace::ReturnValue a pointer? Where does it get assigned a new value?


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            G 1 Reply Last reply
            0
            • D David Crow

              GrumbleWeedster wrote:

              it exits with OnOK()

              That's all that's in CFileReplace::OnOK()? Is CFileReplace::ReturnValue a pointer? Where does it get assigned a new value?


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              G Offline
              G Offline
              GrumbleWeedster
              wrote on last edited by
              #11

              At this moment it isn't returning a value because of the current problem, it's still a plain dialog box with an OnOK() to close.

              D 1 Reply Last reply
              0
              • G GrumbleWeedster

                At this moment it isn't returning a value because of the current problem, it's still a plain dialog box with an OnOK() to close.

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

                Ok, so what happens in CFileReplace::OnInitDialog()?


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                G 1 Reply Last reply
                0
                • D David Crow

                  Ok, so what happens in CFileReplace::OnInitDialog()?


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  G Offline
                  G Offline
                  GrumbleWeedster
                  wrote on last edited by
                  #13

                  Nothing. At the moment CFileReplace is an empty default dialog with and OK and Cancel button. There are no custom functions in place yet because I need to get around the initial error.

                  D 1 Reply Last reply
                  0
                  • G GrumbleWeedster

                    Nothing. At the moment CFileReplace is an empty default dialog with and OK and Cancel button. There are no custom functions in place yet because I need to get around the initial error.

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

                    GrumbleWeedster wrote:

                    At the moment CFileReplace is an empty default dialog with and OK and Cancel button. There are no custom functions in place...

                    Based on that, can we then assume that it has no bearing on the problem? Also, answering this question will go a long way towards the solution.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    G 1 Reply Last reply
                    0
                    • D David Crow

                      GrumbleWeedster wrote:

                      At the moment CFileReplace is an empty default dialog with and OK and Cancel button. There are no custom functions in place...

                      Based on that, can we then assume that it has no bearing on the problem? Also, answering this question will go a long way towards the solution.


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "There is no death, only a change of worlds." - Native American Proverb

                      G Offline
                      G Offline
                      GrumbleWeedster
                      wrote on last edited by
                      #15

                      I may have found a solution but can anyone tell me if it could cause a problem? Changing the code in PreTranslateMessage(MSG* pMsg) stopped the error from occuring: Original Code: (Not Working) if( pMsg->message == WM_DROPFILES) OnDropFiles(pMsg->wParam,pMsg->lParam); return CDialog::PreTranslateMessage(pMsg); Modified Code: (Working) if( pMsg->message == WM_DROPFILES) { OnDropFiles(pMsg->wParam,pMsg->lParam); ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; } else return CDialog::PreTranslateMessage(pMsg); As I said, this does make the function work correctly, but is it a solution or is it just diverting from the error?

                      D 1 Reply Last reply
                      0
                      • G GrumbleWeedster

                        I may have found a solution but can anyone tell me if it could cause a problem? Changing the code in PreTranslateMessage(MSG* pMsg) stopped the error from occuring: Original Code: (Not Working) if( pMsg->message == WM_DROPFILES) OnDropFiles(pMsg->wParam,pMsg->lParam); return CDialog::PreTranslateMessage(pMsg); Modified Code: (Working) if( pMsg->message == WM_DROPFILES) { OnDropFiles(pMsg->wParam,pMsg->lParam); ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; } else return CDialog::PreTranslateMessage(pMsg); As I said, this does make the function work correctly, but is it a solution or is it just diverting from the error?

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

                        GrumbleWeedster wrote:

                        if( pMsg->message == WM_DROPFILES)

                        What's this? Why are you looking for this message in the PreTranslateMessage() method? You should be handling the WM_DROPFILES message via the message map:

                        BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
                        //{{AFX_MSG_MAP(CMyDlg)
                        ON_MESSAGE(WM_DROPFILES, OnDropFiles)
                        //}}AFX_MSG_MAP
                        END_MESSAGE_MAP()


                        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                        "There is no death, only a change of worlds." - Native American Proverb

                        G 1 Reply Last reply
                        0
                        • D David Crow

                          GrumbleWeedster wrote:

                          if( pMsg->message == WM_DROPFILES)

                          What's this? Why are you looking for this message in the PreTranslateMessage() method? You should be handling the WM_DROPFILES message via the message map:

                          BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
                          //{{AFX_MSG_MAP(CMyDlg)
                          ON_MESSAGE(WM_DROPFILES, OnDropFiles)
                          //}}AFX_MSG_MAP
                          END_MESSAGE_MAP()


                          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                          "There is no death, only a change of worlds." - Native American Proverb

                          G Offline
                          G Offline
                          GrumbleWeedster
                          wrote on last edited by
                          #17

                          Dialog based applications can't seem to handle drop files that way. Nothing is ever added to the list when items are dropped. The only way I've found to enable drag and drop in a dialog based app is intercept the message in PreTranslateMessage()

                          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