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. Windows API
  4. sort click colomn title

sort click colomn title

Scheduled Pinned Locked Moved Windows API
cssquestion
4 Posts 3 Posters 2 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.
  • M Offline
    M Offline
    Member 10402390
    wrote on last edited by
    #1

    i try sort virtual list-view with click on column title but when i click nothing happens this dialog procedure:

    BOOL CALLBACK DlgProc(HWND hwnd,UINT msg, WPARAM wParam,LPARAM lParam)
    {
    static HWND hWndList = 0;

    switch(msg)
    {
    case WM_INITDIALOG:
    {
    hWndList= CreateWindowEx(0, WC_LISTVIEW, NULL,
    WS_CHILD|WS_BORDER|WS_VISIBLE|LVS_OWNERDATA|LVS_REPORT,
    20, 20, 620, 300, hwnd, NULL, hInstance,NULL);

      //заголовок
      LV\_COLUMN lvc;
      ZeroMemory(&lvc,sizeof(lvc));
    
      lvc.mask=LVCF\_FMT|LVCF\_SUBITEM|LVCF\_TEXT|LVCF\_WIDTH;
      lvc.fmt=LVCFMT\_LEFT;//выравнивание
      
      lvc.cx=150;
      lvc.pszText=(LPSTR)"имя файла";
      ListView\_InsertColumn(hWndList,0,&lvc);
    
      ListView\_SetItemCount(hWndList,directory.size());
      return TRUE;
    }
    

    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case IDOK:
    case IDCANCEL:
    EndDialog(hwnd,0);
    return true;
    }

    case WM_NOTIFY:
    {
    switch (((LPNMHDR)lParam)->code)
    {
    case LVN_GETDISPINFO:
    {
    NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;

          switch (plvdi->item.iSubItem)
          {
          case 0:
            {
              plvdi->item.pszText = (LPSTR)directory\[plvdi->item.iItem\].\_name.c\_str();//"имя файла"
              break;
            }
          default:
            break;
          }
        }
    
        case LVN\_COLUMNCLICK:
        {
          LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
          //NM\_LISTVIEW \*pnmv= (NM\_LISTVIEW\*)lParam;
          switch (pnmv->iSubItem)
          {
          case 0:
            {
              //"имя файла"
              sort(directory.begin(), directory.end(), boost::bind(less(), boost::bind(&data::\_name, \_1), boost::bind(&data::\_name, \_2)));//возростание
              break;
            }
          default:
            {break;}
          }
          ListView\_RedrawItems(hwnd, 0, directory.size() - 1);
          UpdateWindow(hwnd);
          break;
        }
      }
    }
    

    default:
    return FALSE;
    }
    }

    i don't understand why??

    B M 2 Replies Last reply
    0
    • M Member 10402390

      i try sort virtual list-view with click on column title but when i click nothing happens this dialog procedure:

      BOOL CALLBACK DlgProc(HWND hwnd,UINT msg, WPARAM wParam,LPARAM lParam)
      {
      static HWND hWndList = 0;

      switch(msg)
      {
      case WM_INITDIALOG:
      {
      hWndList= CreateWindowEx(0, WC_LISTVIEW, NULL,
      WS_CHILD|WS_BORDER|WS_VISIBLE|LVS_OWNERDATA|LVS_REPORT,
      20, 20, 620, 300, hwnd, NULL, hInstance,NULL);

        //заголовок
        LV\_COLUMN lvc;
        ZeroMemory(&lvc,sizeof(lvc));
      
        lvc.mask=LVCF\_FMT|LVCF\_SUBITEM|LVCF\_TEXT|LVCF\_WIDTH;
        lvc.fmt=LVCFMT\_LEFT;//выравнивание
        
        lvc.cx=150;
        lvc.pszText=(LPSTR)"имя файла";
        ListView\_InsertColumn(hWndList,0,&lvc);
      
        ListView\_SetItemCount(hWndList,directory.size());
        return TRUE;
      }
      

      case WM_COMMAND:
      switch(LOWORD(wParam))
      {
      case IDOK:
      case IDCANCEL:
      EndDialog(hwnd,0);
      return true;
      }

      case WM_NOTIFY:
      {
      switch (((LPNMHDR)lParam)->code)
      {
      case LVN_GETDISPINFO:
      {
      NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;

            switch (plvdi->item.iSubItem)
            {
            case 0:
              {
                plvdi->item.pszText = (LPSTR)directory\[plvdi->item.iItem\].\_name.c\_str();//"имя файла"
                break;
              }
            default:
              break;
            }
          }
      
          case LVN\_COLUMNCLICK:
          {
            LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
            //NM\_LISTVIEW \*pnmv= (NM\_LISTVIEW\*)lParam;
            switch (pnmv->iSubItem)
            {
            case 0:
              {
                //"имя файла"
                sort(directory.begin(), directory.end(), boost::bind(less(), boost::bind(&data::\_name, \_1), boost::bind(&data::\_name, \_2)));//возростание
                break;
              }
            default:
              {break;}
            }
            ListView\_RedrawItems(hwnd, 0, directory.size() - 1);
            UpdateWindow(hwnd);
            break;
          }
        }
      }
      

      default:
      return FALSE;
      }
      }

      i don't understand why??

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Did you debug it? Do you reach the lines of code you expected? If not, how far do you get?

      M 1 Reply Last reply
      0
      • B Bernhard Hiller

        Did you debug it? Do you reach the lines of code you expected? If not, how far do you get?

        M Offline
        M Offline
        Member 10402390
        wrote on last edited by
        #3

        constantly are sent LVN_COLUMNCLICK, and the list is constantly being updated

        1 Reply Last reply
        0
        • M Member 10402390

          i try sort virtual list-view with click on column title but when i click nothing happens this dialog procedure:

          BOOL CALLBACK DlgProc(HWND hwnd,UINT msg, WPARAM wParam,LPARAM lParam)
          {
          static HWND hWndList = 0;

          switch(msg)
          {
          case WM_INITDIALOG:
          {
          hWndList= CreateWindowEx(0, WC_LISTVIEW, NULL,
          WS_CHILD|WS_BORDER|WS_VISIBLE|LVS_OWNERDATA|LVS_REPORT,
          20, 20, 620, 300, hwnd, NULL, hInstance,NULL);

            //заголовок
            LV\_COLUMN lvc;
            ZeroMemory(&lvc,sizeof(lvc));
          
            lvc.mask=LVCF\_FMT|LVCF\_SUBITEM|LVCF\_TEXT|LVCF\_WIDTH;
            lvc.fmt=LVCFMT\_LEFT;//выравнивание
            
            lvc.cx=150;
            lvc.pszText=(LPSTR)"имя файла";
            ListView\_InsertColumn(hWndList,0,&lvc);
          
            ListView\_SetItemCount(hWndList,directory.size());
            return TRUE;
          }
          

          case WM_COMMAND:
          switch(LOWORD(wParam))
          {
          case IDOK:
          case IDCANCEL:
          EndDialog(hwnd,0);
          return true;
          }

          case WM_NOTIFY:
          {
          switch (((LPNMHDR)lParam)->code)
          {
          case LVN_GETDISPINFO:
          {
          NMLVDISPINFO* plvdi = (NMLVDISPINFO*)lParam;

                switch (plvdi->item.iSubItem)
                {
                case 0:
                  {
                    plvdi->item.pszText = (LPSTR)directory\[plvdi->item.iItem\].\_name.c\_str();//"имя файла"
                    break;
                  }
                default:
                  break;
                }
              }
          
              case LVN\_COLUMNCLICK:
              {
                LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
                //NM\_LISTVIEW \*pnmv= (NM\_LISTVIEW\*)lParam;
                switch (pnmv->iSubItem)
                {
                case 0:
                  {
                    //"имя файла"
                    sort(directory.begin(), directory.end(), boost::bind(less(), boost::bind(&data::\_name, \_1), boost::bind(&data::\_name, \_2)));//возростание
                    break;
                  }
                default:
                  {break;}
                }
                ListView\_RedrawItems(hwnd, 0, directory.size() - 1);
                UpdateWindow(hwnd);
                break;
              }
            }
          }
          

          default:
          return FALSE;
          }
          }

          i don't understand why??

          M Offline
          M Offline
          Malli_S
          wrote on last edited by
          #4

          It seems that you're missing 'break' for

          case LVN_GETDISPINFO:

          switch block.

          [Delegates]      [Virtual Desktop]      [Tray Me !]
          -Malli...! :rose:****

          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