MFC在WinCE平台上Combobox.Getcursel()怎么用

jittuo 2009-08-14 09:30:48
首先我在MFC Application 创建的组合框,然后用Combobox.Getcursel()得到所选择的光标运行正确。由于我是在wince平台上要进行程序移植,所以但当使用MFC smart device Application 工程时 将会弹出错误框,调试运行错误就出现在combox.Getcursel()这句;不知何解?最后查到有getcursor()这个函数,但是也是错误,请大虾赐教。
问题补充:问题是在mfc工程里得到combo box光标用combox.Getcursel()函数没错,可以实现该功能;但是到MFC smart device Application 工程时在该处就弹出错误对话框,问了些同事,说wince平台对一些MFC的函数不支持。所以现在是想在MFC smart device Application 工程里实现该功能,怎么办?
...全文
418 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2009-08-14
  • 打赏
  • 举报
回复
我是说能不能得到listbox,然后从listbox入手。
//http://support.microsoft.com/default.aspx?scid=kb;en-us;Q174667
//While it is simple to directly subclass a combo box control,
//it is not simple to subclass the edit or list box inside a combo box.
//The problem is that it is difficult to get the HWNDs of the child controls
//in a portable manner.

//One safe way to subclass the internal edit and list box controls is to subclass them
//in the WM_CTLCOLOR messages.
//Because Win32 sends separate WM_CTLCOLOREDIT and WM_CTLCOLORLISTBOX messages,
//these messages are safe and easy ways to get the HWNDs of the child controls of the combo box.

//Below is a CSuperComboBox class, which is an MFC implementation of this method.
//Because MFC routes all the WM_CTLCOLOR messages to OnCtlColor, the subclassing takes place there.
//
HBRUSH CMyComboDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
if (nCtlColor == CTLCOLOR_LISTBOX)
{//ListBox control
CWnd *pCombo2=GetDlgItem(IDC_COMBO2);
CWnd *pListParent=pWnd->GetOwner();
if(pListParent==pCombo2)
{
if(!m_listbox)
{
if (m_listbox.GetSafeHwnd() == NULL)
{
m_listbox.SubclassWindow(pWnd->GetSafeHwnd());
//
m_listbox.ModifyStyle(WS_VSCROLL,WS_HSCROLL|LBS_MULTICOLUMN);
m_listbox.SetHorizontalExtent(400);
m_listbox.SetColumnWidth(100);
}
}
}
}
// TODO: Return a different brush if the default is not desired
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
有了handle就好办了。
jittuo 2009-08-14
  • 打赏
  • 举报
回复
我是添加了一个Combo box全局变量a,然后通过a.getcursel()得到选择光标,但在MFC smart device Application 工程上运行就报错了,请详细解释下您怎们做?
schlafenhamster 2009-08-14
  • 打赏
  • 举报
回复
combox由edit和listbox组成,看看能不能从listbox入手。

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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