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. Problems with dialog in DLL

Problems with dialog in DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 2 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.
  • V Offline
    V Offline
    vmaltsev
    wrote on last edited by
    #1

    Hello everyone, I have problems with joining console app and DLL with simple non-modal dialog in it. In DLL::InitInstance() I call Dlg.Create(IDD, NULL) and Dlg.ShowWindow(SW_SHOW) and it works. So when I load dll in console app I can see dialog. The problem appears after that. Dialog is simply dead. It can't ever repaint itself after overlapping. But if I show MessageBox after LoadLibrary, everything ok. Dialog is alive and can parse messages. I thought that problem is in my console app and put Sleep() in it, but nothing changed. Can anyone help me with it? Thanks in advance.

    H 1 Reply Last reply
    0
    • V vmaltsev

      Hello everyone, I have problems with joining console app and DLL with simple non-modal dialog in it. In DLL::InitInstance() I call Dlg.Create(IDD, NULL) and Dlg.ShowWindow(SW_SHOW) and it works. So when I load dll in console app I can see dialog. The problem appears after that. Dialog is simply dead. It can't ever repaint itself after overlapping. But if I show MessageBox after LoadLibrary, everything ok. Dialog is alive and can parse messages. I thought that problem is in my console app and put Sleep() in it, but nothing changed. Can anyone help me with it? Thanks in advance.

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      You have to control the console's message queue. When you call MessageBox, the message loop is created by default, offering to your modeless' messages the chance of being dispatched. But after you close the message box, the modeless is dead again, right? If you need to use the console for input purposes - as making calls like cin - then this thread[^] might be useful. rechi

      V 1 Reply Last reply
      0
      • H Hans Ruck

        You have to control the console's message queue. When you call MessageBox, the message loop is created by default, offering to your modeless' messages the chance of being dispatched. But after you close the message box, the modeless is dead again, right? If you need to use the console for input purposes - as making calls like cin - then this thread[^] might be useful. rechi

        V Offline
        V Offline
        vmaltsev
        wrote on last edited by
        #3

        Thanks for the answer. The problem is that I don't want to control Dialog in DLL from console app. I simply would like to have independent dialog from console app. In the same DLL, where dialog is defined, I have other functions. So the only things that console app knows about DLL are those exported functions. Is it possible to make dialog in DLL independent, to be able to use it in any application? Best regards.

        H 1 Reply Last reply
        0
        • V vmaltsev

          Thanks for the answer. The problem is that I don't want to control Dialog in DLL from console app. I simply would like to have independent dialog from console app. In the same DLL, where dialog is defined, I have other functions. So the only things that console app knows about DLL are those exported functions. Is it possible to make dialog in DLL independent, to be able to use it in any application? Best regards.

          H Offline
          H Offline
          Hans Ruck
          wrote on last edited by
          #4

          va`Lery wrote: Is it possible to make dialog in DLL independent, to be able to use it in any application? It's me again. I did some research meanwhile and... it's possible! (with a minimum of effort, calling an exported function). You have to use a modal dialog box from a worker thread created inside the dll. Unfortunately you cannot create the worker from InitInstance, so you have to do it using some exported function, after LoadLibrary call ends. rechi

          V 1 Reply Last reply
          0
          • H Hans Ruck

            va`Lery wrote: Is it possible to make dialog in DLL independent, to be able to use it in any application? It's me again. I did some research meanwhile and... it's possible! (with a minimum of effort, calling an exported function). You have to use a modal dialog box from a worker thread created inside the dll. Unfortunately you cannot create the worker from InitInstance, so you have to do it using some exported function, after LoadLibrary call ends. rechi

            V Offline
            V Offline
            vmaltsev
            wrote on last edited by
            #5

            Hi, Thanks for the research. :) But I can't implement it due to two problems. First of all, I can't create a dialog in a thread from the template in my dll. Only way to do it is via dll's HMODULE and ::FindResource+::LoadResource and then CreateInderect. I don't think it's normal. Second is that after DoModal I get error message ERROR_RESOURCE_DATA_NOT_FOUND(1812). Even if I create the dialog in the DLL::InitInstance, which is possible to do with normal .Create(id, pWnd), I have the same error in DoModal. Any ideas? :confused: If you did it somehow, maybe you can send me an example? And one small remark, if I use modal dialog in child thread, does that mean that my main thread will be suspended until modal dialog on a screen? Thanks for your help.

            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