|
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.
|
|
|
|
|
It depends on how your dialog classes can be accessed and if they both exist at the same time.
A possible solution:
You need to store pointers to your dialogs when they are created (usually in the parent window).
Store the file name in a member variable of CFirstDialog and provide a public function to get the name:
CFirstDialog
{
public:
const CString& GetFileName() const { return m_strFileName; }
protected:
CString m_strFileName;
};
void CFirstDialog::OnEnChangeMfceditbrowse1()
{
m_browser.GetWindowText(m_strFileName);
} Similar for CSecondDialog but there with a set function:
CSecondDialog
{
public:
void SetFileName(const CString& strFileName) { m_strFileName = strFileName; }
protected:
CString m_strFileName;
};
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:
void CSecondDialog::OnBnClickedOk()
{
CParentOfDialogs *pParent = static_cast<CParentOfDialogs*>(GetParent());
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.
|
|
|
|
|
Is m_pFirstDialog a new variable?
Jochen Arndt wrote: 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!
void CInputView::OnFirstDlg()
{
CInputDoc* pDoc = GetDocument();
CFirstDialog DialogWindow;
CSecondDialog *pDlg = new CSecondDialog(this);
pDlg->DoModal();
delete pDlg;
}
void CMyView::OnSecondDlg()
{
CMyDoc* pDoc = GetDocument();
CSecondDialog DialogWindow;
DialogWindow.DoModal();
}
|
|
|
|
|
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:
void CInputView::OnFirstDlg()
{
CFirstDialog DialogWindow;
DialogWindow.DoModal();
m_strFileName = DialogWindow.GetFileName();
}
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:
CSecondDialog DialogWindow;
DialogWindow.SetFileName(m_strFileName);
DialogWindow.DoModal();
|
|
|
|
|
I create the second dialog from the CInputView (the same class). I wrote it wrong above. Thank you very much for your help!I'm grateful!
|
|
|
|
|
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.
|
|
|
|
|
Such is only useful with modeless dialogs. Modal dialogs will block so that there is usually no need to have a pointer.
However:
if (NULL == m_pSomeDlg)
{
m_pSomeDlg = new CSomeDialog(this);
} When doing so m_pSomeDlg must be initialised with NULL in the constructor and deleted in the destructor.
|
|
|
|
|
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.
|
|
|
|
|
|
thank you. i am clear now
|
|
|
|
|
See C++ Operator Precedence - cppreference.com[^].
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);
|
|
|
|
|
parkavikkk wrote: 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.
Of course it is wrong! Just because the integer number cannot be 2.5, nor 2.7, nor 2.8...
|
|
|
|
|
Maybe the OP was manually calculating it?
|
|
|
|
|
hi, I recently come accross pla.h
what's the purpose of it ?
|
|
|
|
|
I guessing it has to do with declarations associated with Windows performance logs and alerts [^].
"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
|
|
|
|
|
It's a header file. Open it up to reveal its contents. If things are named appropriately and/or it's commented well, you should be able to ascertain its purpose.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I checked it before I ask this question....
anyways thank you for the answer...
I already got the answer from stackoverflow but my question got block...
so I wonder how this forum will react
|
|
|
|
|
(not really urgent)
I decided to try out the C++ Core Check code analysis on a sample project to see if it will be useful for our project.
One one line it says that I need to put a const , so I put the const , and re-run the analysis.
The line still will trigger the warning.
Any way to reset the warnings so that it won't retrigger the same warnings ?
Any experience with that ?
Thanks
I'd rather be phishing!
|
|
|
|
|
If you right-click the warning do you get a menu with Suppress on it?
|
|
|
|
|
I don't want to suppress the warning, just to not report it on lines that it should not appears (after fixing the warning).
Anyway, it is only a minor annoyance, will keep testing/using it .
Thanks.
I'd rather be phishing!
|
|
|
|
|
As I say, if you right-click the warning you can suppress it for that line, not suppress the warning for every line.
|
|
|
|
|
Yes but he's saying that he did what the warning wanted and the warning keeps coming up anyway on that line.
He's asking for a way to make it work right.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
"Any way to reset the warnings so that it won't retrigger the same warnings ?"
|
|
|
|
|
Hi All,
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
|
|
|
|
|
That usually indicates a missing or mis-configured driver. You need to check that the Access driver is correctly installed.
|
|
|
|