我有个自绘的ListBox,我在DrawItem里面
void CMyListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dcItem;
dcItem.Attach(lpDrawItemStruct->hDC); CRect rcItem = lpDrawItemStruct->rcItem;
UINT nIndex = lpDrawItemStruct->itemID; if (nIndex != (UINT)-1) {
TRACE(L"nIndex is : %d\n", nIndex);
dcItem.FillSolidRect(rcItem + CRect(0, 0, 0, -2), RGB(192,192,192));
}
}我在对话框上面
BOOL CTestListBox111Dlg::OnInitDialog()
{
....
m_listCorrectAnswer.AddString(L"000");
m_listCorrectAnswer.AddString(L"111");
m_listCorrectAnswer.AddString(L"222");
....
return TRUE; // return TRUE unless you set the focus to a control
}我又加了个void CTestListBox111Dlg::OnBnClickedButton1()
{
m_listCorrectAnswer.ResetContent();
Invalidate();
}我想在我单击按钮后,ListBox内容不见了,我们都知道。我还想在ListBox没有Item的时候,自动绘黄色背景,如何做呢???
void CMyListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dcItem;
dcItem.Attach(lpDrawItemStruct->hDC); CRect rcItem = lpDrawItemStruct->rcItem;
UINT nIndex = lpDrawItemStruct->itemID; if (nIndex != (UINT)-1) {
TRACE(L"nIndex is : %d\n", nIndex);
dcItem.FillSolidRect(rcItem + CRect(0, 0, 0, -2), RGB(192,192,192));
}
}我在对话框上面
BOOL CTestListBox111Dlg::OnInitDialog()
{
....
m_listCorrectAnswer.AddString(L"000");
m_listCorrectAnswer.AddString(L"111");
m_listCorrectAnswer.AddString(L"222");
....
return TRUE; // return TRUE unless you set the focus to a control
}我又加了个void CTestListBox111Dlg::OnBnClickedButton1()
{
m_listCorrectAnswer.ResetContent();
Invalidate();
}我想在我单击按钮后,ListBox内容不见了,我们都知道。我还想在ListBox没有Item的时候,自动绘黄色背景,如何做呢???
解决方案 »
- mfc 视频截图可以保存在硬盘上了,怎样按保存的时候在指定区域显示出来。
- MFC程序主界面只能通过写代码来完成吗?
- 这种情况下如何调试?
- 关于画笔的问题
- 关于CreateView(...)的第四个参数SIZE sizeInit的问题,查完csdn和msdn的疑惑??
- 我再問::::為什麼我的派生按鈕的自畫ownerdraw功能總是出錯?
- =====================这个问题对我来说太难了=========================
- 高手请教:如何调用动态链接库中的对话框?
- 如何判断CString里的数据是否是常数?
- 高分求助,看过cloudshadow1(小强)网络播放器代码都进来,分数不够可再加,决不食言。
- 如何实现MFC对话框中点击最小化,在任务栏右下角有一个小图标生成??
- 在win7下用socket下载文件报错
onerasebkgnd
在这两个里面试试!