Click here to Skip to main content
15,902,911 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IsWindow(m_hwnd) returns 0. Pin
Swinefeaster10-Nov-03 18:19
Swinefeaster10-Nov-03 18:19 
GeneralCDialogBar Background color Pin
asierra10-Nov-03 16:21
asierra10-Nov-03 16:21 
GeneralDesign opinions/help needed Pin
Steve Messer10-Nov-03 16:06
Steve Messer10-Nov-03 16:06 
GeneralRe: Design opinions/help needed Pin
Antti Keskinen11-Nov-03 11:21
Antti Keskinen11-Nov-03 11:21 
GeneralRe: Design opinions/help needed Pin
Steve Messer11-Nov-03 18:05
Steve Messer11-Nov-03 18:05 
GeneralRe: Design opinions/help needed Pin
Antti Keskinen12-Nov-03 8:25
Antti Keskinen12-Nov-03 8:25 
GeneralRe: Design opinions/help needed Pin
Steve Messer12-Nov-03 12:07
Steve Messer12-Nov-03 12:07 
GeneralRe: Design opinions/help needed Pin
Antti Keskinen13-Nov-03 0:44
Antti Keskinen13-Nov-03 0:44 
It seems there has been a misunderstanding when I readed your first message. My apologies.

When you use AfxLoadLibrary to map a DLL to the address space, it's DllMain (Or if you use MFC, it's CWinApp-derived object's InitInstance) gets executed on a seperate thread. This is a feature of AfxLoadLibrary, but I don't believe it will pose a problem.

It, however, means that you cannot pass C++ CWnd or CDialog objects (or their addresses) from the DLL to the main application. This will cause an assertion in the debug version of MFC, and most obviously, a crash in the release version.
You CAN pass the HWND of the dialog, if you need to post messages to it, or alternatively, create an exported function (from the DLL) to send the messages. Afterall, the function you export gets called within the DLL's thread, as you use GetProcAddress to get a POINTER to that function, which you then call from the main application.

Like said, if you export a function from the DLL which returns the HWND of the dialog, you can use this HWND to pass messages to the dialog. However, you can not return the address of the CWnd/CDialog object from the DLL. This violates the above-mentioned object sharing aspect.

The reason why I used custom message pumping in my application was because my application did not have a main window at all. MFC is designed to shut the thread down if, after the execution of InitInstance returning TRUE, the m_pMainWnd member of CWinApp is NULL.

I could've created my own dialog for the example application: I just didn't feel it necessary. Otherwise, your and my app work similarly. Both load a DLL, both create a dialog in that DLL. My case just is that I am force-running the thread to prevent framework from shutting it down before I want it to.

But, like you said, the problem is solved after you changed the plugin dialog to modeless. Good luck for the future development of the app, and feel free to ask if you run into any more problems Smile | :)

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Design opinions/help needed Pin
Steve Messer13-Nov-03 1:35
Steve Messer13-Nov-03 1:35 
GeneralRe: Design opinions/help needed Pin
Antti Keskinen13-Nov-03 5:17
Antti Keskinen13-Nov-03 5:17 
GeneralRe: Design opinions/help needed Pin
Steve Messer13-Nov-03 7:18
Steve Messer13-Nov-03 7:18 
GeneralOnGridEndEdit and MessageBox Pin
adonisv10-Nov-03 12:48
adonisv10-Nov-03 12:48 
GeneralFILETIME compilation error Pin
rmnowick10-Nov-03 12:31
rmnowick10-Nov-03 12:31 
GeneralRe: FILETIME compilation error Pin
Dave Bryant10-Nov-03 14:04
Dave Bryant10-Nov-03 14:04 
QuestionHow to change a toolbar bitmap image? Pin
ElizabethC10-Nov-03 11:08
ElizabethC10-Nov-03 11:08 
AnswerRe: How to change a toolbar bitmap image? Pin
Roger Allen11-Nov-03 0:40
Roger Allen11-Nov-03 0:40 
GeneralRe: How to change a toolbar bitmap image? Pin
ElizabethC12-Nov-03 6:47
ElizabethC12-Nov-03 6:47 
GeneralRe: How to change a toolbar bitmap image? Pin
Roger Allen12-Nov-03 6:49
Roger Allen12-Nov-03 6:49 
GeneralRe: How to change a toolbar bitmap image? Pin
ElizabethC12-Nov-03 10:49
ElizabethC12-Nov-03 10:49 
Generalopengl with visual c++ Pin
bik10-Nov-03 10:48
bik10-Nov-03 10:48 
GeneralRe: opengl with visual c++ Pin
Andrew Walker10-Nov-03 12:24
Andrew Walker10-Nov-03 12:24 
GeneralRe: opengl with visual c++ Pin
Orhun Birsoy10-Nov-03 13:07
Orhun Birsoy10-Nov-03 13:07 
Generalfile system in Mac Pin
pnpfriend10-Nov-03 10:31
pnpfriend10-Nov-03 10:31 
GeneralRe: file system in Mac Pin
Johnny ²10-Nov-03 11:24
Johnny ²10-Nov-03 11:24 
GeneralRe: file system in Mac Pin
pnpfriend12-Nov-03 4:00
pnpfriend12-Nov-03 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.