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. CFromView

CFromView

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 Posts 4 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.
  • J Offline
    J Offline
    john5632
    wrote on last edited by
    #1

    Hi, I created the CFromView dynamically, Form is having CListCtrl where should set the style for CListCtrl? the below code is giving error as m_ListDriveis is NULL .

    bool CRecoverDriveDlg::CreateView(UINT Style, CRect rect,CWnd *Parent)
    {
    Create(NULL,NULL,Style,rect,Parent,0x10,NULL);

    m\_ListDrive.SetExtendedStyle(LVS\_EX\_FULLROWSELECT);//error
    return 1;
    

    }

    L A C 3 Replies Last reply
    0
    • J john5632

      Hi, I created the CFromView dynamically, Form is having CListCtrl where should set the style for CListCtrl? the below code is giving error as m_ListDriveis is NULL .

      bool CRecoverDriveDlg::CreateView(UINT Style, CRect rect,CWnd *Parent)
      {
      Create(NULL,NULL,Style,rect,Parent,0x10,NULL);

      m\_ListDrive.SetExtendedStyle(LVS\_EX\_FULLROWSELECT);//error
      return 1;
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What is m_ListDrive supposed to be and where is it initialised?

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      1 Reply Last reply
      0
      • J john5632

        Hi, I created the CFromView dynamically, Form is having CListCtrl where should set the style for CListCtrl? the below code is giving error as m_ListDriveis is NULL .

        bool CRecoverDriveDlg::CreateView(UINT Style, CRect rect,CWnd *Parent)
        {
        Create(NULL,NULL,Style,rect,Parent,0x10,NULL);

        m\_ListDrive.SetExtendedStyle(LVS\_EX\_FULLROWSELECT);//error
        return 1;
        

        }

        A Offline
        A Offline
        Andrew Brock
        wrote on last edited by
        #3

        I'm guessing what you mean is m_ListDrivis.m_hwnd is null. The variable somehow needs to be attached to the dialog control. This can be done with Dynamic Data eXchange (DDX) or the SubclassDlgItem[^] function, which must be called before m_ListDrive.SetExtendedStyle(LVS_EX_FULLROWSELECT);. You could also make it into a pointer in the class definition, and then use

        m_ListDrive = (CListCtrl *)GetDlgItem(IDC_MY_LIST); //CListCtrl is whatever control type it is, IDC_MY_LIST is the control ID set in the properties window in the dialog editor.
        m_ListDrive->SetExtendedStyle(LVS_EX_FULLROWSELECT);

        L 1 Reply Last reply
        0
        • J john5632

          Hi, I created the CFromView dynamically, Form is having CListCtrl where should set the style for CListCtrl? the below code is giving error as m_ListDriveis is NULL .

          bool CRecoverDriveDlg::CreateView(UINT Style, CRect rect,CWnd *Parent)
          {
          Create(NULL,NULL,Style,rect,Parent,0x10,NULL);

          m\_ListDrive.SetExtendedStyle(LVS\_EX\_FULLROWSELECT);//error
          return 1;
          

          }

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Why shouldn't it be NULL? I mean, you didn't show us the code initializing it.

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          1 Reply Last reply
          0
          • A Andrew Brock

            I'm guessing what you mean is m_ListDrivis.m_hwnd is null. The variable somehow needs to be attached to the dialog control. This can be done with Dynamic Data eXchange (DDX) or the SubclassDlgItem[^] function, which must be called before m_ListDrive.SetExtendedStyle(LVS_EX_FULLROWSELECT);. You could also make it into a pointer in the class definition, and then use

            m_ListDrive = (CListCtrl *)GetDlgItem(IDC_MY_LIST); //CListCtrl is whatever control type it is, IDC_MY_LIST is the control ID set in the properties window in the dialog editor.
            m_ListDrive->SetExtendedStyle(LVS_EX_FULLROWSELECT);

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Where did you get all this about a dialog? The OP's question is about creating a window.

            Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

            A 1 Reply Last reply
            0
            • L Lost User

              Where did you get all this about a dialog? The OP's question is about creating a window.

              Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

              A Offline
              A Offline
              Andrew Brock
              wrote on last edited by
              #6

              I have not used MFC for about a year now, so my memory could be a bit flaky, but: "These controls are laid out based on a dialog-template resource." - CFormView Class[^]. The form view is a pretty way of embedding a dialog into a MFC view. All of the controls on it have a dialog ID associated with them.

              L 1 Reply Last reply
              0
              • A Andrew Brock

                I have not used MFC for about a year now, so my memory could be a bit flaky, but: "These controls are laid out based on a dialog-template resource." - CFormView Class[^]. The form view is a pretty way of embedding a dialog into a MFC view. All of the controls on it have a dialog ID associated with them.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                That may well be true but it does not seem to be the way OP is implementing it. I'm ready to stand corrected, however.

                Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                A 1 Reply Last reply
                0
                • L Lost User

                  That may well be true but it does not seem to be the way OP is implementing it. I'm ready to stand corrected, however.

                  Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                  A Offline
                  A Offline
                  Andrew Brock
                  wrote on last edited by
                  #8

                  I could be completely wrong on this, but to me, it appears that he has defined a variable, something like CListCtrl m_ListDrive in the CRecoverDriveDlg class. He is expecting this variable to automatically attach to some list control he has in the dialog template (I dont see a call to m_ListDrive.Create()). My suggestion was to manually attach m_ListDrive to this control somehow. It is possible that he has called m_ListDrive.Create() elsewhere in his code and simply hasn't shown it and hence I am completely wrong. Since the original issue is m_ListDrive is NULL, then this call has failed, and that code would be relevant to helping him find a solution.

                  L 1 Reply Last reply
                  0
                  • A Andrew Brock

                    I could be completely wrong on this, but to me, it appears that he has defined a variable, something like CListCtrl m_ListDrive in the CRecoverDriveDlg class. He is expecting this variable to automatically attach to some list control he has in the dialog template (I dont see a call to m_ListDrive.Create()). My suggestion was to manually attach m_ListDrive to this control somehow. It is possible that he has called m_ListDrive.Create() elsewhere in his code and simply hasn't shown it and hence I am completely wrong. Since the original issue is m_ListDrive is NULL, then this call has failed, and that code would be relevant to helping him find a solution.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    I agree, which is why my question to him was "what is this variable and where is it initialised?". We will see; or not!

                    Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                    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