From: RAN on 8 Dec 2009 12:36 Hi, I use VS2008Pro. I have created an ActiveX control dat shows a chessboard etc, I have created an ActiveX event called OnPromotion(); I created a standard CDialog project and inserted the chess activex control. I added the activex event OnPromotion() and want to show a second CDailog using DoModal() inside of this OnPromotion() event. The second (promotion dialog) is shown, but when i click it i get a debug assertion failed message. Can i not call a DoModal() inside an activex event in my dialog? BEGIN_EVENTSINK_MAP(CXPTESTDlg, CDialog) ON_EVENT(CXPTESTDlg, IDC_CHESSACTIVECTRL1, 1, CXPTESTDlg::OnPromotion, VTS_NONE) END_EVENTSINK_MAP() void CXPTESTDlg::OnPromotion() { // TODO: Add your message handler code here // This call causes a debug assertion failed //o_PromotionDlg.DoModal(); ::PostMessage (this->m_hWnd ,_UDM_TEST,0,0); } void CXPTESTDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here o_PromotionDlg.DoModal (); } LRESULT CXPTESTDlg::OnTest(WPARAM wParam, LPARAM lParam) { o_PromotionDlg.DoModal (); return 0; } If i use PostMessage instead to call the DoModal() it works fine. I dont know why this happens. Could someone help please? Thanks.
From: Joseph M. Newcomer on 8 Dec 2009 15:32 See below... On Tue, 8 Dec 2009 09:36:13 -0800 (PST), RAN <nijenhuis(a)wish.nl> wrote: >Hi, > >I use VS2008Pro. >I have created an ActiveX control dat shows a chessboard etc, >I have created an ActiveX event called OnPromotion(); >I created a standard CDialog project and inserted the chess activex >control. >I added the activex event OnPromotion() and want to show a second >CDailog using DoModal() inside of this OnPromotion() event. >The second (promotion dialog) is shown, but when i click it i get a >debug assertion failed message. Can i not call a DoModal() inside an >activex event in my dialog? **** I am absolutely certain you do not get "a" debug assertion message. I have a great confidence that you get a VERY SPECIFIC assertion failure, that specifies a file, and line, and you can supply a backtrace from that location to your code. Be sure to tell us what version of VS you are using so we know how to correlate the file/line with actual source code. **** > >BEGIN_EVENTSINK_MAP(CXPTESTDlg, CDialog) > ON_EVENT(CXPTESTDlg, IDC_CHESSACTIVECTRL1, 1, >CXPTESTDlg::OnPromotion, VTS_NONE) >END_EVENTSINK_MAP() > >void CXPTESTDlg::OnPromotion() >{ > // TODO: Add your message handler code here > > // This call causes a debug assertion failed > //o_PromotionDlg.DoModal(); > > > > ::PostMessage (this->m_hWnd ,_UDM_TEST,0,0); **** Why such a clumsy method? Would't it be easier to write PostMessage(_UDM_TEST); ? **** >} > >void CXPTESTDlg::OnBnClickedButton1() **** One of the VERY FIRST things you should do when you add a control is change the ID from the useless IDC_BUTTON1 to something that makes sense. **** >{ > // TODO: Add your control notification handler code here > o_PromotionDlg.DoModal (); >} > >LRESULT CXPTESTDlg::OnTest(WPARAM wParam, LPARAM lParam) >{ > o_PromotionDlg.DoModal (); > return 0; >} **** There isn't enough information here. Lacking any description of the assertion failure, there's nothing to try but psychic vibrations, and they don't work too well. **** > >If i use PostMessage instead to call the DoModal() it works fine. >I dont know why this happens. >Could someone help please? **** First, give us complete information. Second, where is o_PromotionDlg declared? It should be a local variable in the function, since there is no reason for it to exist outside the scope of the function that does the DoModal. If you are inventing new notational conventions, such as a prefix "o_", it is important that you explain what it means. joe **** > >Thanks. Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: RAN on 8 Dec 2009 16:11 On 8 dec, 21:32, Joseph M. Newcomer <newco...(a)flounder.com> wrote: > See below... > > On Tue, 8 Dec 2009 09:36:13 -0800 (PST), RAN <nijenh...(a)wish.nl> wrote: > >Hi, > > >I use VS2008Pro. > >I have created an ActiveX control dat shows a chessboard etc, > >I have created an ActiveX event called OnPromotion(); > >I created a standard CDialog project and inserted the chess activex > >control. > >I added the activex event OnPromotion() and want to show a second > >CDailog using DoModal() inside of this OnPromotion() event. > >The second (promotion dialog) is shown, but when i click it i get a > >debug assertion failed message. Can i not call a DoModal() inside an > >activex event in my dialog? > > **** > I am absolutely certain you do not get "a" debug assertion message. I have a great > confidence that you get a VERY SPECIFIC assertion failure, that specifies a file, and > line, and you can supply a backtrace from that location to your code. Be sure to tell us > what version of VS you are using so we know how to correlate the file/line with actual > source code. > **** > > > > > > >BEGIN_EVENTSINK_MAP(CXPTESTDlg, CDialog) > > ON_EVENT(CXPTESTDlg, IDC_CHESSACTIVECTRL1, 1, > >CXPTESTDlg::OnPromotion, VTS_NONE) > >END_EVENTSINK_MAP() > > >void CXPTESTDlg::OnPromotion() > >{ > > // TODO: Add your message handler code here > > > // This call causes a debug assertion failed > > //o_PromotionDlg.DoModal(); > > > ::PostMessage (this->m_hWnd ,_UDM_TEST,0,0); > > **** > Why such a clumsy method? Would't it be easier to write > PostMessage(_UDM_TEST); > ? > ****>} > > >void CXPTESTDlg::OnBnClickedButton1() > > **** > One of the VERY FIRST things you should do when you add a control is change the ID from > the useless IDC_BUTTON1 to something that makes sense. > ****>{ > > // TODO: Add your control notification handler code here > > o_PromotionDlg.DoModal (); > >} > > >LRESULT CXPTESTDlg::OnTest(WPARAM wParam, LPARAM lParam) > >{ > > o_PromotionDlg.DoModal (); > > return 0; > >} > > **** > There isn't enough information here. Lacking any description of the assertion failure, > there's nothing to try but psychic vibrations, and they don't work too well. > **** > > >If i use PostMessage instead to call the DoModal() it works fine. > >I dont know why this happens. > >Could someone help please? > > **** > First, give us complete information. > > Second, where is o_PromotionDlg declared? It should be a local variable in the function, > since there is no reason for it to exist outside the scope of the function that does the > DoModal. If you are inventing new notational conventions, such as a prefix "o_", it is > important that you explain what it means. > joe > **** > > >Thanks. > > Joseph M. Newcomer [MVP] > email: newco...(a)flounder.com > Web:http://www.flounder.com > MVP Tips:http://www.flounder.com/mvp_tips.htm- Tekst uit oorspronkelijk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven - 1) I use Microsoft Visual Studio 2008, version 9.0.21022.8 RTM 2) i use the notational convention prefix _o for anything that is a class or object. 3) the declaration of o_PromotionDlg is in class CXPTESTDlg: // XP TESTDlg.h : header file // #pragma once #include "chessactivectrl1.h" #include "PromotionDlg.h" #define _UDM_TEST WM_USER + 100 // CXPTESTDlg dialog class CXPTESTDlg : public CDialog { // Construction public: CXPTESTDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_XPTEST_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: CChessactivectrl1 o_ChessActive; DECLARE_EVENTSINK_MAP() void OnPromotion(); CPromotionDlg o_PromotionDlg; afx_msg void OnBnClickedButton1(); LRESULT OnTest(WPARAM wParam, LPARAM lParam); }; 4) if i click the break button after the debug assertion failed box it jumps to file: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp (line 492) HWND CDialog::PreModal() { // cannot call DoModal on a dialog already constructed as modeless ASSERT(m_hWnd == NULL); // allow OLE servers to disable themselves CWinApp* pApp = AfxGetApp(); if (pApp != NULL) pApp->EnableModeless(FALSE); // find parent HWND HWND hWnd = CWnd::GetSafeOwner_(m_pParentWnd->GetSafeHwnd(), &m_hWndTop); // hook for creation of dialog AfxHookWindowCreate(this); // return window to use as parent for dialog return hWnd; } the first ASSERT() failes. 5) i also tried : void CXPTESTDlg::OnPromotion() { // TODO: Add your message handler code here CDialog o_Test; o_Test.Create (IDD_PROMOTION); // This call causes a debug assertion failed o_Test.DoModal(); } I get the same error. I hope i have send you some information you can use. Thanks.
From: Drew on 8 Dec 2009 17:13 // XP TESTDlg.h : header file // #pragma once #include "chessactivectrl1.h" #include "PromotionDlg.h" #define _UDM_TEST WM_USER + 100 // CXPTESTDlg dialog class CXPTESTDlg : public CDialog { // Construction public: CXPTESTDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data enum { IDD = IDD_XPTEST_DIALOG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: HICON m_hIcon; // Generated message map functions virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() public: CChessactivectrl1 o_ChessActive; DECLARE_EVENTSINK_MAP() void OnPromotion(); CPromotionDlg o_PromotionDlg; afx_msg void OnBnClickedButton1(); LRESULT OnTest(WPARAM wParam, LPARAM lParam); }; 4) if i click the break button after the debug assertion failed box it jumps to file: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp (line 492) HWND CDialog::PreModal() { // cannot call DoModal on a dialog already constructed as modeless ASSERT(m_hWnd == NULL); // allow OLE servers to disable themselves CWinApp* pApp = AfxGetApp(); if (pApp != NULL) pApp->EnableModeless(FALSE); // find parent HWND HWND hWnd = CWnd::GetSafeOwner_(m_pParentWnd->GetSafeHwnd(), &m_hWndTop); // hook for creation of dialog AfxHookWindowCreate(this); // return window to use as parent for dialog return hWnd; } the first ASSERT() failes. 5) i also tried : void CXPTESTDlg::OnPromotion() { // TODO: Add your message handler code here CDialog o_Test; o_Test.Create (IDD_PROMOTION); // This call causes a debug assertion failed o_Test.DoModal(); } Why isn't this: void CXPTESTDlg::OnPromotion() { o_PromotionDlg.DoModal(); } ? Drew
From: RAN on 8 Dec 2009 17:39 On 8 dec, 23:13, "Drew" <d...(a)dam.com> wrote: > // XP TESTDlg.h : header file > // > > #pragma once > #include "chessactivectrl1.h" > #include "PromotionDlg.h" > > #define _UDM_TEST WM_USER + 100 > > // CXPTESTDlg dialog > class CXPTESTDlg : public CDialog > { > // Construction > public: > CXPTESTDlg(CWnd* pParent = NULL); // standard constructor > > // Dialog Data > enum { IDD = IDD_XPTEST_DIALOG }; > > protected: > virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support > > // Implementation > protected: > HICON m_hIcon; > > // Generated message map functions > virtual BOOL OnInitDialog(); > afx_msg void OnSysCommand(UINT nID, LPARAM lParam); > afx_msg void OnPaint(); > afx_msg HCURSOR OnQueryDragIcon(); > DECLARE_MESSAGE_MAP() > public: > CChessactivectrl1 o_ChessActive; > DECLARE_EVENTSINK_MAP() > void OnPromotion(); > CPromotionDlg o_PromotionDlg; > afx_msg void OnBnClickedButton1(); > LRESULT OnTest(WPARAM wParam, LPARAM lParam); > > }; > > 4) if i click the break button after the debug assertion failed box it > jumps to file: > f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp (line 492) > > HWND CDialog::PreModal() > { > // cannot call DoModal on a dialog already constructed as modeless > ASSERT(m_hWnd == NULL); > > // allow OLE servers to disable themselves > CWinApp* pApp = AfxGetApp(); > if (pApp != NULL) > pApp->EnableModeless(FALSE); > > // find parent HWND > HWND hWnd = CWnd::GetSafeOwner_(m_pParentWnd->GetSafeHwnd(), > &m_hWndTop); > > // hook for creation of dialog > AfxHookWindowCreate(this); > > // return window to use as parent for dialog > return hWnd; > > } > > the first ASSERT() failes. > > 5) i also tried : > > void CXPTESTDlg::OnPromotion() > { > // TODO: Add your message handler code here > > CDialog o_Test; > > o_Test.Create (IDD_PROMOTION); > > // This call causes a debug assertion failed > o_Test.DoModal(); > > } > > Why isn't this: > > void CXPTESTDlg::OnPromotion() > { > o_PromotionDlg.DoModal(); > > } > > ? > > Drew HWND CDialog::PreModal() { // cannot call DoModal on a dialog already constructed as modeless ASSERT(m_hWnd == NULL); I dont understand the comment. which dialog ? modeless ?
|
Next
|
Last
Pages: 1 2 Prev: Client Server and Throttling Next: Unicode, CRichEditCtrl, SetWindowText and Paste |