Idle processing in USER DLL
Sanjay -- SGUPTA@aegonusa.com Tuesday, May 07, 1996 Environment: Win3.1 VC++1.52 I have a C++ USER DLL which normally reads file and does different stuff in response to commands read from the file until end of file. If one of the commands in the file is, say "INTERACT", in response to this command, the DLL should bring up a modelesss dialog box and stay idle in the DLL itself until user presses a button on the modeless dialog box. As soon as the button is pressed, modeless dialog disappears and reading of the rest of the file by the DLL should be resumed. Main problem is to stay in the DLL idle as long as the modeless dialog box is up and user should be alloed to do anything else. How can i stay in the DLL idle and then receive a message or something to resume the processing of the file. I do not want to put any code in the main application because all this is very specific to DLL itlself. Any help will be appreciated. I ahve already looked at DLLTRACE sample but still I can't seem to figure this out. Thanks Sanjay
David W. Gillett -- DGILLETT@expertedge.com Thursday, May 09, 1996 [Mini-digest: 3 responses] > Environment: > Win3.1 > VC++1.52 > > I have a C++ USER DLL which normally reads file and does different > stuff in response to commands read from the file until end of > file. If one of the commands in the file is, say "INTERACT", in > response to this command, the DLL should bring up a modelesss > dialog box and stay idle in the DLL itself until user presses a > button on the modeless dialog box. As soon as the button is > pressed, modeless dialog disappears and reading of the rest of the > file by the DLL should be resumed. > > Main problem is to stay in the DLL idle as long as the modeless > dialog box is up and user should be alloed to do anything else. > How can i stay in the DLL idle and then receive a message or > something to resume the processing of the file. I do not want to > put any code in the main application because all this is very > specific to DLL itlself. > > Any help will be appreciated. I ahve already looked at DLLTRACE > sample but still I can't seem to figure this out. Modelessness means getting the dialog's messages dispatched off an application's message queue with calls to IsDialogMessage(). If you put a message loop in the DLL, breaking out when a flag is set as the dialog is dismissed (or when its window handle stops being valid), then this should work okay -- unless the app calling the DLL has other modeless dialogs that would *also* like to receive messages.... File I/O and message queue handling are two things better done in a .EXE than in a .DLL. Perhaps your DLL should have a private .EXE that it starts up to do the job on behalf of a calling application -- in the long run, I think that will avoid more problems than it raises. [If the .EXE implicitly links to your .DLL, trying to launch the .EXE from LibMain() will cause LibMain() to be called again, and again....] Dave -----From: "Frederic Steppe"You may try something like this : In your CDialog-derived class, implement the following function : BOOL CMyDlg::MustLeave() { ASSERT(m_hWnd!=NULL); MSG msg; while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(!IsDialogMessage(&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return m_bMustLeave; } Of course, you need a member variable named m_bMustLeave, which is set to FALSE by the constructor, and set to TRUE by a function you define (I guess somethink like OnCancel()). In your main DLL's code, implement this : CMyDlg Dlg; Dlg.Create(); while(!Dlg.MustLeave()) { // Do anything you want while waiting, even do nothing ! } Dlg.DestroyWindow(); Frederic Steppe (frederics@msn.com) -----From: Jeff Lindholm Why not use a Modal dialog, these were made for exactly what you want. Jeff
| Вернуться в корень Архива |