Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. resizing problem in a selfmade MDIChildFrame

resizing problem in a selfmade MDIChildFrame

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Franken
    wrote on last edited by
    #1

    Hi all, I've written an MFC MDI application where I need an additional child frame to show other aspects of my data. So I derived a class from CMDIChildWnd and created the Icon, Accelerator and Menu. My view for this child frame is derived from CFormView and has a chart control an a button control. I call/create the child frame by choosing a menu entry as follows: void CmyApp::OnAnsichtnewView() { // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. CMainFrame *pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd); pFrame->CreateNewChild(RUNTIME_CLASS(CmyChildFrm), IDR_myTYPE); CRect cr; pFrame->GetActiveFrame()->GetClientRect(cr); CDocument *pDoc = pFrame->GetActiveDocument(); CRuntimeClass *pRTC = RUNTIME_CLASS(CmyFromView); CCreateContext context; context.m_pCurrentDoc = pDoc; context.m_pNewViewClass = pRTC; context.m_pLastView = NULL; pFrame->GetActiveFrame()->CreateView(&context); } In my view class I've overwritten the OnSize method as follows: void CmyFormView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein. if(m_Chart.GetSafeHwnd() != NULL) { m_Chart.MoveWindow(0, 0, cx-30, cy); AfxMessageBox("Chart resized"); } if(m_Button.GetSafeHwnd()) { m_Button.MoveWindow(cx-30, 0, 30, 30); AfxMessageBox("Button resized"); } AfxMessageBox("Form resized"); } When I run my programm and do a resize on my new child, I only get a "Form resized" MessageBox. So, obviously m_Chart and m_Button don't get a Hwnd but I don't know why. Can anybody give me a hint on this? Thanks, Frank.

    T V 2 Replies Last reply
    0
    • F Franken

      Hi all, I've written an MFC MDI application where I need an additional child frame to show other aspects of my data. So I derived a class from CMDIChildWnd and created the Icon, Accelerator and Menu. My view for this child frame is derived from CFormView and has a chart control an a button control. I call/create the child frame by choosing a menu entry as follows: void CmyApp::OnAnsichtnewView() { // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. CMainFrame *pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd); pFrame->CreateNewChild(RUNTIME_CLASS(CmyChildFrm), IDR_myTYPE); CRect cr; pFrame->GetActiveFrame()->GetClientRect(cr); CDocument *pDoc = pFrame->GetActiveDocument(); CRuntimeClass *pRTC = RUNTIME_CLASS(CmyFromView); CCreateContext context; context.m_pCurrentDoc = pDoc; context.m_pNewViewClass = pRTC; context.m_pLastView = NULL; pFrame->GetActiveFrame()->CreateView(&context); } In my view class I've overwritten the OnSize method as follows: void CmyFormView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein. if(m_Chart.GetSafeHwnd() != NULL) { m_Chart.MoveWindow(0, 0, cx-30, cy); AfxMessageBox("Chart resized"); } if(m_Button.GetSafeHwnd()) { m_Button.MoveWindow(cx-30, 0, 30, 30); AfxMessageBox("Button resized"); } AfxMessageBox("Form resized"); } When I run my programm and do a resize on my new child, I only get a "Form resized" MessageBox. So, obviously m_Chart and m_Button don't get a Hwnd but I don't know why. Can anybody give me a hint on this? Thanks, Frank.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      Follow the Forum rule please[^]


      You don't know where to start ? ask a good friend

      [VisualCalc 3.0][Flags Beginner's Guide]

      1 Reply Last reply
      0
      • F Franken

        Hi all, I've written an MFC MDI application where I need an additional child frame to show other aspects of my data. So I derived a class from CMDIChildWnd and created the Icon, Accelerator and Menu. My view for this child frame is derived from CFormView and has a chart control an a button control. I call/create the child frame by choosing a menu entry as follows: void CmyApp::OnAnsichtnewView() { // TODO: Fügen Sie hier Ihren Befehlsbehandlungscode ein. CMainFrame *pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd); pFrame->CreateNewChild(RUNTIME_CLASS(CmyChildFrm), IDR_myTYPE); CRect cr; pFrame->GetActiveFrame()->GetClientRect(cr); CDocument *pDoc = pFrame->GetActiveDocument(); CRuntimeClass *pRTC = RUNTIME_CLASS(CmyFromView); CCreateContext context; context.m_pCurrentDoc = pDoc; context.m_pNewViewClass = pRTC; context.m_pLastView = NULL; pFrame->GetActiveFrame()->CreateView(&context); } In my view class I've overwritten the OnSize method as follows: void CmyFormView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Fügen Sie hier Ihren Meldungsbehandlungscode ein. if(m_Chart.GetSafeHwnd() != NULL) { m_Chart.MoveWindow(0, 0, cx-30, cy); AfxMessageBox("Chart resized"); } if(m_Button.GetSafeHwnd()) { m_Button.MoveWindow(cx-30, 0, 30, 30); AfxMessageBox("Button resized"); } AfxMessageBox("Form resized"); } When I run my programm and do a resize on my new child, I only get a "Form resized" MessageBox. So, obviously m_Chart and m_Button don't get a Hwnd but I don't know why. Can anybody give me a hint on this? Thanks, Frank.

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #3

        It seems your m_Button and m_Chart variables were not associated with child controls. Did you create your child controls with Create member, like m_Button.Create(. . .), or in a different way? Maybe you should show us more details.

        F 1 Reply Last reply
        0
        • V Viorel

          It seems your m_Button and m_Chart variables were not associated with child controls. Did you create your child controls with Create member, like m_Button.Create(. . .), or in a different way? Maybe you should show us more details.

          F Offline
          F Offline
          Franken
          wrote on last edited by
          #4

          I used the dialog editor to create the controls. The chart control is an ActiveX control and the button is actually a checkbox control, which behaves like a button. In this editor I also assigned the member variables by a right click on the control and let the framework do the job. So the framework also created the DataExchange

          void CmyFormView::DoDataExchange(CDataExchange* pDX)
          {
          CFormView::DoDataExchange(pDX);
          DDX_Control(pDX, IDC_TCHART_Chart, m_Chart);
          DDX_Control(pDX, IDC_CHECK_Button, m_Button);
          }

          I created also another child frame in the same way but assigned it to a DocTemplate so that it starts when the programm start. Here I don't have resizing problems. So maybe I did something wrong in my OnAnsichtnewView part when the user creates the child frame. Maybe I have to pass a handle? Thanks, Frank. -- modified at 7:32 Saturday 25th November, 2006

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups