wu qi zhao ba de listview control use the sort function with SDK simple example

not comment centense is right

  case WM_CREATE:


    mybtn=CreateWindow("button","mybutton",WS_VISIBLE|WS_CHILD,440,0,100,100,hwnd,(HMENU)1000,hinst,NULL);
    lvw=CreateWindow("syslistview32","ListView",LVS_REPORT|LVS_SHOWSELALWAYS|WS_VISIBLE|WS_CHILD,10,25,240,270,hwnd,(HMENU)1001,hinst,NULL);

 lvc.mask=LVCF_TEXT|LVCF_WIDTH;
 lvc.pszText="user";
 lvc.cx=70;
 SendMessage(lvw,LVM_INSERTCOLUMN,0,(long)&lvc);
 lvc.pszText="email";
 lvc.cx=90;
 SendMessage(lvw,LVM_INSERTCOLUMN,1,(long)&lvc);
 lvc.pszText="web";
 lvc.cx=90;
 SendMessage(lvw,LVM_INSERTCOLUMN,2,(long)&lvc);
 lvc.pszText="other"; 
 lvc.cx=90;
 SendMessage(lvw,LVM_INSERTCOLUMN,3,(long)&lvc);
 lvitem.mask=LVIF_TEXT|LVIF_PARAM;

 item.column=0;

 

 

 lvitem.lParam=(DWORD)malloc(sizeof(item));
 *(useritem*)lvitem.lParam=item;
 lvitem.pszText="dsfdsf";
 lvitem.iItem=0;
 lvitem.iSubItem=0;
 strcpy(item.user,"dsfdsf");
 SendMessage(lvw,LVM_INSERTITEM,0,(long)&lvitem);
 lvitem.pszText="fdsfsdf";
 lvitem.iSubItem=1;
 SendMessage(lvw,LVM_SETITEM,0,(long)&lvitem);

 ListView_SortItems(lvw,lvwCompareProc,(LPARAM)&item);
 //if (lvitem.lParam)
 //free((void*)lvitem.lParam);


 
 //lvitem.lParam=(DWORD)malloc(sizeof(item));
 *(useritem*)lvitem.lParam=item;
 lvitem.pszText="aaaaaadsfdsf";
 lvitem.iItem=1;
 lvitem.iSubItem=0;
 strcpy(item.user,"aaaaaadsfdsf");
 lvitem.lParam=(DWORD)&item;
 SendMessage(lvw,LVM_INSERTITEM,0,(LPARAM)&lvitem);
 lvitem.pszText="aaaaaaaafdsfsdf";
 lvitem.iSubItem=1;
 SendMessage(lvw,LVM_SETITEM,1,(long)&lvitem);
 
 ListView_SortItems(lvw,lvwCompareProc,(LPARAM)&item);
 //if (lvitem.lParam)
 //free((void*)lvitem.lParam);
//lvitem.lParam=(DWORD)malloc(sizeof(item));
*(useritem*)lvitem.lParam=item;
 lvitem.pszText="31414adsfdsf";
 lvitem.iItem=2;
 lvitem.iSubItem=0;
 strcpy(item.user,"31414adsfdsf");
 *(useritem*)lvitem.lParam=item;
 SendMessage(lvw,LVM_INSERTITEM,0,(long)&lvitem);
 lvitem.pszText="435315aaaaafdsfsdf";
 lvitem.iSubItem=1;
 SendMessage(lvw,LVM_SETITEM,2,(long)&lvitem);
 
 ListView_SortItems(lvw,lvwCompareProc,(LPARAM)&item);
 //if (lvitem.lParam)
//free((void*)lvitem.lParam);

 //lvitem.lParam=(DWORD)malloc(sizeof(item));
 *(useritem*)lvitem.lParam=item;
 lvitem.pszText="zzzfdsfdsf";
 lvitem.iItem=3;
 lvitem.iSubItem=0;
 strcpy(item.user,"zzzfdsfdsf");
 *(useritem*)lvitem.lParam=item;
 SendMessage(lvw,LVM_INSERTITEM,0,(long)&lvitem);
 lvitem.pszText="zzdsfsdfaafdsfsdf";
 lvitem.iSubItem=1;
 SendMessage(lvw,LVM_SETITEM,3,(long)&lvitem);
//if (lvitem.lParam)
//free((void*)lvitem.lParam);
 //ListView_SortItems(lvw,lvwCompareProc,(LPARAM)&item);
    break;
         
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ; //开始窗口绘制
         
          GetClientR

阅读更多
想对作者说点什么? 我来说一句

lvs for linux

2009年12月29日 2KB 下载

stm32 TIM input capture

2018年04月23日 92.55MB 下载

ccproxy

2007年09月22日 1.79MB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