Click here to Skip to main content
15,919,423 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralReceiving from a socket Pin
monrobot1326-May-04 17:17
monrobot1326-May-04 17:17 
GeneralRe: Receiving from a socket Pin
Ryan Binns26-May-04 18:43
Ryan Binns26-May-04 18:43 
GeneralRe: Receiving from a socket Pin
bryce26-May-04 19:09
bryce26-May-04 19:09 
GeneralRe: Receiving from a socket Pin
Antony M Kancidrowski27-May-04 2:18
Antony M Kancidrowski27-May-04 2:18 
GeneralRe: Receiving from a socket Pin
monrobot1327-May-04 8:43
monrobot1327-May-04 8:43 
GeneralRe: Receiving from a socket Pin
Antony M Kancidrowski27-May-04 11:05
Antony M Kancidrowski27-May-04 11:05 
GeneralSQLBindParameter Problems...need helps!!!!! Pin
**bamboo**26-May-04 17:00
**bamboo**26-May-04 17:00 
GeneralASSERTION ERROR IN MFC MDI, HELP Pin
MFC_R_O_O_K_I_E26-May-04 16:40
MFC_R_O_O_K_I_E26-May-04 16:40 
BUILD AN MFC MDI WITH 2 FORMVIEWS THAT I CAN DISPLAY BY SELECTING IN A PULL DOWN MENU.
THE PROBLEM STARTS WHEN I CHOSE THE NEW WINDOW MENU.
I CAN STILL USE THE PULL DOWN MENU TO VIEW ONE OF THE 2 FORMVIEWS ON THE NEW WINDOW, BUT WHEN SELECT THE ORIGINAL VIEW AND USE THE PULL DOWN MENU TO SWITH TO THE OTHER FORMVIW, I GET AN ASSERTION ERROR. THE ERROR HAPPENS IN THE BASE CLASS'S SetActiveWindow() and the error pointing arrow points to IsChild(Wnd* pView).

HERE IS THE RELEVANT CODE:
*******************************
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{


/**********************************/
CMainFrame *pParentFrameWnd;
pParentFrameWnd = (CMainFrame*)this->GetParentFrame();
// pParentFrameWnd = (CMainFrame*)pApp->m_pMainWnd;
/*********************************/


CMDIPointApp* pApp = (CMDIPointApp*)AfxGetApp();
//ASSERT_KINDOF(CMDIPointApp, pApp);

CView* View;
CMDIDocTemplate* pTemplate;

POSITION pos = pApp->GetFirstDocTemplatePosition();

while(pos)
{


MessageBox(str,"CChildFrame::OnCreateClient()",MB_OK);
pTemplate = (CMDIDocTemplate*)pApp->GetNextDocTemplate(pos);
pContext->m_pNewViewClass = pTemplate->GetViewClass();
View = (CView*)CreateView(pContext);
ASSERT(View != NULL);
pTemplate->pView = View;
View->SetDlgCtrlID(0);

}


// ANY AND ALL CRICHEDITVIEW'S IN THE APP MUST BE FIRST VIEW(S) TO BE ACTIVATED
//IN ORDER FOR LAYOUT TO WORK. I ONLY HAVE ONE CRICHEDITVIEW IN MY APP
pTemplate = pApp->GetTemplate(RUNTIME_CLASS(CRICHEDITVIEW1));
if(pTemplate)
SetActiveView(pTemplate->pView);

pTemplate = pApp->GetFirstTemplate();
ActivateView(pTemplate->GetViewClass());


//DO NOT CALL CMDIChildWind::OnCreateClient since you are overriding behavior here
//return CMDIChildWnd::OnCreateClient(lpcs, pContext); //otherwise layout does not work

return TRUE;
}


void CChildFrame::ActivateView(CRuntimeClass *pViewClass)
{
CMDIPointApp* pApp = (CMDIPointApp*)AfxGetApp();
//ASSERT_KINDOF(CMDIPointApp, pApp);

CView *pActiveView = GetActiveView();
CRuntimeClass *pRun = pActiveView->GetRuntimeClass();

CMDIDocTemplate *pNewTemplate = pApp->GetTemplate(pViewClass);
CMDIDocTemplate *pActiveTemplate = pApp->GetTemplate(pRun);

//CMDIDocTemplate *pActiveTemplate = pApp->GetTemplate(pActiveView);

if(pNewTemplate == NULL) return;
if(pNewTemplate == pActiveTemplate)
{
MessageBox("NewTemplate == ActiveTemplate","");
return;
}

pActiveTemplate->pView->SetDlgCtrlID(0);
pNewTemplate->pView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);

pActiveTemplate->pView->ShowWindow(SW_HIDE);
pNewTemplate->pView->ShowWindow(SW_SHOW);

SetActiveView(pNewTemplate->pView);

RecalcLayout();
}


BOOL CChildFrame::IsViewActive(CRuntimeClass *pViewClass)
{
// return(GetActiveView()->IsKindOf(pViewClass);)


CView* pActiveView = GetActiveView();
if (pActiveView == NULL) return FALSE;
return (pActiveView->GetRuntimeClass() == pViewClass);

return FALSE;
}

...js..
GeneralBooks Pin
---Mark---26-May-04 16:28
---Mark---26-May-04 16:28 
GeneralRe: Books Pin
foxele26-May-04 21:51
foxele26-May-04 21:51 
GeneralRe: Books Pin
toxcct26-May-04 22:52
toxcct26-May-04 22:52 
GeneralRe: Books Pin
Maxwell Chen26-May-04 23:33
Maxwell Chen26-May-04 23:33 
GeneralRe: Books Pin
toxcct26-May-04 23:57
toxcct26-May-04 23:57 
GeneralRe: Books Pin
Maxwell Chen27-May-04 0:14
Maxwell Chen27-May-04 0:14 
GeneralRe: Books Pin
toxcct27-May-04 0:31
toxcct27-May-04 0:31 
GeneralRe: Books Pin
Maxwell Chen27-May-04 7:51
Maxwell Chen27-May-04 7:51 
GeneralRe: Books Pin
toxcct27-May-04 22:27
toxcct27-May-04 22:27 
GeneralConnecting to a database on a network or server using ADO Pin
Graham Holdaway26-May-04 16:25
Graham Holdaway26-May-04 16:25 
GeneralRe: Connecting to a database on a network or server using ADO Pin
Monty226-May-04 20:52
Monty226-May-04 20:52 
GeneralMonitoring USB Port Pin
jerry1211a26-May-04 15:09
jerry1211a26-May-04 15:09 
GeneralDrawState problem Pin
nm_11426-May-04 14:30
nm_11426-May-04 14:30 
GeneralSystemwide Cursor Change Pin
debacler26-May-04 11:57
debacler26-May-04 11:57 
GeneralRe: Systemwide Cursor Change Pin
Michael Dunn26-May-04 19:14
sitebuilderMichael Dunn26-May-04 19:14 
GeneralRe: Systemwide Cursor Change Pin
Naren Neelamegam26-May-04 21:48
Naren Neelamegam26-May-04 21:48 
GeneralRe: Systemwide Cursor Change Pin
debacler28-May-04 6:58
debacler28-May-04 6:58 

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.