Discussion:
GetParent() from a modal dialog in a MFC SDI application
(too old to reply)
Anders Eriksson
2007-06-12 11:00:16 UTC
Permalink
Hello,

I have a MFC SDI CFormView application and in the View I create a dialog
that I DoModal(); The dialog is created using the Resource Editor, not
dynamically.

In the OnInitDialog() I use this code to get a pointer to the View that is
calling the dialog
CMarkerView *pView = (CMarkerView*)GetParent();

I then use this to change a member variable in the view
pView->m_currMagazine = nMagazine;

Somehow this is wrong! using this code will make me crash in
CPlex::FreeDataChain(), See Call Stack below.

What is wrong and how to I get a pointer to the View?

// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
mfc80ud.dll!CPlex::FreeDataChain() Line 42 + 0x3 bytes C++
mfc80ud.dll!CPtrList::RemoveAll() Line 48 C++
mfc80ud.dll!CPtrList::FreeNode(CPtrList::CNode * pNode=0x003bcad0) Line
123 C++
mfc80ud.dll!CPtrList::RemoveAt(__POSITION * position=0x003bcad0) Line
324 C++
mfc80ud.dll!CFrameWnd::RemoveControlBar(CControlBar * pBar=0x01001304)
Line 875 C++
mfc80ud.dll!CControlBar::OnDestroy() Line 586 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012e9f4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!CControlBar::WindowProc(unsigned int nMsg=2, unsigned int
wParam=0, long lParam=0) Line 504 + 0x14 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001304, HWND__ *
hWnd=0x00011302, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CControlBar::DestroyWindow() Line 598 C++
mfc80ud.dll!CFrameWnd::DestroyDockBars() Line 1618 C++
mfc80ud.dll!CFrameWnd::OnDestroy() Line 852 C++
Marker.exe!CMainFrame::OnDestroy() Line 126 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012eec4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CDocument::OnCloseDocument() Line 744 C++
mfc80ud.dll!CDocTemplate::CloseAllDocuments(int __formal=0) Line 355 C++
mfc80ud.dll!CDocManager::CloseAllDocuments(int bEndSession=0) Line 588
C++
mfc80ud.dll!CWinApp::CloseAllDocuments(int bEndSession=0) Line 90 C++
mfc80ud.dll!CFrameWnd::OnClose() Line 798 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=16, unsigned int
wParam=0, long lParam=0, long * pResult=0x0012f2cc) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=16, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=16, unsigned int wParam=0, long
lParam=0) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=16,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=16, unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e4194be()
user32.dll!7e41b42d()
user32.dll!7e4184fc()
user32.dll!7e41ba0e()
user32.dll!7e4184fc()
user32.dll!7e4185a4()
user32.dll!7e41b3f9()
uxtheme.dll!5ad73c20()
uxtheme.dll!5ad8e300()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
uxtheme.dll!5ad8e2d5()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=274, unsigned int
wParam=61536, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::Default() Line 274 C++
mfc80ud.dll!CWnd::OnSysCommand(unsigned int __formal=61536, unsigned int
__formal=61536) Line 460 + 0xf bytes C++
mfc80ud.dll!CFrameWnd::OnSysCommand(unsigned int nID=61536, long
lParam=3408996) Line 1042 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996, long * pResult=0x0012f8cc) Line 2056
C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=274, unsigned int wParam=61536, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=274,
unsigned int wParam=61536, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=274, unsigned int wParam=61536, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b89b()
user32.dll!7e41b903()
uxtheme.dll!5ad9881f()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=161, unsigned int
wParam=20, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=161, unsigned int
wParam=20, long lParam=3408996) Line 1742 + 0x1c bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=161, unsigned int wParam=20, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=161,
unsigned int wParam=20, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=161, unsigned int wParam=20, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
mfc80ud.dll!AfxInternalPumpMessage() Line 183 C++
mfc80ud.dll!CWinThread::PumpMessage() Line 896 C++
mfc80ud.dll!CWinThread::Run() Line 625 + 0xd bytes C++
mfc80ud.dll!CWinApp::Run() Line 889 C++
mfc80ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 47 + 0xd bytes C++
Marker.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 29 C++
Marker.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
Marker.exe!wWinMainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()
Guido Franzke
2007-06-12 11:23:53 UTC
Permalink
This post might be inappropriate. Click to display it.
Anders Eriksson
2007-06-12 13:21:48 UTC
Permalink
Post by Guido Franzke
Well,
I would implement the view pointer in your dialog.
Nice work around ;-)

I did like you suggested and everything is good!

Thank you very much!

// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
Tom Serface
2007-06-12 13:26:04 UTC
Permalink
To add to what Guido wrote (which is the same approach I'd take), I would
likely send messages to the parent to change controls rather than accessing
them directly. You can send messages to the view once you have the pointer
to it. It will likely work either way, I just think that sending messages
and letting the code that owns the window update seems more appropriate.

Tom
Post by Anders Eriksson
Hello,
I have a MFC SDI CFormView application and in the View I create a dialog
that I DoModal(); The dialog is created using the Resource Editor, not
dynamically.
In the OnInitDialog() I use this code to get a pointer to the View that is
calling the dialog
CMarkerView *pView = (CMarkerView*)GetParent();
I then use this to change a member variable in the view
pView->m_currMagazine = nMagazine;
Somehow this is wrong! using this code will make me crash in
CPlex::FreeDataChain(), See Call Stack below.
What is wrong and how to I get a pointer to the View?
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
mfc80ud.dll!CPlex::FreeDataChain() Line 42 + 0x3 bytes C++
mfc80ud.dll!CPtrList::RemoveAll() Line 48 C++
mfc80ud.dll!CPtrList::FreeNode(CPtrList::CNode * pNode=0x003bcad0) Line
123 C++
mfc80ud.dll!CPtrList::RemoveAt(__POSITION * position=0x003bcad0) Line
324 C++
mfc80ud.dll!CFrameWnd::RemoveControlBar(CControlBar * pBar=0x01001304)
Line 875 C++
mfc80ud.dll!CControlBar::OnDestroy() Line 586 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012e9f4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!CControlBar::WindowProc(unsigned int nMsg=2, unsigned int
wParam=0, long lParam=0) Line 504 + 0x14 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001304, HWND__ *
hWnd=0x00011302, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CControlBar::DestroyWindow() Line 598 C++
mfc80ud.dll!CFrameWnd::DestroyDockBars() Line 1618 C++
mfc80ud.dll!CFrameWnd::OnDestroy() Line 852 C++
Marker.exe!CMainFrame::OnDestroy() Line 126 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012eec4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CDocument::OnCloseDocument() Line 744 C++
mfc80ud.dll!CDocTemplate::CloseAllDocuments(int __formal=0) Line 355 C++
mfc80ud.dll!CDocManager::CloseAllDocuments(int bEndSession=0) Line 588
C++
mfc80ud.dll!CWinApp::CloseAllDocuments(int bEndSession=0) Line 90 C++
mfc80ud.dll!CFrameWnd::OnClose() Line 798 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=16, unsigned int
wParam=0, long lParam=0, long * pResult=0x0012f2cc) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=16, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=16, unsigned int wParam=0, long
lParam=0) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=16,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=16, unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e4194be()
user32.dll!7e41b42d()
user32.dll!7e4184fc()
user32.dll!7e41ba0e()
user32.dll!7e4184fc()
user32.dll!7e4185a4()
user32.dll!7e41b3f9()
uxtheme.dll!5ad73c20()
uxtheme.dll!5ad8e300()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
uxtheme.dll!5ad8e2d5()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=274, unsigned int
wParam=61536, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::Default() Line 274 C++
mfc80ud.dll!CWnd::OnSysCommand(unsigned int __formal=61536, unsigned int
__formal=61536) Line 460 + 0xf bytes C++
mfc80ud.dll!CFrameWnd::OnSysCommand(unsigned int nID=61536, long
lParam=3408996) Line 1042 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996, long * pResult=0x0012f8cc) Line 2056
C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=274, unsigned int wParam=61536, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=274,
unsigned int wParam=61536, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=274, unsigned int wParam=61536, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b89b()
user32.dll!7e41b903()
uxtheme.dll!5ad9881f()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=161, unsigned int
wParam=20, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=161, unsigned int
wParam=20, long lParam=3408996) Line 1742 + 0x1c bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=161, unsigned int wParam=20, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=161,
unsigned int wParam=20, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=161, unsigned int wParam=20, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
mfc80ud.dll!AfxInternalPumpMessage() Line 183 C++
mfc80ud.dll!CWinThread::PumpMessage() Line 896 C++
mfc80ud.dll!CWinThread::Run() Line 625 + 0xd bytes C++
mfc80ud.dll!CWinApp::Run() Line 889 C++
mfc80ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 47 + 0xd bytes C++
Marker.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 29 C++
Marker.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
Marker.exe!wWinMainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()
Arman Sahakyan
2007-06-12 13:43:05 UTC
Permalink
see below..
Post by Anders Eriksson
Hello,
I have a MFC SDI CFormView application and in the View I create a dialog
that I DoModal(); The dialog is created using the Resource Editor, not
dynamically.
In the OnInitDialog() I use this code to get a pointer to the View that is
calling the dialog
CMarkerView *pView = (CMarkerView*)GetParent();
I then use this to change a member variable in the view
pView->m_currMagazine = nMagazine;
No. If the dialog weren't modal but modeless, this kind of thing might
survive.
The wrong part is that there is no need to change the view inside a modal
dialog. If you want to, the best thing to do is to let the view get the
variable from dlg and use it [after the modal dlg exits];

