组合框的下拉列表没有显示通过SendMessage()添加到它的项目 [英] Drop down list of combo box is not showing item added to it by SendMessage()
本文介绍了组合框的下拉列表没有显示通过SendMessage()添加到它的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下拉列表框列表不显示SendMessage()添加到它的项目
这是包含组合框的对话框
Drop down list of combo box is not showing item added to it by SendMessage()
This is Dialog box which contains combo box
BOOL CALLBACK AddRuleDlgProc (HWND hAddRuleDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
const char *ComboBoxItem[] = {"All","TCP","UDP","ICMP"};
case WM_INITDIALOG :
for(i=0;i<3;i++)
{ SendMessage((GetDlgItem(hAddRuleDlg,IDC_COMBO4)),CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCSTR)ComboBoxItem[i]));
}
return TRUE ;
}
这是组合框的资源
This is resource of combo box
COMBOBOX IDC_COMBO4,81,151,44,49,CBS_DROPDOWNLIST | CBS_OWNERDRAWVARIABLE | WS_VSCROLL | WS_TABSTOP
请尽快给我帮忙
Please help me asap
推荐答案
您正在使用CBS_OWNERDRAWVARIABLE
(请参阅 ^ ]),这意味着在显示或更新组合框时,您可以按需提供列表项.删除此选项,然后重试.
You are using CBS_OWNERDRAWVARIABLE
(see here[^]) which means that you are expected to supply the items for the list on demand when the combobox is dispalyed or updated. Remove this option and try again.
如果您需要使用ownerdrawn样式(因此按照Richard的建议将其删除对您不起作用),然后尝试添加CBS_HASSTRINGS(组合框样式 [
If you need to use the ownerdrawn-style (so removing it as Richard suggested won''t work for you) then try adding CBS_HASSTRINGS (Combo-Box Styles[^].
你能试试吗..
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast< LPARAM> LPCTSTR)ComboBoxItem [0])));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast< LPARAM>(((LPCTSTR)ComboBoxItems [1]));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast< LPARAM>(((LPCTSTR)ComboBoxItems [2]));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast< LPARAM>((LPCTSTR)ComboBoxItems [3]));
Can u try this..
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast<LPARAM>LPCTSTR)ComboBoxItem[0]));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast<LPARAM>((LPCTSTR)ComboBoxItems[1]));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast<LPARAM>((LPCTSTR)ComboBoxItems[2]));
SendMessage(hWndComboBox,CB_ADDSTRING,0,
reinterpret_cast<LPARAM>((LPCTSTR)ComboBoxItems[3]));
这篇关于组合框的下拉列表没有显示通过SendMessage()添加到它的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文