VC++控件之多目标关联
来源:互联网 发布:mac qq截屏 编辑:程序博客网 时间:2024/06/08 10:31
一、新建工程
二、编辑对话框资源
三、添加变量、结构、函数
1、添加变量
2、添加结构
3、添加函数
三、添加代码(红色部分)
1、添加“初始化”代码
BOOL CCListBoxDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
struct student str[3]={"常胜","生产","010","黄河","人事","011","李凌","质检","022"};
int index;
DWORD index2[3]={1,2,3};
index=m_ListBox.AddString(str[0].name);
m_ListBox.SetItemData(index,index2[0]);
index=m_ListBox.AddString(str[1].name);
m_ListBox.SetItemData(index,index2[1]);
index=m_ListBox.AddString(str[2].name);
m_ListBox.SetItemData(index,index2[2]);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
2、添加函数代码
void CCListBoxDlg::OnSelchangeList1()
{
// TODO: Add your control notification handler code here
struct student str[3]={"常胜","生产","010","黄河","人事","011","李凌","质检","022"};
int index,i;
DWORD index2;
index=m_ListBox.GetCurSel();
m_ListBox.GetText(index,m_name);
index2=m_ListBox.GetItemData(index);
switch (index2)
{
case 1:
i=0;
break;
case 2:
i=1;
break;
case 3:
i=2;
break;
default:i=100;
}
m_id=str[i].ID;
m_class=str[i].classnumber;
UpdateData(FALSE);
}
四、编译
五、运行
六、函数说明
1、CListBox::SetItemDataPtr函数声明
int SetItemDataPtr(int nIndex,void *pData)
nIndex:列表框内被选中列表项的索引
pData:与该列表项相关联的数据的指针
功能:将列表项中的索引和数据相关联。返回LB_ERR,则关联失败。
- VC++控件之多目标关联
- vc 动态控件的变量关联
- VC图像控件关联Halcon图像
- Hibernate关联之多对一外键单向关联
- 关联映射之多对一
- linq To SQl之多表关联修改
- linq To SQl之多表关联修改
- hibernate之多对一关联映射
- MYSQL学习之多表关联update
- Hibernate关联关系之多对一
- Hibernate关联关系之多对多
- 06-MyBatis_关联映射之多对一
- Hibernate映射之多对一关联映射
- hibernate关联关系之多对多关系
- 【Hibernate步步为营】--关联映射之多对一
- hibernate之多对一单向关联
- hibernate之多对多单向关联
- hibernate之多对多双向关联
- tftp配置
- 有用的SQL分页语句
- SqlDataAdapter隐式打开关闭connection
- VC++控件之按钮动态变化
- World Islands HDU3405 杭州省赛 最小生成树
- VC++控件之多目标关联
- VC++控件之权限设置
- 回调函数
- VC++控件之IP地址设置
- Teradata BETQ登陆
- VC++之控件编辑框的应用
- HDU 3412 杭州省赛 An Odd Award Rule
- 7条大型网站设计和维护的关键技巧(转)
- linux 下asp.net WEB应用环境的搭建