Need help with pointer in View
-
hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages
class CTestView : public CFormView
and i have a different class and object some where else and i want to point to this class where i double click my control and load my imagesCTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();
I new at this MFC Visual C++ program can any one please help me thanks........... -
hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages
class CTestView : public CFormView
and i have a different class and object some where else and i want to point to this class where i double click my control and load my imagesCTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();
I new at this MFC Visual C++ program can any one please help me thanks...........I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
I think it's AfxGetMainWnd()->GetActiveView(). you only need to cast to CTestView*. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd(); pMain->GetActiveView(); Sorry, I abandoned MFC a long time ago. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
CMainFrame * pMain = (CMainFrame*) AfxGetMainWnd(); pMain->GetActiveView(); Sorry, I abandoned MFC a long time ago. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
It's ok thanks for trying :) in my program the is no GetActiveView() i keep getting an error. maybe i'm putting this in the wrong way this is what i have CTestView * pView= (CTestView*)AfxGetMainWnd(); and lets say i want to call and function or an object like this pView->m_cThumbFrame.Add("picture.bmp"); but this dosen't work :(:((:((:((
-
It's ok thanks for trying :) in my program the is no GetActiveView() i keep getting an error. maybe i'm putting this in the wrong way this is what i have CTestView * pView= (CTestView*)AfxGetMainWnd(); and lets say i want to call and function or an object like this pView->m_cThumbFrame.Add("picture.bmp"); but this dosen't work :(:((:((:((
E3 wrote: in my program the is no GetActiveView() i keep getting an error. After the cast ? Compiles fine here. E3 wrote: CTestView * pView= (CTestView*)AfxGetMainWnd(); Won't work. You'll get the CMainFrame class, which when cast has a GetActiveView() method. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages
class CTestView : public CFormView
and i have a different class and object some where else and i want to point to this class where i double click my control and load my imagesCTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();
I new at this MFC Visual C++ program can any one please help me thanks...........It would be better to store the view-pointer for each view in a own variable to ensure you getting the right view pointer. If not you are to crush and not to know why.:~ (If you do´t do this than check with the CObject::IsKindOf or something that the pointer is a object type of the class) Try this @ home. (B&B)
-
hello everybody I need some help with declering an pointer to my clss my class of CFromView in there i have a function class LoadImages
class CTestView : public CFormView
and i have a different class and object some where else and i want to point to this class where i double click my control and load my imagesCTestView *pView = (CTestView *)((CFormView *)AfxGetApp()->m_pMainWnd)->GetActiveWindow();
I new at this MFC Visual C++ program can any one please help me thanks...........I find it easier to store a pointer to the CView derived class in my CWinApp derived class. This guarantees that I'm working on the correct view. Assuming you are calling your function from your CFrameWnd derived class, you may be able to use GetActiveView and cast it to the CTestView. I prefer the first method but then I tend to have a lot of CView classes in my projects. Michael Fat bottomed girls You make the rockin' world go round -- Queen
-
I find it easier to store a pointer to the CView derived class in my CWinApp derived class. This guarantees that I'm working on the correct view. Assuming you are calling your function from your CFrameWnd derived class, you may be able to use GetActiveView and cast it to the CTestView. I prefer the first method but then I tend to have a lot of CView classes in my projects. Michael Fat bottomed girls You make the rockin' world go round -- Queen
thank you all for helping me... I finaly got the some of a b.... to work hehehe here is what i did to get it working for all those people who mite get stuck on this and are new like me.
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd(); CTestView *p = (CTestView *)pFrame->GetActiveView(); p->LoadImages(str);
and this get the current CFormView window and everything works..... thanks all guys....for all your help ;);):):):):) E3