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. call main view form subclass

call main view form subclass

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionannouncement
3 Posts 2 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.
  • T Offline
    T Offline
    Tara14
    wrote on last edited by
    #1

    Hi, I have a program, SDI, with FormView, CGreenView written in vc++6. I have created a subclass of CListCtrl named CMyListCtrl. Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done in CMyListCtrl. After the dialog box closes, I want to call a function which is written in CGreenView the main view class. Please can you tell me the right way of doing it?

    void CMyListCtrl::OnRecordEdit()
    {
    if (nItem != -1)
    {
    CAddNew *pDlg = new CAddNew();
    pDlg->type = 2;
    Dlg->DoModal();
    delete pDlg;
    // now call the function to update the list
    // which is in CGreenView, the main view class
    }
    }

    Thanks.

    _


    Fortitudine Vincimus!_

    M 1 Reply Last reply
    0
    • T Tara14

      Hi, I have a program, SDI, with FormView, CGreenView written in vc++6. I have created a subclass of CListCtrl named CMyListCtrl. Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done in CMyListCtrl. After the dialog box closes, I want to call a function which is written in CGreenView the main view class. Please can you tell me the right way of doing it?

      void CMyListCtrl::OnRecordEdit()
      {
      if (nItem != -1)
      {
      CAddNew *pDlg = new CAddNew();
      pDlg->type = 2;
      Dlg->DoModal();
      delete pDlg;
      // now call the function to update the list
      // which is in CGreenView, the main view class
      }
      }

      Thanks.

      _


      Fortitudine Vincimus!_

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun :)

      Nothing is exactly what it seems but everything with seems can be unpicked.

      T 1 Reply Last reply
      0
      • M Matthew Faithfull

        I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun :)

        Nothing is exactly what it seems but everything with seems can be unpicked.

        T Offline
        T Offline
        Tara14
        wrote on last edited by
        #3

        Thank you very much for the advice. This what I did. Its working exacly the way I want it to. Hope it is correct.

        void CMyListCtrl::OnRecordEdit()
        {
        if (nItem != -1)
        {
        CAddNew *pDlg = new CAddNew();
        pDlg->type = 2;
        pDlg->DoModal();
        delete pDlg;

        	// Send Notification to parent of ListView ctrl	
        	LV\_DISPINFO lvDispInfo;
        	lvDispInfo.hdr.hwndFrom = m\_hWnd;
        	lvDispInfo.hdr.idFrom = IDC\_FD\_LIST;
        	lvDispInfo.hdr.code = LVN\_ENDLABELEDIT;
        
        	GetParent()->GetParent()->SendMessage( WM\_NOTIFY, IDC\_FD\_LIST,(LPARAM)&lvDispInfo);
        
        }
        else
        return;
        

        }

        And in the CGreenView class :

        void CGreenMView::OnEndlabeleditFdList(NMHDR* pNMHDR, LRESULT* pResult)
        {
        LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

        // stuff to update the listctrl items
        
        \*pResult = 0;
        

        }

        _


        Fortitudine Vincimus!_

        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