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. Problem with ListView API : LVM_ISERTITEM

Problem with ListView API : LVM_ISERTITEM

Scheduled Pinned Locked Moved C / C++ / MFC
testingbeta-testingjsonhelpquestion
15 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.
  • R Offline
    R Offline
    ravjak
    wrote on last edited by
    #1

    "Hi I'm developing dll which will do some changing stuff with ListView. I have a funny problem I want to change value of iImage in a LV_ITEM according to pszText value. Problem occurs when I want to test value of pszText, exception ouccrs Access Violation 0xC0000005 :(. But I'm testing if pitem and pitem->pszText are not null even if I tryed to use strdup(pitem->pszText) the same exception occurs. There is no problem when I tryed to change value of iItem. Is is somehow connected witch injection dll into some application ?? and its address space ?? " (WNDPROC) gfnListProc; //in some previous called function gfnListProc = (WNDPROC)SetWindowLong(listview, GWL_WNDPROC,(LONG)ListProc); __declspec(dllexport) LRESULT CALLBACK ListProc(HWND hwnd, UINT uiMsg,WPARAM wParam, LPARAM lParam) { switch (uiMsg) { case LVM_INSERTITEM: { LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam; if(pitem && pitem->pszText) MessageBox(0, pitem->pszText,":-)",MB_OK); break; } } return CallWindowProc(gfnListProc, hwnd, uiMsg, wParam, lParam); } //from commctr.h typedef struct tagLVITEMW { UINT mask; int iItem; int iSubItem; UINT state; UINT stateMask; LPWSTR pszText; int cchTextMax; int iImage; LPARAM lParam; #if (_WIN32_IE >= 0x0300) int iIndent; #endif } LVITEMW, FAR* LPLVITEMW; #define ListView_InsertItem(hwnd, pitem) \ (int)SNDMSG((hwnd), LVM_INSERTITEM, 0, (LPARAM)(const LV_ITEM FAR*)(pitem)) Thaks for reading that stuff :-) Pain is a weakness living the body

    A 1 Reply Last reply
    0
    • R ravjak

      "Hi I'm developing dll which will do some changing stuff with ListView. I have a funny problem I want to change value of iImage in a LV_ITEM according to pszText value. Problem occurs when I want to test value of pszText, exception ouccrs Access Violation 0xC0000005 :(. But I'm testing if pitem and pitem->pszText are not null even if I tryed to use strdup(pitem->pszText) the same exception occurs. There is no problem when I tryed to change value of iItem. Is is somehow connected witch injection dll into some application ?? and its address space ?? " (WNDPROC) gfnListProc; //in some previous called function gfnListProc = (WNDPROC)SetWindowLong(listview, GWL_WNDPROC,(LONG)ListProc); __declspec(dllexport) LRESULT CALLBACK ListProc(HWND hwnd, UINT uiMsg,WPARAM wParam, LPARAM lParam) { switch (uiMsg) { case LVM_INSERTITEM: { LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam; if(pitem && pitem->pszText) MessageBox(0, pitem->pszText,":-)",MB_OK); break; } } return CallWindowProc(gfnListProc, hwnd, uiMsg, wParam, lParam); } //from commctr.h typedef struct tagLVITEMW { UINT mask; int iItem; int iSubItem; UINT state; UINT stateMask; LPWSTR pszText; int cchTextMax; int iImage; LPARAM lParam; #if (_WIN32_IE >= 0x0300) int iIndent; #endif } LVITEMW, FAR* LPLVITEMW; #define ListView_InsertItem(hwnd, pitem) \ (int)SNDMSG((hwnd), LVM_INSERTITEM, 0, (LPARAM)(const LV_ITEM FAR*)(pitem)) Thaks for reading that stuff :-) Pain is a weakness living the body

      A Offline
      A Offline
      Andrew Quinn AUS
      wrote on last edited by
      #2

      Hi, Are you sure that lParam is pointing to a valid LV_ITEM structure? Cheers, Andy

      R 1 Reply Last reply
      0
      • A Andrew Quinn AUS

        Hi, Are you sure that lParam is pointing to a valid LV_ITEM structure? Cheers, Andy

        R Offline
        R Offline
        ravjak
        wrote on last edited by
        #3

        I'm pretty sure because listview is a HWND of list control and its valid Pain is a weakness living the body

        B 1 Reply Last reply
        0
        • R ravjak

          I'm pretty sure because listview is a HWND of list control and its valid Pain is a weakness living the body

          B Offline
          B Offline
          bikram singh
          wrote on last edited by
          #4

          Check that mask member contains LVIF_TEXT This flag indicates that the pszText member contains a valid address. If the flag is not set, the member could contain any "address". Also, check that cchTextMax member is not zero. (not really required) Bikram Singh

          R 1 Reply Last reply
          0
          • B bikram singh

            Check that mask member contains LVIF_TEXT This flag indicates that the pszText member contains a valid address. If the flag is not set, the member could contain any "address". Also, check that cchTextMax member is not zero. (not really required) Bikram Singh

            R Offline
            R Offline
            ravjak
            wrote on last edited by
            #5

            this pice of code doesn't work :( case LVM_INSERTITEM: { LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam; if(!pitem && !pitem->pszText) break; if( pitem->mask & LVIF_TEXT == LVIF_TEXT && pitem->cchTextMax>0) { MessageBox(okno,pitem->pszText,":-)",MB_OK); } break; any other ideas :confused: :mad::mad: Pain is a weakness living the body

            B J 2 Replies Last reply
            0
            • R ravjak

              this pice of code doesn't work :( case LVM_INSERTITEM: { LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam; if(!pitem && !pitem->pszText) break; if( pitem->mask & LVIF_TEXT == LVIF_TEXT && pitem->cchTextMax>0) { MessageBox(okno,pitem->pszText,":-)",MB_OK); } break; any other ideas :confused: :mad::mad: Pain is a weakness living the body

              B Offline
              B Offline
              bikram singh
              wrote on last edited by
              #6

              Try using brackets to delimit each expression you are testing in the if statement. Bikram Singh

              1 Reply Last reply
              0
              • R ravjak

                this pice of code doesn't work :( case LVM_INSERTITEM: { LV_ITEM FAR* pitem = (LV_ITEM FAR*) lParam; if(!pitem && !pitem->pszText) break; if( pitem->mask & LVIF_TEXT == LVIF_TEXT && pitem->cchTextMax>0) { MessageBox(okno,pitem->pszText,":-)",MB_OK); } break; any other ideas :confused: :mad::mad: Pain is a weakness living the body

                J Offline
                J Offline
                jmkhael
                wrote on last edited by
                #7

                What happens if pitem != NULL and pitem->pszText = NULL? (Hint: It wont break) I would do the test: if(pitem && pitem->pszText) { // Do the dance... } Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                R B 2 Replies Last reply
                0
                • J jmkhael

                  What happens if pitem != NULL and pitem->pszText = NULL? (Hint: It wont break) I would do the test: if(pitem && pitem->pszText) { // Do the dance... } Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                  R Offline
                  R Offline
                  ravjak
                  wrote on last edited by
                  #8

                  Not working hmmm hardcore hehe. Im testing changing iImage value according to iItem and it seems to be good if I know sequence of adding apriori, which will require some more coding. Anyway its really strage stuff isn't it :confused: Pain is a weakness living the body

                  J 1 Reply Last reply
                  0
                  • R ravjak

                    Not working hmmm hardcore hehe. Im testing changing iImage value according to iItem and it seems to be good if I know sequence of adding apriori, which will require some more coding. Anyway its really strage stuff isn't it :confused: Pain is a weakness living the body

                    J Offline
                    J Offline
                    jmkhael
                    wrote on last edited by
                    #9

                    Try this case LVM_INSERTITEM: { LPLVITEM pitem = (LPLVITEM) lParam; if(pitem && pitem->pszText) { if( ((pitem->mask & LVIF_TEXT) == LVIF_TEXT)) { MessageBox(okno,pitem->pszText,"",MB_OK); } } break; Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                    R 1 Reply Last reply
                    0
                    • J jmkhael

                      Try this case LVM_INSERTITEM: { LPLVITEM pitem = (LPLVITEM) lParam; if(pitem && pitem->pszText) { if( ((pitem->mask & LVIF_TEXT) == LVIF_TEXT)) { MessageBox(okno,pitem->pszText,"",MB_OK); } } break; Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                      R Offline
                      R Offline
                      ravjak
                      wrote on last edited by
                      #10

                      Not working. Plese remind me next time do not take a project for windows. Pain is a weakness living the body

                      R J 2 Replies Last reply
                      0
                      • R ravjak

                        Not working. Plese remind me next time do not take a project for windows. Pain is a weakness living the body

                        R Offline
                        R Offline
                        ravjak
                        wrote on last edited by
                        #11

                        But I thing I know why is it so. According to spy ++ this is a ATL:SysTreeView control. Maybe as a lparam they are sending some other struct than LV_ITEM:confused: Pain is a weakness living the body

                        1 Reply Last reply
                        0
                        • R ravjak

                          Not working. Plese remind me next time do not take a project for windows. Pain is a weakness living the body

                          J Offline
                          J Offline
                          jmkhael
                          wrote on last edited by
                          #12

                          Where is it crashing? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                          R 1 Reply Last reply
                          0
                          • J jmkhael

                            What happens if pitem != NULL and pitem->pszText = NULL? (Hint: It wont break) I would do the test: if(pitem && pitem->pszText) { // Do the dance... } Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                            B Offline
                            B Offline
                            bikram singh
                            wrote on last edited by
                            #13

                            I would do: if(pitem) { if(pitem->pszText) { // Do the dance... } } Bikram Singh

                            R 1 Reply Last reply
                            0
                            • J jmkhael

                              Where is it crashing? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                              R Offline
                              R Offline
                              ravjak
                              wrote on last edited by
                              #14

                              Im hooking into OE and it crashes when OE adds new items to address list. when i use olny iImage eg iImage = 2 it works properly but i want test pszText vaule and according to this set proper valus of iImage :) Pain is a weakness living the body

                              1 Reply Last reply
                              0
                              • B bikram singh

                                I would do: if(pitem) { if(pitem->pszText) { // Do the dance... } } Bikram Singh

                                R Offline
                                R Offline
                                ravjak
                                wrote on last edited by
                                #15

                                not working too i think this not valid pointer beacuse its not the same address space I had the similar problem some time ago when i wannted to send some char * as wparam or lparam using SendMessage. I had to use WM_COPYDATA then char * goes thru kernel memory and pointer is valid:confused: Pain is a weakness living the body

                                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