Click here to Skip to main content
15,886,799 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwhich one would be better? Pin
bestbear11-Jul-17 1:18
bestbear11-Jul-17 1:18 
Questionquestions plz solve throught c or c++ Pin
Member 1330375110-Jul-17 22:51
Member 1330375110-Jul-17 22:51 
AnswerRe: questions plz solve throught c or c++ Pin
CodeWraith10-Jul-17 23:21
CodeWraith10-Jul-17 23:21 
AnswerRe: questions plz solve throught c or c++ Pin
Richard MacCutchan11-Jul-17 0:21
mveRichard MacCutchan11-Jul-17 0:21 
AnswerRe: questions plz solve throught c or c++ Pin
Patrice T16-Jul-17 17:34
mvePatrice T16-Jul-17 17:34 
QuestionHow to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici10-Jul-17 8:07
lolici10-Jul-17 8:07 
AnswerRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Richard MacCutchan10-Jul-17 21:28
mveRichard MacCutchan10-Jul-17 21:28 
AnswerRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt10-Jul-17 21:38
professionalJochen Arndt10-Jul-17 21:38 
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:
C++
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:
C++
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());
    // 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.
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici11-Jul-17 8:33
lolici11-Jul-17 8:33 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt11-Jul-17 9:08
professionalJochen Arndt11-Jul-17 9:08 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici11-Jul-17 9:18
lolici11-Jul-17 9:18 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici15-Jul-17 3:53
lolici15-Jul-17 3:53 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt15-Jul-17 22:00
professionalJochen Arndt15-Jul-17 22:00 
QuestionProblem in precedence of operators. Pin
parkavikkk7-Jul-17 21:25
parkavikkk7-Jul-17 21:25 
AnswerRe: Problem in precedence of operators. Pin
Richard MacCutchan7-Jul-17 22:02
mveRichard MacCutchan7-Jul-17 22:02 
GeneralRe: Problem in precedence of operators. Pin
parkavikkk7-Jul-17 22:30
parkavikkk7-Jul-17 22:30 
AnswerRe: Problem in precedence of operators. Pin
Jochen Arndt7-Jul-17 22:15
professionalJochen Arndt7-Jul-17 22:15 
AnswerRe: Problem in precedence of operators. Pin
Victor Nijegorodov8-Jul-17 11:13
Victor Nijegorodov8-Jul-17 11:13 
GeneralRe: Problem in precedence of operators. Pin
jschell10-Jul-17 4:33
jschell10-Jul-17 4:33 
Questionwhat is pla.h ? Pin
Flaze077-Jul-17 6:45
Flaze077-Jul-17 6:45 
AnswerRe: what is pla.h ? Pin
jeron17-Jul-17 7:20
jeron17-Jul-17 7:20 
AnswerRe: what is pla.h ? Pin
David Crow7-Jul-17 7:25
David Crow7-Jul-17 7:25 
GeneralRe: what is pla.h ? Pin
Flaze078-Jul-17 16:16
Flaze078-Jul-17 16:16 
Question(latest VS2017) Using the C++ Core Check (code analysis) trigger warning on corrected code. Pin
Maximilien6-Jul-17 5:56
Maximilien6-Jul-17 5:56 
AnswerRe: (latest VS2017) Using the C++ Core Check (code analysis) trigger warning on corrected code. Pin
Michael_Davies6-Jul-17 7:33
Michael_Davies6-Jul-17 7:33 

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.