ListBox排序的一个问题
在对话框资源中,画一个ListBox,其ID为IDC_LIST1,在“List Box Properties”对话框中去掉sort勾选
BOOL CTestDlg::OnInitDialog()
{
CListBox* pList=(CListBox*)GetDlgItem(IDC_LIST1);
pList->AddString("5");
pList->AddString("2");
pList->AddString("4");
pList->AddString("3");
pList->AddString("1");
}
项在一个按钮中来对ListBox内容排序
void CTestDlg::OnSort()
{
CListBox* pList=(CListBox*)GetDlgItem(IDC_LIST1);
DWORD style=GetWindowLong(pList->m_hWnd,GWL_STYLE);
style|=LBS_SORT ;
SetWindowLong(pList->m_hWnd,GWL_STYLE,style);
}
为什么无法成功?