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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ListView Assert - IsWindow(m_hWnd)

ListView Assert - IsWindow(m_hWnd)

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 Posts 5 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.
  • S Offline
    S Offline
    Shutter
    wrote on last edited by
    #1

    Hi, I have a listview as one of my splitter panes. A function in this view is as follows: void MyFunction(CString* str) { // Code to insert str as an item // such as GetListBox().InsertItem(0,str); // The same thing happens no matter what method I try... // but the view isn't recognized as a window. } But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in. Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did. Any suggestions? :confused: Shutter

    B V B J 4 Replies Last reply
    0
    • S Shutter

      Hi, I have a listview as one of my splitter panes. A function in this view is as follows: void MyFunction(CString* str) { // Code to insert str as an item // such as GetListBox().InsertItem(0,str); // The same thing happens no matter what method I try... // but the view isn't recognized as a window. } But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in. Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did. Any suggestions? :confused: Shutter

      B Offline
      B Offline
      Beer
      wrote on last edited by
      #2

      this may sound awkward, but did you try passing the CString by value instead? I've had some nasty stuff happen when I tried passing CStrings by a pointer then using them in controls. hey

      S 1 Reply Last reply
      0
      • B Beer

        this may sound awkward, but did you try passing the CString by value instead? I've had some nasty stuff happen when I tried passing CStrings by a pointer then using them in controls. hey

        S Offline
        S Offline
        Shutter
        wrote on last edited by
        #3

        That was a typo there...actually, I'm just using a CString instead of a CString*... I did try your code, but unfortunately it didn't work either. I've tried many functions... they all assert. It seems to think that there isn't a window there. Perhaps it's a cast of some sort that I'm missing...I really have no idea. Shutter

        1 Reply Last reply
        0
        • S Shutter

          Hi, I have a listview as one of my splitter panes. A function in this view is as follows: void MyFunction(CString* str) { // Code to insert str as an item // such as GetListBox().InsertItem(0,str); // The same thing happens no matter what method I try... // but the view isn't recognized as a window. } But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in. Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did. Any suggestions? :confused: Shutter

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #4

          Add a member variable to the main frame that corresponds to the listview. Kuphryn

          S 1 Reply Last reply
          0
          • V valikac

            Add a member variable to the main frame that corresponds to the listview. Kuphryn

            S Offline
            S Offline
            Shutter
            wrote on last edited by
            #5

            Could you expand on that? Shutter

            V 1 Reply Last reply
            0
            • S Shutter

              Could you expand on that? Shutter

              V Offline
              V Offline
              valikac
              wrote on last edited by
              #6

              In your code you get a pointer to the listview via GetListBox(). I meant you could assign a member variable to the listview instead of GetListBox(). Kuphryn

              1 Reply Last reply
              0
              • S Shutter

                Hi, I have a listview as one of my splitter panes. A function in this view is as follows: void MyFunction(CString* str) { // Code to insert str as an item // such as GetListBox().InsertItem(0,str); // The same thing happens no matter what method I try... // but the view isn't recognized as a window. } But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in. Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did. Any suggestions? :confused: Shutter

                B Offline
                B Offline
                Baris Kurtlutepe
                wrote on last edited by
                #7

                There's also the possibility that if you call this function from a thread that is not the creator of the listview control, this assert will fire (something like ASSERT(IsWindow(..))). Is this the case?

                S 1 Reply Last reply
                0
                • B Baris Kurtlutepe

                  There's also the possibility that if you call this function from a thread that is not the creator of the listview control, this assert will fire (something like ASSERT(IsWindow(..))). Is this the case?

                  S Offline
                  S Offline
                  Shutter
                  wrote on last edited by
                  #8

                  I haven't involved separate threads in the application. I've tried creating a ListCtrl in a formview, tried adding a ListCtrl into a CView, tried using a CListView... but still no luck. The thing is, I can see the header when I have it in Report mode, and Spy++ picks up on the windows messages for it. But even calling IsWindow on it returns false. What gets me is it's a CListView with no modification whatsoever. Oh well, I'll try more in the morning. Shutter

                  1 Reply Last reply
                  0
                  • S Shutter

                    Hi, I have a listview as one of my splitter panes. A function in this view is as follows: void MyFunction(CString* str) { // Code to insert str as an item // such as GetListBox().InsertItem(0,str); // The same thing happens no matter what method I try... // but the view isn't recognized as a window. } But whenever I try to do so, it asserts saying that it isn't a window. A listview works just fine in another 2 applications I have a listview in. Everything is standard...I haven't overridden any functions. The documentation says I don't need to create a ListCtrl because the view did. Any suggestions? :confused: Shutter

                    J Offline
                    J Offline
                    JT Anderson
                    wrote on last edited by
                    #9

                    What is the value of m_hWnd at the time you get the ASSERT failure? Is it NULL? You haven't created the window. Is it 0xDDDDDDDD? You have deleted the CListView object. Is it 0xCDCDCDCD? I don't know how this could be. But it is interesting. (It would mean m_hWnd had not be initialized.) If it is something else, what is it? -------- There are 10 types of people in this world. Those who know binary and those who don't.

                    S 1 Reply Last reply
                    0
                    • J JT Anderson

                      What is the value of m_hWnd at the time you get the ASSERT failure? Is it NULL? You haven't created the window. Is it 0xDDDDDDDD? You have deleted the CListView object. Is it 0xCDCDCDCD? I don't know how this could be. But it is interesting. (It would mean m_hWnd had not be initialized.) If it is something else, what is it? -------- There are 10 types of people in this world. Those who know binary and those who don't.

                      S Offline
                      S Offline
                      Shutter
                      wrote on last edited by
                      #10

                      It comes back null. But isn't the ListView supposed to create it?

                      J 1 Reply Last reply
                      0
                      • S Shutter

                        It comes back null. But isn't the ListView supposed to create it?

                        J Offline
                        J Offline
                        JT Anderson
                        wrote on last edited by
                        #11

                        Nothing happens by magic. Sometimes the framework creates windows for you. Sometimes you need to create them yourself. In this case it appears you need to create the window yourself. You have the MFC source. Read it. Debug it. Learn it. -------- There are 10 types of people in this world. Those who know binary and those who don't.

                        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