为什么不能向组合框添加字符串? VS C++
Why cannot add strings to combo box? VS C++
当我启动我的应用程序并单击“触发器”选项卡时,几乎没有 select 框应该加载项目列表。有一个内置函数可以工作(如果你从菜单中打开场景文件 testscen.scx 然后单击单位选项卡,你可以检查它,所以函数 ret = Units_HandleInit(dialog);
调用 Combo_Fill(dialog, IDC_U_TYPE, esdata.unitgroups.head(), L"All");
加载数据输入 selectbox (view/editunits.cpp).
当文件未加载时,所以我想在模块 view/edittriggers2.cpp 中做类似的事情 - 有函数 BOOL Handle_WM_INITDIALOG2(HWND dialog)
BOOL Handle_WM_INITDIALOG2(HWND dialog)
{
LCombo_Fill(dialog, IDC_T_UCLASS1, esdata.unitgroups.head(), L"All");
LCombo_Fill(dialog, IDC_T_UCLASS2, esdata.unitgroups.head(), L"All");
LCombo_Fill(dialog, IDC_T_UCLASS3, esdata.unitgroups.head(), L"All");
return TRUE;
}
调用 LCombo_Fill(dialog, IDC_T_UCLASS1, esdata.unitgroups.head(), L"All");
但不幸的是,唯一的项目添加了 "All"。我不明白这是为什么,添加了第一个,而没有添加其余项目?我可以调试它并通过函数中的循环来检查是否有消息发送来添加字符串。
esdata.unitgroups.head() returns link.
When I debug the LCombo_Fill so it first jumps to [code]
template <class T> T * LinkList<T>::head()
{
return _head;
}
然后到
inline LRESULT LCombo_Fill(HWND dialog, int id, const Link * list,
const wchar_t * nosel = NULL)
{
return LinkComboBox_Fill(GetDlgItem(dialog, id), list, NULL, nosel);
}
list 是完全有效的单位类型列表。我用 Units 检查了地址和值,这是正确的。
鼻子是 "All"
然后到:
LRESULT Combo_AddW(HWND combobox, LPCWSTR string, const void * data)
{
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
return index;
}
然后到:
int LinkComboBox_Fill(HWND combobox, const Link *list, const Link *select,
const wchar_t * nosel)
{
int ret = -1;
SendMessage(combobox, CB_RESETCONTENT, 0, 0);
if (nosel)
Combo_AddW(combobox, nosel, NULL);
for (; list; list = list->next())
{
LRESULT index = Combo_AddW(combobox, list->name(), list);
if (list == select)
{
SendMessage(combobox, CB_SETCURSEL, index, 0);
ret = index;
}
}
if (ret == -1 && nosel)
{
SendMessage(combobox, CB_SETCURSEL, 0, 0);
ret = 0;
}
return ret;
}
然后到:
LRESULT Combo_AddW(HWND combobox, LPCWSTR string, const void * data)
{
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
return index;
}
最后:
inline LRESULT Combo_SetItemData(HWND control, WPARAM index, const void * ptr)
{
// LPARAM is defined as a LONG_PTR by the documentation. Hopefully that
// won't change.
return SendMessageW(control, CB_SETITEMDATA, index,
reinterpret_cast<LPARAM>(ptr));
}
// (the comments above are not of me)
ptr 是 0x00000000
然后在循环中调用相同的函数:
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
所以我需要帮助找出组合框未填充通过循环传递的值的原因。
注意:
在循环中调试:
res = SendMessageW(control, CB_ADDSTRING, 0, (LPARAM)string);
res 为 1
LRESULT index = Combo_AddStringW(combobox, string);
结果为1(看起来像索引,循环时增加)
在Combo_SetItemData中:
LRESULT res = SendMessageW(control, CB_SETITEMDATA, index,
reinterpret_cast<LPARAM>(ptr));
res 为 1
程序不是我写的,源代码比较复杂。我无法简化它,但是有人知道为什么除了第一项之外没有添加这些项目吗? None 个应添加到组合框的项目已添加。
项目link:
http://sourceforge.net/projects/autots/files/AOKTS%20update/aokts-1.0.1%20r72%20update_test.zip/download
项目文件名:aokts.sln
调整组合框的大小以查看其他添加内容。如果资源文件中有对话框,您可以单击组合框的箭头并在那里调整它的大小。
当我启动我的应用程序并单击“触发器”选项卡时,几乎没有 select 框应该加载项目列表。有一个内置函数可以工作(如果你从菜单中打开场景文件 testscen.scx 然后单击单位选项卡,你可以检查它,所以函数 ret = Units_HandleInit(dialog);
调用 Combo_Fill(dialog, IDC_U_TYPE, esdata.unitgroups.head(), L"All");
加载数据输入 selectbox (view/editunits.cpp).
当文件未加载时,所以我想在模块 view/edittriggers2.cpp 中做类似的事情 - 有函数 BOOL Handle_WM_INITDIALOG2(HWND dialog)
BOOL Handle_WM_INITDIALOG2(HWND dialog)
{
LCombo_Fill(dialog, IDC_T_UCLASS1, esdata.unitgroups.head(), L"All");
LCombo_Fill(dialog, IDC_T_UCLASS2, esdata.unitgroups.head(), L"All");
LCombo_Fill(dialog, IDC_T_UCLASS3, esdata.unitgroups.head(), L"All");
return TRUE;
}
调用 LCombo_Fill(dialog, IDC_T_UCLASS1, esdata.unitgroups.head(), L"All");
但不幸的是,唯一的项目添加了 "All"。我不明白这是为什么,添加了第一个,而没有添加其余项目?我可以调试它并通过函数中的循环来检查是否有消息发送来添加字符串。
esdata.unitgroups.head() returns link.
When I debug the LCombo_Fill so it first jumps to [code]
template <class T> T * LinkList<T>::head()
{
return _head;
}
然后到
inline LRESULT LCombo_Fill(HWND dialog, int id, const Link * list,
const wchar_t * nosel = NULL)
{
return LinkComboBox_Fill(GetDlgItem(dialog, id), list, NULL, nosel);
}
list 是完全有效的单位类型列表。我用 Units 检查了地址和值,这是正确的。 鼻子是 "All"
然后到:
LRESULT Combo_AddW(HWND combobox, LPCWSTR string, const void * data)
{
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
return index;
}
然后到:
int LinkComboBox_Fill(HWND combobox, const Link *list, const Link *select,
const wchar_t * nosel)
{
int ret = -1;
SendMessage(combobox, CB_RESETCONTENT, 0, 0);
if (nosel)
Combo_AddW(combobox, nosel, NULL);
for (; list; list = list->next())
{
LRESULT index = Combo_AddW(combobox, list->name(), list);
if (list == select)
{
SendMessage(combobox, CB_SETCURSEL, index, 0);
ret = index;
}
}
if (ret == -1 && nosel)
{
SendMessage(combobox, CB_SETCURSEL, 0, 0);
ret = 0;
}
return ret;
}
然后到:
LRESULT Combo_AddW(HWND combobox, LPCWSTR string, const void * data)
{
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
return index;
}
最后:
inline LRESULT Combo_SetItemData(HWND control, WPARAM index, const void * ptr)
{
// LPARAM is defined as a LONG_PTR by the documentation. Hopefully that
// won't change.
return SendMessageW(control, CB_SETITEMDATA, index,
reinterpret_cast<LPARAM>(ptr));
}
// (the comments above are not of me)
ptr 是 0x00000000
然后在循环中调用相同的函数:
LRESULT index = Combo_AddStringW(combobox, string);
Combo_SetItemData(combobox, index, data);
所以我需要帮助找出组合框未填充通过循环传递的值的原因。
注意:
在循环中调试:
res = SendMessageW(control, CB_ADDSTRING, 0, (LPARAM)string);
res 为 1
LRESULT index = Combo_AddStringW(combobox, string);
结果为1(看起来像索引,循环时增加)
在Combo_SetItemData中:
LRESULT res = SendMessageW(control, CB_SETITEMDATA, index,
reinterpret_cast<LPARAM>(ptr));
res 为 1
程序不是我写的,源代码比较复杂。我无法简化它,但是有人知道为什么除了第一项之外没有添加这些项目吗? None 个应添加到组合框的项目已添加。
项目link: http://sourceforge.net/projects/autots/files/AOKTS%20update/aokts-1.0.1%20r72%20update_test.zip/download 项目文件名:aokts.sln
调整组合框的大小以查看其他添加内容。如果资源文件中有对话框,您可以单击组合框的箭头并在那里调整它的大小。