刚才没说清楚,再问一次
我用下面的代码好像不行
long styleValue = GetWindowLong(hList, GWL_STYLE);
styleValue &= (~LBS_SORT);
SetWindowLong(hList, GWL_STYLE, styleValue);
RECT rc;
GetClientRect(hList, &rc);
// make set take effect
SetWindowPos(hList, HWND_TOP, rc.left, rc.top, rc.right, rc.bottom, SWP_FRAMECHANGED); // disable controls
EnableWindow(hList, FALSE);不使用CListBox
做过的人请举手,谢谢

解决方案 »

  1.   

    补充:我想把一个有LBS_SORT风格的ListBox改成不排序的
      

  2.   

    WNDPROC wpOrigEditProc; 
     
    LRESULT APIENTRY EditBoxProc(
        HWND hwndDlg, 
        UINT uMsg, 
        WPARAM wParam, 
        LPARAM lParam) 

        HWND hwndEdit; 
     
        switch(uMsg) 
        { 
            case WM_INITDIALOG: 
                // Retrieve the handle to the edit control. 
                hwndEdit = GetDlgItem(hwndDlg, ID_EDIT); 
     
                // Subclass the edit control. 
                wpOrigEditProc = (WNDPROC) SetWindowLong(hwndEdit, 
                    GWL_WNDPROC, (LONG) EditSubclassProc); 
                // 
                // Continue the initialization procedure. 
                // 
                return TRUE; 
     
            case WM_DESTROY: 
                // Remove the subclass from the edit control. 
                SetWindowLong(hwndEdit, GWL_WNDPROC, 
                    (LONG) wpOrigEditProc); 
                // 
                // Continue the cleanup procedure. 
                // 
                break; 
        } 
        return FALSE; 
            UNREFERENCED_PARAMETER(lParam); 

     
    // Subclass procedure 
    LRESULT APIENTRY EditSubclassProc(
        HWND hwnd, 
        UINT uMsg, 
        WPARAM wParam, 
        LPARAM lParam) 

        if (uMsg == WM_GETDLGCODE) 
            return DLGC_WANTALLKEYS; 
     
        return CallWindowProc(wpOrigEditProc, hwnd, uMsg, 
            wParam, lParam); 
    }
      

  3.   

    It is not possible to change these styles at runtime even though ModifyStyle() may give the impression it does. If you want turn the Sort style on and off for example it is best to construct the List box by calling new and Create then deleting it and creating a new one when the style is to be changed
      

  4.   

    请参考:http://www.codeproject.com/combobox/recreatelistbox.asp的一个例子,可以对其中的代码做一些修改,估计应该可以满足你的要求
    祝楼主成功
    ^_^
      

  5.   

    多谢 flyelf(空谷清音)
    看来暂时只有recreate了,要是有什么好办法都贴出来啊。