CMyDlg dlg;
if (IDOK == dlg.DoModal())
{
m_currMagazine = dlg.nMagazine;
}
Post by Anders Eriksson
Somehow this is wrong! using this code will make me crash in
CPlex::FreeDataChain(), See Call Stack below.
What is wrong and how to I get a pointer to the View?
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
mfc80ud.dll!CPlex::FreeDataChain() Line 42 + 0x3 bytes C++
mfc80ud.dll!CPtrList::RemoveAll() Line 48 C++
mfc80ud.dll!CPtrList::FreeNode(CPtrList::CNode * pNode=0x003bcad0) Line
123 C++
mfc80ud.dll!CPtrList::RemoveAt(__POSITION * position=0x003bcad0) Line
324 C++
mfc80ud.dll!CFrameWnd::RemoveControlBar(CControlBar * pBar=0x01001304)
Line 875 C++
mfc80ud.dll!CControlBar::OnDestroy() Line 586 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012e9f4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!CControlBar::WindowProc(unsigned int nMsg=2, unsigned int
wParam=0, long lParam=0) Line 504 + 0x14 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001304, HWND__ *
hWnd=0x00011302, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CControlBar::DestroyWindow() Line 598 C++
mfc80ud.dll!CFrameWnd::DestroyDockBars() Line 1618 C++
mfc80ud.dll!CFrameWnd::OnDestroy() Line 852 C++
Marker.exe!CMainFrame::OnDestroy() Line 126 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012eec4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CDocument::OnCloseDocument() Line 744 C++
mfc80ud.dll!CDocTemplate::CloseAllDocuments(int __formal=0) Line 355 C++
mfc80ud.dll!CDocManager::CloseAllDocuments(int bEndSession=0) Line 588
C++
mfc80ud.dll!CWinApp::CloseAllDocuments(int bEndSession=0) Line 90 C++
mfc80ud.dll!CFrameWnd::OnClose() Line 798 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=16, unsigned int
wParam=0, long lParam=0, long * pResult=0x0012f2cc) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=16, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=16, unsigned int wParam=0, long
lParam=0) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=16,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=16, unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e4194be()
user32.dll!7e41b42d()
user32.dll!7e4184fc()
user32.dll!7e41ba0e()
user32.dll!7e4184fc()
user32.dll!7e4185a4()
user32.dll!7e41b3f9()
uxtheme.dll!5ad73c20()
uxtheme.dll!5ad8e300()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
uxtheme.dll!5ad8e2d5()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=274, unsigned int
wParam=61536, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::Default() Line 274 C++
mfc80ud.dll!CWnd::OnSysCommand(unsigned int __formal=61536, unsigned int
__formal=61536) Line 460 + 0xf bytes C++
mfc80ud.dll!CFrameWnd::OnSysCommand(unsigned int nID=61536, long
lParam=3408996) Line 1042 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996, long * pResult=0x0012f8cc) Line 2056
C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=274, unsigned int wParam=61536, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=274,
unsigned int wParam=61536, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=274, unsigned int wParam=61536, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b89b()
user32.dll!7e41b903()
uxtheme.dll!5ad9881f()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=161, unsigned int
wParam=20, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=161, unsigned int
wParam=20, long lParam=3408996) Line 1742 + 0x1c bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=161, unsigned int wParam=20, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=161,
unsigned int wParam=20, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=161, unsigned int wParam=20, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
mfc80ud.dll!AfxInternalPumpMessage() Line 183 C++
mfc80ud.dll!CWinThread::PumpMessage() Line 896 C++
mfc80ud.dll!CWinThread::Run() Line 625 + 0xd bytes C++
mfc80ud.dll!CWinApp::Run() Line 889 C++
mfc80ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 47 + 0xd bytes C++
Marker.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 29 C++
Marker.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
Marker.exe!wWinMainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()
--
======
Arman
Tom Serface
2007-06-12 13:52:40 UTC
Permalink
Hi Arman,

