Re: using Document object from CFrameWnd
(a) where in your code are you doing this?
*******************************
I am doing this in a class derived from CFrameWnd in OnLButtonDown()
which is used as a view in one of the split window.
********************************
(b) what value do you get for pDOC or pFrame? NULL? 0xDFDFDFDF? 0xFEEEFEEE?
***************************************************
pDoc=0x00000000
pFrame=0x00ce6148
***************************************************
(c) where are you getting your access violation?
**************************************
debugger points to pDoc->store=0; or whenever I try to access any member(in
same OnLButtonDown())
(d) what is the call stack back to your code?
********************************* -->App.exe!CAbView::OnLButtonDown(unsigned int flag=1, CPoint point={...}) Line 202 + 0x9 bytes C++
App.exe!CWnd::OnWndMsg(unsigned int message=513, unsigned int wParam=1,
long lParam=13697493, long * pResult=0x0012fcbc) Line 2169 C++
App.exe!CWnd::WindowProc(unsigned int message=513, unsigned int wParam=1,
long lParam=13697493) Line 1741 + 0x20 bytes C++
App.exe!AfxCallWndProc(CWnd * pWnd=0x00ce6e08, HWND__ * hWnd=0x0004094c,
unsigned int nMsg=513, unsigned int wParam=1, long lParam=13697493) Line
240 + 0x1c bytes C++
App.exe!AfxWndProc(HWND__ * hWnd=0x0004094c, unsigned int nMsg=513,
unsigned int wParam=1, long lParam=13697493) Line 389 C++
user32.dll!77d48709()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!77d487eb()
user32.dll!77d70494()
user32.dll!77d489a5()
user32.dll!77d70494()
user32.dll!77d4bccc()
App.exe!AfxInternalPumpMessage() Line 183 C++
App.exe!CWinThread::PumpMessage() Line 896 C++
App.exe!CWinThread::Run() Line 625 + 0xd bytes C++
App.exe!CWinApp::Run() Line 894 C++
App.exe!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, char * lpCmdLine=0x00151f41, int nCmdShow=1) Line
47 + 0xd bytes C++
App.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, char * lpCmdLine=0x00151f41, int nCmdShow=1) Line
33
C++
App.exe!__tmainCRTStartup() Line 324 + 0x35 bytes C
App.exe!WinMainCRTStartup() Line 196 C
kernel32.dll!7c816d4f()
kernel32.dll!7c8399f3()
App.exe!COleServerDoc::XOleObject::SetHostNames(const wchar_t *
lpszContainerApp=0x00380078, const wchar_t * lpszContainerObj=0x00220036)
Line
2068 + 0x2d bytes C++
*****************************************************
Without knowing (a) and (b) there is no good way to answer the question. (c) and (d) help
isolate what is going on.
joe
On Fri, 23 Jan 2009 21:36:01 -0800, nexolite <nexolite@discussions.microsoft.com> wrote:
But NONE is working,
wether I do:
1> CMyDoc* pDoc=(CMyDoc*) GetActiveDocument();
OR..
2> CFramewnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
CMyDoc* pDoc=(CMyDoc*) pFrame->GetActiveDocument();
OR...
3>CMyFrame* pFrame=(CMyFrame*)AfxGetMainWnd();
CMyDoc* pDoc=(CMyDoc*) pFrame->GetActiveDocument();
while using any of these I am getting Access Violation.
what I should do?
"Giovanni Dicanio" wrote:
"David Wilkinson" <no-reply@effisols.com> ha scritto nel messaggio
news:eLr2%23KXfJHA.5496@TK2MSFTNGP02.phx.gbl...
If the CFrameWnd is just "used as a view", will it be hooked up correctly
to MFC so that GetActiveDocument() will work? I wouldn't think so.
I would have thought you would need to do something like
CFrameWnd* pFrame = (CFrameWnd*)AfxGetMainWnd();
CMyDocument* pDoc = (CMyDocument*)pFrame->GetActiveDocument();
or maybe better pass a CMyDocument* pointer to the new CFrameWnd and store
it in a member variable,
David: I did not try that with a real test with the C++ compiler, so I trust
much more what you think considering your experience, that what I suppose
without a real test.
Thanks,
Giovanni
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm