ListBox排序的一个问题

maoyunfeng1019 2005-03-25 01:32:48
在对话框资源中,画一个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);
}
为什么无法成功?
...全文
112 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fanqing 2005-03-25
  • 打赏
  • 举报
回复
gz
LZDGDX 2005-03-25
  • 打赏
  • 举报
回复
get之后直接set。。。。。。
有问题吧。
tropicscsdn 2005-03-25
  • 打赏
  • 举报
回复
没这么使用过,但是如果用listbox的insert方法会不会好用啊?
oyljerry 2005-03-25
  • 打赏
  • 举报
回复
应该需要重新插入内容

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