Problems with dialog in DLL
-
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.
-
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.
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 likecin
- then this thread[^] might be useful. rechi -
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 likecin
- then this thread[^] might be useful. rechiThanks 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.
-
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.
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, afterLoadLibrary
call ends. rechi -
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, afterLoadLibrary
call ends. rechiHi, 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.