This would be, of course, the more normal way to do things. I though OP was
trying to pass the data back to the parent during the life of the dialog.
However, you're right, you're illustration is how we would do this sort of
thing more often. I was too busy answering the question rather than solving
the problem :o)

If I wanted the parent and the child dialog to exist together I would likely
use a non-modal dialog that communicates with the parent and handles
messages from the parent. Thanks for the post.

Tom
Post by Arman Sahakyan
see below..
Post by Anders Eriksson
Hello,
I have a MFC SDI CFormView application and in the View I create a dialog
that I DoModal(); The dialog is created using the Resource Editor, not
dynamically.
In the OnInitDialog() I use this code to get a pointer to the View that is
calling the dialog
CMarkerView *pView = (CMarkerView*)GetParent();
I then use this to change a member variable in the view
pView->m_currMagazine = nMagazine;
No. If the dialog weren't modal but modeless, this kind of thing might
survive.
The wrong part is that there is no need to change the view inside a modal
dialog. If you want to, the best thing to do is to let the view get the
variable from dlg and use it [after the modal dlg exits];
CMyDlg dlg;
if (IDOK == dlg.DoModal())
{
m_currMagazine = dlg.nMagazine;
}
Post by Anders Eriksson
Somehow this is wrong! using this code will make me crash in
CPlex::FreeDataChain(), See Call Stack below.
What is wrong and how to I get a pointer to the View?
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
mfc80ud.dll!CPlex::FreeDataChain() Line 42 + 0x3 bytes C++
mfc80ud.dll!CPtrList::RemoveAll() Line 48 C++
mfc80ud.dll!CPtrList::FreeNode(CPtrList::CNode * pNode=0x003bcad0) Line
123 C++
mfc80ud.dll!CPtrList::RemoveAt(__POSITION * position=0x003bcad0) Line
324 C++
mfc80ud.dll!CFrameWnd::RemoveControlBar(CControlBar * pBar=0x01001304)
Line 875 C++
mfc80ud.dll!CControlBar::OnDestroy() Line 586 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012e9f4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!CControlBar::WindowProc(unsigned int nMsg=2, unsigned int
wParam=0, long lParam=0) Line 504 + 0x14 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001304, HWND__ *
hWnd=0x00011302, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x00011302, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
[Frames below may be incorrect and/or missing, no symbols loaded for
user32.dll]
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CControlBar::DestroyWindow() Line 598 C++
mfc80ud.dll!CFrameWnd::DestroyDockBars() Line 1618 C++
mfc80ud.dll!CFrameWnd::OnDestroy() Line 852 C++
Marker.exe!CMainFrame::OnDestroy() Line 126 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=2, unsigned int wParam=0,
long lParam=0, long * pResult=0x0012eec4) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=2, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=2, unsigned int wParam=0, long lParam=0)
Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int nMsg=2,
unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
mfc80ud.dll!CThreadSlotData::GetThreadValue(int nSlot=1471840) Line 265
C++
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e41daf6()
mfc80ud.dll!CWnd::DestroyWindow() Line 993 + 0xd bytes C++
mfc80ud.dll!CDocument::OnCloseDocument() Line 744 C++
mfc80ud.dll!CDocTemplate::CloseAllDocuments(int __formal=0) Line 355
C++
mfc80ud.dll!CDocManager::CloseAllDocuments(int bEndSession=0) Line 588
C++
mfc80ud.dll!CWinApp::CloseAllDocuments(int bEndSession=0) Line 90 C++
mfc80ud.dll!CFrameWnd::OnClose() Line 798 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=16, unsigned int
wParam=0, long lParam=0, long * pResult=0x0012f2cc) Line 2028 C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=16, unsigned int
wParam=0, long lParam=0) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=16, unsigned int wParam=0, long
lParam=0) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=16,
unsigned int wParam=0, long lParam=0) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=16, unsigned int wParam=0, long lParam=0) Line 407 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b4c0()
user32.dll!7e41b50c()
ntdll.dll!7c90eae3()
user32.dll!7e4194be()
user32.dll!7e41b42d()
user32.dll!7e4184fc()
user32.dll!7e41ba0e()
user32.dll!7e4184fc()
user32.dll!7e4185a4()
user32.dll!7e41b3f9()
uxtheme.dll!5ad73c20()
uxtheme.dll!5ad8e300()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
uxtheme.dll!5ad8e2d5()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=274, unsigned int
wParam=61536, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::Default() Line 274 C++
mfc80ud.dll!CWnd::OnSysCommand(unsigned int __formal=61536, unsigned int
__formal=61536) Line 460 + 0xf bytes C++
mfc80ud.dll!CFrameWnd::OnSysCommand(unsigned int nID=61536, long
lParam=3408996) Line 1042 C++
mfc80ud.dll!CWnd::OnWndMsg(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996, long * pResult=0x0012f8cc) Line 2056
C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=274, unsigned int
wParam=61536, long lParam=3408996) Line 1741 + 0x20 bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=274, unsigned int wParam=61536, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=274,
unsigned int wParam=61536, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=274, unsigned int wParam=61536, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41b89b()
user32.dll!7e41b903()
uxtheme.dll!5ad9881f()
uxtheme.dll!5ad71ac7()
uxtheme.dll!5ad71b3d()
user32.dll!7e41bb15()
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e41c63f()
user32.dll!7e41c665()
mfc80ud.dll!CWnd::DefWindowProcW(unsigned int nMsg=161, unsigned int
wParam=20, long lParam=3408996) Line 1029 + 0x20 bytes C++
mfc80ud.dll!CWnd::WindowProc(unsigned int message=161, unsigned int
wParam=20, long lParam=3408996) Line 1742 + 0x1c bytes C++
mfc80ud.dll!AfxCallWndProc(CWnd * pWnd=0x01001230, HWND__ *
hWnd=0x000112b0, unsigned int nMsg=161, unsigned int wParam=20, long
lParam=3408996) Line 240 + 0x1c bytes C++
mfc80ud.dll!AfxWndProc(HWND__ * hWnd=0x000112b0, unsigned int nMsg=161,
unsigned int wParam=20, long lParam=3408996) Line 389 C++
mfc80ud.dll!AfxWndProcBase(HWND__ * hWnd=0x000112b0, unsigned int
nMsg=161, unsigned int wParam=20, long lParam=3408996) Line 407 + 0x15
bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e4189cd()
user32.dll!7e418a10()
mfc80ud.dll!AfxInternalPumpMessage() Line 183 C++
mfc80ud.dll!CWinThread::PumpMessage() Line 896 C++
mfc80ud.dll!CWinThread::Run() Line 625 + 0xd bytes C++
mfc80ud.dll!CWinApp::Run() Line 889 C++
mfc80ud.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 47 + 0xd bytes C++
Marker.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, wchar_t * lpCmdLine=0x00020f94, int nCmdShow=1)
Line 29 C++
Marker.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
Marker.exe!wWinMainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()
--
======
Arman
Ajay Kalra
2007-06-12 14:26:05 UTC
Permalink
Post by Arman Sahakyan
The wrong part is that there is no need to change the view inside a modal
dialog.
Why? Whats wrong in changing the view from the dialog? We did this
routinely. Instead of using GetParent, I used GetActiveView(thats what
we wanted) but thats besides the issue.


---
Ajay
David Webber
2007-06-12 14:47:35 UTC
Permalink
This post might be inappropriate. Click to display it.
Ajay Kalra
2007-06-12 15:29:40 UTC
Permalink
Post by David Webber
Post by Ajay Kalra
Why? Whats wrong in changing the view from the dialog? We did this
routinely. Instead of using GetParent, I used GetActiveView(thats what
we wanted) but thats besides the issue.
It should also be noted the modal property sheet dialogues have an "Apply"
button which is intended for exactly this purpose.
If I have dialogues which do this, and rely on having a CMyView as the
parent, I tend to write the constructor with an argument which is a
CMyDialog
{
CMyView &m_view;
public
CMyDialog( CMyView &wndParent );
...
}
with a constructor broadly of the form
CMyDialog::CMyDialog( CMyView &wndParent )
: CDialog( &wndParent )
, m_view( wndParent )
{
}
That way the dialogue cannot be constructed without a view of the required
kind, and it can do what it likes to that view directly (using m_view) while
it lives.
If you have a common base class of all your views, this is not a
problem. In a typical MDI app, you will end up with that scenario. Our
case was simple, some acclerator key when hit in a dialog was always
needed to go to the active view(eg hitting F8 in dialog would rotate
the model in the view). The key was explicity forwarded to the view
without caching the view pointer.

