⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index186.htm

📁 关于vc的一本问题集,很不错的,有很多精采的问题
💻 HTM
字号:
<html>
<style type="text/css"><!--
.p9 {  font-family: "宋体"; font-size: 9pt}a        {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../../../backg.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">自画列表框样例</font></td></tr>
<tr><td><p>
</Br>
很久以前,有人散发关于自画列表框控件代码,而自画列表框外观就象一个标准列表框,在那时我就有个想法想把程序员开发的所有自画控件的代码惧收集起来,这样程序员们就可以使用现存的代码了。<Br>
我想问一下在1996年关于MFC站点那儿有才能关于列表框或其它控件的代码?<Br>
</Br>
1)自画列表框代码如下,看看是不是你所想要的。<Br>
</Br>
Header file<Br>
</Br>
class CCustomListBox : public CListBox<Br>
{<Br>
public:<Br>
// Operations<Br>
&nbsp;&nbsp;&nbsp;&nbsp;DECLARE_DYNCREATE(CCustomListBox)<Br>
&nbsp;&nbsp;&nbsp;&nbsp;int AddLBItem(LPSTR);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;void HandleSelectionState(LPDRAWITEMSTRUCT lpdis);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;void HandleFocusState(LPDRAWITEMSTRUCT lpdis);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);<Br>
};<Br>
</Br>
cpp file<Br>
</Br>
IMPLEMENT_DYNCREATE(CCustomListBox, CListBox)<Br>
</Br>
int CCustomListBox::AddLBItem(LPSTR itemStr)<Br>
{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;AddString((LPCSTR)itemStr);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;return 0;<Br>
}<Br>
</Br>
void CCustomListBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)<Br>
{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;CDC* pDC = CDC::FromHandle(lpDIS->hDC);<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;if ((lpDIS->itemState & ODS_SELECTED) &&<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))<Br>
&nbsp;&nbsp;&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC->InvertRect(&lpDIS->rcItem);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC->DrawFocusRect(&lpDIS->rcItem);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;}<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;if (!(lpDIS->itemState & ODS_SELECTED) &&<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(lpDIS->itemAction & ODA_SELECT))<Br>
&nbsp;&nbsp;&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC->InvertRect(&lpDIS->rcItem);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC->DrawFocusRect(&lpDIS->rcItem);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;}<Br>
}<Br>
</Br>
void CCustomListBox::HandleSelectionState(LPDRAWITEMSTRUCT lpdis)<Br>
{<Br>
// Ordinarily could check for "if (lpdis->itemState & ODS_SELECTED)"<Br>
// and do drawing for selected state, "else" draw non-selected state.<Br>
// But second call to InvertRect restores rectangle to original<Br>
// state, so will just call function whether selected or unselected.<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;::InvertRect (lpdis->hDC, (LPRECT)&lpdis->rcItem);<Br>
}<Br>
</Br>
void CCustomListBox::HandleFocusState(LPDRAWITEMSTRUCT lpdis)<Br>
{<Br>
// Ordinarily would check for "if (lpdis->itemState & ODS_FOCUS)"<Br>
// and do drawing for focus state, "else" draw non-focus state.<Br>
// But second call to DrawFocusRect restores rectangle to original<Br>
// state, so will just call function whether focus or non-focus.<Br>
// New to Windows 3.0, this function draws a black dashed-rect<Br>
// border on the border of the specified rectangle<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;::DrawFocusRect( lpdis->hDC, (LPRECT) &lpdis->rcItem );<Br>
}<Br>
2)http://toronto.planeteer.com/~zalmoxe/<Br>
</Br>
</p></td></tr>
</table><p align="center"><img src="../../../logo.gif" align="center"><center><table><tr><td><a href="http://www.ourcode.net" target=_top>www.OurCode.net</a><Br>版权所有: 2002-2008</a></td></tr></table></center></p>
</body><SCRIPT LANGUAGE='JavaScript' SRC='../../../navigate_bar.js'></SCRIPT><SCRIPT LANGUAGE='JavaScript'>write_tail();</SCRIPT></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -