Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Felix Cho21-Feb-02 11:55
Felix Cho21-Feb-02 11:55 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Nish Nishant21-Feb-02 12:01
sitebuilderNish Nishant21-Feb-02 12:01 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Nish Nishant21-Feb-02 12:02
sitebuilderNish Nishant21-Feb-02 12:02 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Felix Cho21-Feb-02 16:39
Felix Cho21-Feb-02 16:39 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Tim Smith21-Feb-02 13:51
Tim Smith21-Feb-02 13:51 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Nish Nishant21-Feb-02 14:23
sitebuilderNish Nishant21-Feb-02 14:23 
GeneralRe: Unbelievable error when attempting to return a BSTR** as retval Pin
Mazdak21-Feb-02 19:43
Mazdak21-Feb-02 19:43 
GeneralView in Dialog Problems Pin
yellowine21-Feb-02 11:18
yellowine21-Feb-02 11:18 
I am writing codes to put a view in a dialog.
Here are the code to initialize the view in a dialog:

BOOL CMyDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CCreateContext pContext;

	CWnd* pFrameWnd = this;
  
	pContext.m_pCurrentDoc = new CMyDoc();
	pContext.m_pNewViewClass = RUNTIME_CLASS(CMyView);
	CMyView *pView = (CMyView *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
	ASSERT(pView);
	pView->ShowWindow(SW_NORMAL);
/*
* After a view is created, resize that to 
* have the same size as the dialog.
*/
	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);
/**
 * Leave a little space for border and title...
 */
	rectWindow.right += 15;
	rectWindow.top   -= 10;
	pView->MoveWindow(rectWindow);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


I got two problems:
(1) If the CMyView is kind of CHtmlView and if the dialog is displayed within an MFC MDI application, when I clicked the view right after the view is displayed, I got an ASSERT in CView::OnMouseActivate(..). But if the dialog is the main window of a dialog-based MFC app, it works fine. Why?Confused | :confused:
(2) I use the following code to detect if there is memory leak:

void CMyDlgView::OnViewViewInDialog() 
{
	// TODO: Add your command handler code here
// Declare the variables needed
#ifdef _DEBUG
    CMemoryState oldMemState, newMemState, diffMemState;
    oldMemState.Checkpoint();
#endif

	ShowDialog();
#ifdef _DEBUG
    newMemState.Checkpoint();
    if( diffMemState.Difference( oldMemState, newMemState ) )
    {
        TRACE( "Memory leaked!\n" );
    }
#endif

}

void CMyDlgView::ShowDialog()
{
	CMyDialog dlg;
	dlg.DoModal();

}


if it is a CHtmlView derived view, there is memork leak; however if it is a generic CView derived view, no memory leak. Why?Confused | :confused:
GeneralRe: View in Dialog Problems Pin
Joaquín M López Muñoz21-Feb-02 11:26
Joaquín M López Muñoz21-Feb-02 11:26 
GeneralRe: View in Dialog Problems Pin
yellowine21-Feb-02 11:40
yellowine21-Feb-02 11:40 
GeneralRe: View in Dialog Problems Pin
21-Feb-02 11:27
suss21-Feb-02 11:27 
GeneralRe: View in Dialog Problems Pin
yellowine21-Feb-02 11:35
yellowine21-Feb-02 11:35 
GeneralHorror of horrors :- _T is undefined error :-( Pin
Nish Nishant21-Feb-02 11:11
sitebuilderNish Nishant21-Feb-02 11:11 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Joaquín M López Muñoz21-Feb-02 11:10
Joaquín M López Muñoz21-Feb-02 11:10 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Nish Nishant21-Feb-02 11:17
sitebuilderNish Nishant21-Feb-02 11:17 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Joaquín M López Muñoz21-Feb-02 11:15
Joaquín M López Muñoz21-Feb-02 11:15 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Nish Nishant21-Feb-02 11:29
sitebuilderNish Nishant21-Feb-02 11:29 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Matt Newman21-Feb-02 11:56
Matt Newman21-Feb-02 11:56 
GeneralRe: Horror of horrors :- _T is undefined error :-( Pin
Tim Smith21-Feb-02 13:53
Tim Smith21-Feb-02 13:53 
GeneralATL query - BSTR vs BSTR* Pin
Nish Nishant21-Feb-02 11:00
sitebuilderNish Nishant21-Feb-02 11:00 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:31
Derek Waters21-Feb-02 11:31 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Nish Nishant21-Feb-02 11:41
sitebuilderNish Nishant21-Feb-02 11:41 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:43
Derek Waters21-Feb-02 11:43 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Nish Nishant21-Feb-02 11:53
sitebuilderNish Nishant21-Feb-02 11:53 
GeneralRe: ATL query - BSTR vs BSTR* Pin
Derek Waters21-Feb-02 11:32
Derek Waters21-Feb-02 11:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.