---
Ajay
Post by David Webber
I don't do this a lot, as it can be like a loaded gun with a hair trigger
pointed at one's foot <g> but one very useful example is setting margins and
other spacing on a page. The dialogue can change the settings in the
controls and they can be shown immediately on the view. Of course it helps
to have an implementation of Ctrl+Z for after you get out :-)
Dave
--
David Webber
Author of 'Mozart the Music Processor'http://www.mozart.co.uk
For discussion/support seehttp://www.mozart.co.uk/mzusers/mailinglist.htm
Tom Serface
2007-06-12 16:13:44 UTC
Permalink
Hi David,

I think the Apply button mostly signals the parent sheet to get the data
from the pages, but in this case OP had a CFormView that started up a modal
dialog. While it is possible to update the dialog, I still think that
accessing the parent directly to update controls would be the wrong way to
go about it. I would prefer sending messages and having the parent update
itself.

Still, most of the time, I would simply fish the data out of the dialog
object after the modal dialog is closed (if the user says OK) and not fish
the data out if the user canceled the modal dialog. Adding something like
an Apply button into the mix would change that paradigm though. OP didn't
mention having an Apply button on their modal dialog.

Tom
Post by David Webber
Post by Ajay Kalra
Why? Whats wrong in changing the view from the dialog? We did this
routinely. Instead of using GetParent, I used GetActiveView(thats what
we wanted) but thats besides the issue.
It should also be noted the modal property sheet dialogues have an "Apply"
button which is intended for exactly this purpose.
If I have dialogues which do this, and rely on having a CMyView as the
parent, I tend to write the constructor with an argument which is a
CMyDialog
{
CMyView &m_view;
public
CMyDialog( CMyView &wndParent );
...
}
with a constructor broadly of the form
CMyDialog::CMyDialog( CMyView &wndParent )
: CDialog( &wndParent )
, m_view( wndParent )
{
}
That way the dialogue cannot be constructed without a view of the required
kind, and it can do what it likes to that view directly (using m_view)
while it lives.
I don't do this a lot, as it can be like a loaded gun with a hair trigger
pointed at one's foot <g> but one very useful example is setting margins
and other spacing on a page. The dialogue can change the settings in the
controls and they can be shown immediately on the view. Of course it
helps to have an implementation of Ctrl+Z for after you get out :-)
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
Arman Sahakyan
2007-06-13 05:13:01 UTC
Permalink
Hi,
Post by Ajay Kalra
Post by Arman Sahakyan
The wrong part is that there is no need to change the view inside a modal
dialog.
Why? Whats wrong in changing the view from the dialog? We did this
routinely. Instead of using GetParent, I used GetActiveView(thats what
we wanted) but thats besides the issue.
Well. If we dive into the problem, we would speak about design issues.
Actually, one could change the view inside of the dialog and, in general,
this is normal. Though, as said [by me], no need to do that in a modal
dialog. This kind of usage [of the view] only does increase the coupling
between the view and the dialog (except for the rare cases which I cannot
point out now).
--
======
Arman
Ajay Kalra
2007-06-13 12:49:32 UTC
Permalink
Post by Arman Sahakyan
This kind of usage [of the view] only does increase the coupling
between the view and the dialog (except for the rare cases which I cannot
point out now).
As mentioned in my reply to David Webber, this worked for us without
any coupling between the view and the dialog. Getting the view using
GetActiveView and passing on a selected method to the view is not bad
in my view. In this case, where we wanted accelerators to work in the
view at all times, this is a necessary.

---
Ajay

Loading...