|
I think I've solved the issue by using the code suggested in the Visual Studio help, and what Roger has said is right.
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->GetMainWnd();
CMDIChildWnd *pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();
CUCPView *pView = (CUCPView*)pChild->GetActiveView();
then,
pView->UpdateOutputs();
but I had all these strange issues when I tried to add in the first set of code to different parts of the program, saying can't find GetActiveFrame and GetActiveView, even tho I could right click and go to definition. So I added that code all within the same function as where "pView->UpdateOutputs();" was located. Also I couldn't add a declaration "CUCPView *pView" to the SetOutputDlg.h file because when I tried to #include "CUCPView.h" it would come up with lots of errors.
doesn't sound very neat, but works. I came from java and now learning C++ and pointers and such are still giving me troubles.
|
|
|
|
|
Some things to consider in your chosen solution...
You're using a lot of ...GetActive... which suggests that there may be more than one, don't you think? Then you're type casting the returned pointer into a type you assume it is, but it may in fact be something else if you have more than one view.
Your code will probably work, but it is based on a lot of assumptions that you need to be aware of.
soongez wrote: when I tried to #include "CUCPView.h" it would come up with lots of errors.
What kind of errors? When building which file?
You should be able to include the header file, but depending on your errors you may need to include "stdafx.h" at the top of your SetOutputDlg.cpp file if that's not done already.
This would be the "right" way to do it.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
The code with GetActive was just copied from the Visual studio help... I am working on understanding it all and making it more "right"
when I include UCPView.h the errors start with,
1>Compiling...
1>UCPView.cpp
1>c:\users\soong\desktop\project\project program\ucp\UCPView.h(48) : error C2143: syntax error : missing ';' before '*'
that line reads,
CSetOutputDlg *dlg;
so the error is in the include, because it doesn't appear when I don't include it.
|
|
|
|
|
Hi,
May i know the difference b/w ondraw() and onpaint()....
|
|
|
|
|
You mean other than what the documentation provides?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
A warm welcome, David [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
One difference is that OnDraw () works with views, and OnPaint () works with dialog boxes. There's no good reason for this; just unnecessary Microsoft complexity.
|
|
|
|
|
Hi,
I am a c# programmer. I got an application in c++, i need to integrate that to my application in c#.net. I dont know c++ programing, not even to run.
How can i use the c++ application in c#?
Thankyou
YPKI
|
|
|
|
|
Are you wanting to convert your C++ code to C#, or are you wanting to run an application from within C#?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
For the latter, try ShellExecute() or CreateProcess() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Is there any difference between
auto_ptr<<foo>> p;
...
p = auto_ptr<<foo>>(new foo);
and
auto_ptr<<foo>> p;
...
p = new foo;
I saw the first form in examples and wondered why it was being used.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: p = new foo;
are you sure. that you'd able to do this? I think compiler will throw error.
You've to be careful about auto_ptrs unusual characteristic. Copying them them to null, and the copying pointer assumes sole ownership of the resource
See the example demonstrate this issue from Effective C++ 3rd Ed.
std::auto_ptr<Investment>
pInv1(createInvestment());
std::auto_ptr<Investment> pInv2(pInv1);
pInv1 = pInv2;
// object, and pInv2 is null
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Thanks for the reply.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
Can u pls suggest me any book to start with for MFC in VS2003 and even im new to vc++..
|
|
|
|
|
Hi,
Programming Windows with MFC[^] is a great book, written by Jeff Prosise.
Legend says that one starts with Programming Windows with C++ and work your way up through frameworks and libraries. If you'd like to pursue that path, you could start with Programming Windows[^] by Charles Petzold.
Of course, you would be expected to be able to do C/C++ programming well before you touch any of these.
Happy learning.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I learnt from an earlier version of this one[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The name (Programming with Microsoft Visual C++ .NET) of this version looks like it would explain managed stuff too.
I'm not against managed code, but I don't like the idea of mixing up managed code with good old native C++. It's like eating garlic with ice cream.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Good one!
Welcome again int CP's Memorable Quotes list [^] (what a day! Yours is the second entry, so far...).
BTW:Rajesh R Subramanian wrote: Of course, you would be expected to be able to do C/C++ programming well before you touch any of these.
is a great one too...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I ain't sure if I can keep up to the heat.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
That was actually the name of the product - remember it used to be Visual Studio .NET rather than just plain Visual Studio? 5 out of the 35 chapters cover .NET - the rest are plain Visual C++ and MFC (I know because it's on Safari & I can see it ).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yes, that was very much what I was talking about. They can please publish another book to explain all the C++/CLI stuff instead of dedicating 5 chapters to show how .NET "fits in". But I see this is happening with a lot of books these days.
I can't wait for X86 .NET.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
How do give ( pass, transmit) value of variable
m_sPP_modal
From class modal window “CAdodc_MDI”
To variable
m_sPP_modeless
of modeless class “CMyModeless2”
and on the contrary - from class “CMyModeless2”
to class modal window “CAdodc_MDI ?
below 2 lines isn’t correctly into button ‘OK’ of modal window:
CMyModeless2 dlg2;
dlg2.m_sPP_modeless = L“text”;
below brief:
/////////////////////////////////////////
// Adodc_MDI.cpp : implementation file
#include "stdafx.h"
#include "ADO_MDI.h"
#include "Adodc_MDI.h"
#include "MyModeless2.h"
class CAdodc_MDI : public CDialog
{
CString m_sPP_modal = _T("text in Modal window");
}
//////////////////////////////////////
MyModeless2.cpp : implementation file
#define WM_GOODBYE WM_USER + 100
class CMyModeless2 : public CDialog
{
CString m_sPP_modeless = _T("text in Modeless window");
}
//////////////////////////////////////
// ADO_MDIView.cpp : implementation of the CADO_MDIView class
//
#include "stdafx.h"
#include "ADO_MDI.h"
#include "ADO_MDIDoc.h"
#include "CntrItem.h"
#include "ADO_MDIView.h"
#include "MyModeless2.h"
#include "Adodc_MDI.h"
LRESULT CADO_MDIView::OnGoodbye(WPARAM wParam, LPARAM lParam)
{ }
void CADO_MDIView::OnLButtonDown(UINT nFlags, CPoint point)
{ }
void CADO_MDIView::OnRButtonDown(UINT nFlags, CPoint point)
{ }
///////////////////////////////////////////////
///////////////////////////////////////////////
Below MORE DETAIL:
"MyModeless2.h"
#pragma once
#include "afxwin.h"
// CMyModeless2 dialog
#define WM_GOODBYE WM_USER + 100
class CMyModeless2 : public CDialog
{
DECLARE_DYNAMIC(CMyModeless2)
public:
CMyModeless2(CWnd* pParent = NULL); // standard constructor
virtual ~CMyModeless2();
// Dialog Data
enum { IDD = IDD_DIALOG4 };
CString m_sPP_modeless;
CView* m_pView;
CMyModeless2(CView* pView);
afx_msg void OnBnClickedButton3();
BOOL Create(void);
protected:
virtual void OnOK();
virtual void OnCancel();
public:
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
};
/////////////////////////////////////
MyModeless2.cpp
#include "stdafx.h"
#include "ADO_MDI.h"
#include "MyModeless2.h"
// CMyModeless2 dialog
IMPLEMENT_DYNAMIC(CMyModeless2, CDialog)
CMyModeless2::CMyModeless2(CWnd* pParent /*=NULL*/)
: CDialog(CMyModeless2::IDD, pParent)
, m_sPP_modeless(_T(""))
void CMyModeless2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT3, m_sPP_modeless);
}
BEGIN_MESSAGE_MAP(CMyModeless2, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &CMyModeless2::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CMyModeless2::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &CMyModeless2::OnBnClickedButton3)
ON_BN_CLICKED(IDOK, &CMyModeless2::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CMyModeless2::OnBnClickedCancel)
END_MESSAGE_MAP()
CMyModeless2::CMyModeless2(CView* pView)
{
m_pView = pView;
}
BOOL CMyModeless2::Create(void)
{
return CDialog::Create(CMyModeless2::IDD);
}
void CMyModeless2::OnOK()
{
if (m_pView != NULL) {
m_pView->PostMessage(WM_GOODBYE, IDOK);
}
else {
CDialog::OnOK(); // modal case
}
CDialog::OnOK();
}
void CMyModeless2::OnCancel()
{
if (m_pView != NULL) {
// modeless case -- do not call base class OnCancel
m_pView->PostMessage(WM_GOODBYE, IDCANCEL);
}
else {
CDialog::OnCancel(); // modal case
}
}
void CMyModeless2::OnBnClickedOk()
{
OnOK();
}
void CMyModeless2::OnBnClickedCancel()
{
OnCancel();
}
///////////////////////////////////////////
ADO_MDIView.h
// ADO_MDIView.h : interface of the CADO_MDIView class
#pragma once
class CMyModeless2;
class CADO_MDIView : public CScrollView
{
protected: // create from serialization only
CADO_MDIView();
DECLARE_DYNCREATE(CADO_MDIView)
// Attributes
public:
CADO_MDIDoc* GetDocument() const;
// Overrides
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
// Implementation
public:
virtual ~CADO_MDIView();
protected:
// Generated message map functions
protected:
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP()
public:
CMyModeless2* m_pModeless;
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam);
};
//////////////////////////////////////////////
// ADO_MDIView.cpp : implementation of the CADO_MDIView class
#include "stdafx.h"
#include "ADO_MDI.h"
#include "ADO_MDIDoc.h"
#include "CntrItem.h"
#include "ADO_MDIView.h"
#include "MyModeless2.h"
#include "Adodc_MDI.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CADO_MDIView
IMPLEMENT_DYNCREATE(CADO_MDIView, CScrollView)
BEGIN_MESSAGE_MAP(CADO_MDIView, CScrollView)
ON_MESSAGE(WM_GOODBYE, OnGoodbye)
ON_WM_DESTROY()
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()
// CADO_MDIView construction/destruction
CADO_MDIView::CADO_MDIView()
: m_pModeless(NULL)
, m_sReceivingFromModeless1(_T(""))
{
m_pModeless = new CMyModeless2(this);
}
CADO_MDIView::~CADO_MDIView()
{
delete m_pModeless;
}
void CADO_MDIView::OnDestroy()
{
// Deactivate the item on destruction; this is important
// when a splitter view is being used
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
{
pActiveItem->Deactivate();
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
CScrollView::OnDestroy();
}
void CADO_MDIView::OnLButtonDown(UINT nFlags, CPoint point)
{
if (m_pModeless->GetSafeHwnd() == 0)
{
m_pModeless->Create();
}
}
void CADO_MDIView::OnRButtonDown(UINT nFlags, CPoint point)
{
m_pModeless ->DestroyWindow();
}
LRESULT CADO_MDIView::OnGoodbye(WPARAM wParam, LPARAM lParam)
{
m_pModeless->m_sPP_modeless;
m_pModeless->DestroyWindow();
return 0L;
}
/////////////////////////////////////////////
Adodc_MDI.h
#pragma once
#include "afxcmn.h"
class CAdodc_MDI : public CDialog
{
DECLARE_DYNAMIC(CAdodc_MDI)
public:
CAdodc_MDI(CWnd* pParent = NULL); // standard constructor
virtual ~CAdodc_MDI();
enum { IDD = IDD_ADODC };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
CListCtrl* m_pListCtrl;
_ConnectionPtr m_pConn2;
CString m_sPP;
afx_msg void OnHdnItemclickList1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedOk();
int col;
int row;
private:
};
////////////////////////////////////////
|
|
|
|
|
Please read the posting guidelines. I don't think anybody will want to read all your source code.
As far as I understood, you want to pass a variable from one dialog to another one. Is that correct ? If yes, then take a look at this article[^]
|
|
|
|
|
See, for instance, this article [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|