Similar Threads
1. Problem opening an Open File Dialog.
2. problems when a non modal dialog closes, and has an open Modal Dialog
I have a non-modal dialog box whos parent window is the main MDI window.
I then have a modal Dialog box that can popup with the nonmodal box as
its parent.
If the Non-Modal Box gets closed (user removes its document from the MDI
interface.)
then A get an assert because DoModal is still funning, on a window that
does not exist.
So My question is how do I stop domodal from running in a safe way?
thanks,
how
3. Problems with new File Open Dialog in a 16 bit Application
4. File Open with Common Dialog Box Problem with Cancel
When I open a file using the Common Dialog Box, if I select the cancel option, my code still tries to open the file. The code begins with:
OpenDialog1->Execute();
The remaining lines translate the contents of a file into user readable information on a form. No problems with that, but it is clear that selecting CANCEL in the file open dialog box doesn't stop the execution of subsequent code after the line shown. My problem is how to recognize the "CANCEL" selection after "OpenDialog1->Execute();" if a file is not selected.
I don't want to try to read data that hasn't been loaded if no file is selected to be opened and "CANCEL" is instead selected. I recall seeing something like "OnCancelExecute()" in other code but don't know how to come up with the precise way to code this.
Thanks for your help with this in advance.
5. Open File Dialog Problem - CSharp/C#
6. File Open dialog box problem
Hi
I am creating a file open dialog box in explorer style.
In that i am filtering ".cpg" files.
If cpg files are not registered in the system , Windows explorer and
File open dialog box (in detail view) shows file type as CPG File.
If i open cpg file with notepad and allow notepad to open the "CPG"
file type everytime, Windows explorer still shows File Type "CPG
File".
But the detail view in File open dialog box does not show any file type.
Can i make File open dialog to show the same settings as Windows
Explorer.
following is my code
CHAR filter[] = "Display File (*.cpg)\0*.cpg\0All Files
(*.*)\0*.*\0\0";
OPENFILENAME openName;
memset(&openName, 0, sizeof(openName));
openName.lStructSize = sizeof(OPENFILENAME);
openName.hwndOwner = m_hWnd;
openName.hInstance = NULL;
openName.lpstrFilter = filter;
openName.lpstrCustomFilter = (LPSTR) NULL;
openName.nMaxCustFilter = 0L;
openName.nFilterIndex = 1L;
openName.lpstrFile = szFile;
openName.nMaxFile = sizeof(szFile);
openName.lpstrFileTitle = NULL;
openName.nMaxFileTitle = 0;
openName.lpstrInitialDir = "D:\\";
openName.nFileOffset = 0;
openName.nFileExtension = 0;
openName.lpstrDefExt = ".cpg";
openName.lCustData = 0;
openName.lpfnHook = NULL;
openName.lpTemplateName = NULL;
openName.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |
OFN_NONETWORKBUTTON|
OFN_FILEMUSTEXIST|OFN_SHAREAWARE|OFN_PATHMUSTEXIST|OFN_EXPLORER;
openName.lpstrTitle = "Title";
openName.nMaxFileTitle = 6;
GetOpenFileName(&openName);
pls help.
Thanks in advance
Max
7. Dialog opening problem and drawing
8. Modeless Dialog from MFC Regular DLL opened from EXE problems
Hi,
Resources for the MFC modeless dialog are in a Regular DLL with MFC
statically linked, No message overrides are set with the dialog, it is a
generic dialog with only the OK and Cancel buttons. I choose a MFC
AppWizard(exe) Dialog based for the calling EXE and used Run-Time Dynamic
Linking to the DLL. Tried a couple I different approaches base on what I
found on the newsgroup and the usual help sites. I know that I need to keep
the modeless dialog from going out of scope after it is created so this is
what I tried two different methods so far but I still can't get the dialog
to hang around.
1. DllTrace approach using the PreTranslateMessage override
2. Return a CWnd from the exported function that creates the dialog.
============================================================================
======
1. using DllTrace approach
===DLL code===
#define DLLEXPORT __declspec( dllexport )
MyModelessDialogClass *MyDialog;
extern "C"
{
DLLEXPORT int OpenMyDialog (void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
AfxMessageBox ( "Where's my dialog?");
MyDialog = new MyModelessDialogClass;
MyDialog->Create (IDD_DIALOG1, NULL);
MyDialog->ShowWindow (SW_SHOWNORMAL);
AfxMessageBox ( "Did you see it?");
return 0;
}
DLLEXPORT BOOL FAR PASCAL FilterDllMsg(LPMSG lpMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
TRY
{
return AfxGetApp()->PreTranslateMessage(lpMsg);
}
END_TRY
return FALSE;
}
}
===EXE code===
typedef int (*MyDlgPROC)(void);
typedef BOOL (*DllMsgPROC)(LPMSG lpMsg);
MyDlgPROC openMyDialog;
DllMsgPROC filterDllMsg;
BOOL CMyMFCsExeApp::InitInstance()
{
HINSTANCE hinstLib;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("MyModelessDialog.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
openMyDialog = (MyDlgPROC) GetProcAddress(hinstLib, "OpenMyDialog");
filterDllMsg = (DllMsgPROC) GetProcAddress(hinstLib, "FilterDllMsg");
// If the function address is valid, call the function.
if (NULL != openMyDialog)
{
fRunTimeLinkSuccess = TRUE;
(openMyDialog) ( );
}
else
{
MessageBox ( NULL, "openMyDialog Function Not Loaded",
"MyMFCsExeApp Info", MB_ICONINFORMATION );
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
else
{
MessageBox ( NULL, "MyModelessDialog.dll NOT Loaded", "MyMFCsExeApp
Info", MB_ICONINFORMATION );
}
return FALSE;
}
BOOL CMyMFCsExeApp::PreTranslateMessage(MSG* pMsg)
{
if (CWinApp::PreTranslateMessage(pMsg))
return TRUE;
return ((filterDllMsg) (pMsg));
}
============================================================================
======
2. using CWnd as return
===DLL code===
#define DLLEXPORT __declspec( dllexport )
MyModelessDialogClass *MyDialog;
extern "C"
{
DLLEXPORT CWnd* OpenMyDialog (CWnd *parent)
{
AfxMessageBox ( "Where's my dialog?");
CWnd *dlg = new MyModelessDialogClass;
if ( !dlg->Create(NULL,"MyMFCsExeDialog", WS_CHILD | WS_VISIBLE,
CRect(0, 0, 20, 20), parent, IDD_DIALOG1)
return NULL;
return dlg;
}
}
===EXE code===
typedef CWnd* (*MyDlgPROC)(CWnd *parent);
MyDlgPROC openMyDialog;
CWnd *MyDlg = NULL;
BOOL CMyMFCsExeApp::InitInstance()
{
HINSTANCE hinstLib;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("MyModelessDialog.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
openMyDialog = (MyDlgPROC) GetProcAddress(hinstLib, "OpenMyDialog");
// If the function address is valid, call the function.
if (NULL != openMyDialog)
{
fRunTimeLinkSuccess = TRUE;
MyDlg = (openMyDialog) (AfxGetMainWnd());
if (NULL != MyDlg)
MyDlg->ShowWindow(SW_SHOW);
AfxMessageBox ( "Did you see it?");
}
else
{
MessageBox ( NULL, "OpenMyDialog Function Not Loaded",
"MyMFCsExeApp Info", MB_ICONINFORMATION );
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
else
{
MessageBox ( NULL, "MyModelessDialog.dll NOT Loaded", "MyMFCsExeApp
Info", MB_ICONINFORMATION );
}
return FALSE;
}
TIA for any help
Todd