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 DLL and Dialogs

MFC DLL and Dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
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.
  • P Offline
    P Offline
    Peter Marino
    wrote on last edited by
    #1

    I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:

    L D 2 Replies Last reply
    0
    • P Peter Marino

      I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:

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

      I had the same problem through a COM ATL DLL, but the solution is the same, just build a release version of your DLL, it should work (ASSERT only in debug).:) :) Celhtar

      L P 2 Replies Last reply
      0
      • L Lost User

        I had the same problem through a COM ATL DLL, but the solution is the same, just build a release version of your DLL, it should work (ASSERT only in debug).:) :) Celhtar

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

        What you can't see won't hurt you:confused:

        P 1 Reply Last reply
        0
        • L Lost User

          I had the same problem through a COM ATL DLL, but the solution is the same, just build a release version of your DLL, it should work (ASSERT only in debug).:) :) Celhtar

          P Offline
          P Offline
          Peter Marino
          wrote on last edited by
          #4

          That isn't a very good solution. I do need my debug version... for debugging :-) and if it asserts then I'm doing something I shouldn't. The assert comes from the ::IsWindow( m_hWnd ) , the m_hWnd comes from my ProgramApp and I can use the lpDlg->SetWindowText( "Whatever" ) without anyproblems,.. but sending the lpDlg over to the DLL and using the same lpDlg->SetWindowText( "Whatever" ) asserts in the ::IsWindow function. The m_hWnd and lpDlg are the same both in the ProgramApp and ProgramDLL. For some reason the ProgramDLL can't see that the m_hWnd is a valid window in the ProgramDLL?! and this confuses me,.. I have now used 3 days and nights trying to solve this problem. :confused: :confused: :confused: :confused: :confused: :confused: Peter Marino ( www.marino.dk )

          1 Reply Last reply
          0
          • L Lost User

            What you can't see won't hurt you:confused:

            P Offline
            P Offline
            Peter Marino
            wrote on last edited by
            #5

            err, now you are confusing me even more :(( Peter Marino ( www.marino.dk )

            1 Reply Last reply
            0
            • P Peter Marino

              I have a problem I just don't get. I have created two programs, a ProgramApp and a ProgramDLL. The ProgramApp is a SDI and I create a standard modeless dialog when it starts up. Next I load the ProgramDLL so the ProgramApp can use it. I call a function in the Program DLL called ChangeDialogText( lpDlg ), this function sends the lpDlg pointer to the ProgramDLL when calling the ChangeDialogText( lpDlg ). ok, so far so good,.. now the ProgramDLL has a singal line that does this lpDlg->SetWindowText( "DLL Text" ).... bang here I get an assert that the lpDlg doesn't have a m_hWnd??!?!?! I have the AFX_MANAGE_STATE(AfxGetStaticModuleState()) in the beginning of the ChangeDialogText function. I just don't understand it,... it should work. what am I doing wrong. :confused:

              D Offline
              D Offline
              D D de Kerf
              wrote on last edited by
              #6

              Try building both the exe and the dll using MFC in a shared DLL. I found this problem too, and using shared dll's it was solved... Somehow when you use MFC in a shared DLL both the EXE and the DLL will use the same heap or something and pointers can do their work better... You can find the option in the project settings of the project (left tab). Please, let me know if it helped you. Structured programming vs. chaotic mind boggling

              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