Hello! I'm trying to browse a text file using CMFCEditBrowseCtrl (it is used in CFirstDialog Class) and use this file in another Dialog Class (named CSecondDialog Class). My problem is on how to save the filename retrieved from the CMFCEditBrowseCtrl when the CFirstDialog::OnEnChangeMfceditbrowse1() goes out of scope and then pass the filename to the CSecondDialog. Here is the code:
CStdioFile fileSource("here I need to put the filename retrieved from the previous dialog class", CFile::modeRead);
int num = 1;
The OnEnChangeMfceditbrowse1 method should store the file name in one of its object variables (or str) should be an object variable. The calling code can then capture that variable when the dialog returns.
You can now get and set the name from the class that holds the pointers to the dialogs. If both dialogs might not exist at the same time you have to store the file name in a member variable of that class (e.g. get the name when DoModal() returns).
Finally you need access to the upper class from CSecondDialog. If the upper class is the parent window, always of the same type, and has been passed as parent, you can use casting:
CParentOfDialogs *pParent = static_cast<CParentOfDialogs*>(GetParent());
// Use pParent here to get the stored name or retrieve it from the first dialog
CString strFileName = pParent->m_pFirstDialog->GetFileName();
Otherwise you have to use a member variable in your second dialog that holds a pointer to the upper class and is initalised upon dialog creation or using a set function.
There are also other solutions and variations of the above.
If both dialogs might not exist at the same time you have to store the file name in a member variable of that class (e.g. get the name when DoModal() returns).
The two dialogs do not exist at the same time, actually CSecondDialog gets on screen after I finish with CFirstDialog which goes out of scope. Could you explain me how to get the file name after DoModal() returns? Thank you in advance!
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CSecondDialog *pDlg = new CSecondDialog(this);
// TODO: Add your command handler code here
CMyDoc* pDoc = GetDocument();
Add a member variable to the first dialog (as already described) and to the parent window. Then get the file name from the dialog after calling:
// Get file name here before DialogWindow goes out of scope
m_strFileName = DialogWindow.GetFileName();
// Or (when DialogWindow.m_strFileName is public): //m_strFileName = DialogWindow.m_strFileName
If you create the second dialog from another class (not CInputView), you have to pass the name to the other class in a similar way.
Then set the file name before calling DoModal() of the second dialog:
// Pass file name before calling DoModal()
Could you please explain me how to store pointers to the dialogs when they are created so that I can get and set the name from the class that holds the pointers to the dialogs? I'm sorry for asking again but I got a little confused with this part.
What number will z in the sample code given below?
int z, x=5, y= -10, a=4, b=2;
z=x++ - --y *b/a;
Can anyone please solve it and explain the precedence. i am not getting right answer. my answer is 2.5. but it is wrong. i am struggling in it. kindly solve it and explain. Thanks in advance.
The first step is inserting parentheses according to the predence and order:
z = (x++) - (((--y) * b) / a);
Then replace the variables with their values:
z = (5++) - (((--(-10)) * 2) / 4);
Now solve step by step but observe the special handling of the postfix operator which will return a temporary copy that contains the value before the operation (that means x will be changed but the initial value of 5 is used for the calculation). Observe also that results might get rounded wirh integer arithmetic:
z = (5) - ((-11 * 2) / 4);
z = 5 - (-22 / 4);
// The remaining steps are left to your exercise
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
I have a C++ application which reads access (.mdb) file. This application runs fine on Windows XP,7 OS. But when I run the application on Embedded Standard OS, it gives me System Error 126 (Microsoft Access Driver).
What would be the best solution for this?
Kindly help in solving this problem.
Thanks In advance
Last Visit: 31-Dec-99 19:00 Last Update: 6-Feb-23 10:32