📄 mylistbox.cpp
字号:
// MyListBox.cpp : implementation file
//
#include "stdafx.h"
#include "TestListBox.h"
#include "MyListBox.h"
#include "TestListBoxDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyListBox
CMyListBox::CMyListBox()
{
m_brHollow.CreateStockObject(HOLLOW_BRUSH);
iSelectChange = FALSE;
}
CMyListBox::~CMyListBox()
{
}
BEGIN_MESSAGE_MAP(CMyListBox, CListBox)
//{{AFX_MSG_MAP(CMyListBox)
ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_ERASEBKGND()
ON_WM_HSCROLL()
ON_WM_LBUTTONDOWN()
ON_WM_VSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyListBox message handlers
void CMyListBox::OnSelchange()
{
// TODO: Add your control notification handler code here
iSelectChange = TRUE;
Invalidate(TRUE);
}
HBRUSH CMyListBox::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(0,0,255));
return m_brHollow;
// TODO: Return a non-NULL brush if the parent's handler should not be called
return NULL;
}
BOOL CMyListBox::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
BITMAP bm;
m_bmp.GetBitmap(&bm);
m_pbmCurrent = &m_bmp;
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = dcMem.SelectObject(m_pbmCurrent);
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dcMem,0,0,SRCCOPY);
dcMem.SelectObject(pOldBitmap);
return CListBox::OnEraseBkgnd(pDC);
}
void CMyListBox::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
CListBox::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMyListBox::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(iSelectChange)
{
iSelectChange= FALSE;
Invalidate();
}
// CString str;
//
// int i=GetCurSel();
//
// if (i<0){
// return;
// }
//
// GetText(i,str);
//
// if ((L"txt"==str.Right(3))||(L"TXT"==str.Right(3))){
//
// ((CTestListBoxDlg*)AfxGetApp()->m_pMainWnd)->m_FilePathName="My Documents\\"+str;
// // ((CTestListBoxDlg*)AfxGetApp()->m_pMainWnd)->SerchObject.EXIT();
// // AfxMessageBox("到这");
// } else {
// return;
// }
CListBox::OnLButtonDown(nFlags, point);
}
void CMyListBox::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
Invalidate();
CListBox::OnVScroll(nSBCode, nPos, pScrollBar);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -