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

📄 listviewdlg.cpp

📁 wince list control based on vs2005
💻 CPP
字号:
// ListViewDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ListView.h"
#include "ListViewDlg.h"
 
#include "JWListCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CListViewDlg dialog

CListViewDlg::CListViewDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CListViewDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CListViewDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CListViewDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListViewDlg)
	DDX_Control(pDX, IDC_LIST1, m_cListCtrl);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListViewDlg, CDialog)
	//{{AFX_MSG_MAP(CListViewDlg)
	ON_WM_PAINT()
	ON_WM_CANCELMODE()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_WM_ACTIVATE()
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_WM_PALETTECHANGED()
	ON_WM_QUERYNEWPALETTE()
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnInitVScroll)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListViewDlg message handlers

BOOL CListViewDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
 	DWORD dwStyle = m_cListCtrl.GetExtendedStyle();
	dwStyle |= LVS_EX_FULLROWSELECT | LVS_ALIGNTOP | WS_HSCROLL  ;

	//DWORD   dwStyle   =   m_cListCtrl.GetStyle();   
    //dwStyle   &=   ~0x0001;   
   
    ::SetWindowLong(m_cListCtrl.m_hWnd,   GWL_STYLE,   dwStyle);
	//::SetWindowLong( m_cListCtrl.GetSafeHwnd(), GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_HSCROLL ); 

	//m_cListCtrl.ShowScrollBar(TRUE);   
	//m_cListCtrl.SetBkColor( RGB(0,150,0) );

	m_cListCtrl.SetExtendedStyle(dwStyle);


	m_cListCtrl.InsertImgTextItems(IDB_IMAGES_NORMAL , 32, 32, 4,L"My Items1");

	m_cListCtrl.InsertImgTextItems(IDB_IMAGES_NORMAL , 32 ,32, 3,L"My Items4");

	m_cListCtrl.InsertImgTextItems(IDB_IMAGES_NORMAL , 32 ,32, 2,L"My Items3");
 
 	m_cListCtrl.InsertImgTextItems(IDB_IMAGES_NORMAL , 32, 32, 1,L"My Items2");

	m_cListCtrl.InsertImgTextItems(IDB_IMAGES_NORMAL , 32, 32, 0,L"My Items1");

//	m_cListCtrl.SetBkColor(RGB(0,150,0));

	m_cListCtrl.SetBkColor(ILD_TRANSPARENT);
	
 	m_cListCtrl.ModifyStyle(0,LVS_SINGLESEL);
	
	//m_cListCtrl.ModifyStyle(0,LVS_NOSCROLL);
	
	m_cListCtrl.SetTextBkColor(CLR_NONE);
	
	m_cListCtrl.SetBkImage(IDB_IMAGES_BK);

//	m_cListCtrl.ShowScrollBar( FALSE );


	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CListViewDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		//SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}	
	// Do not call CDialog::OnPaint() for painting messages
}

void CListViewDlg::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

 
void CListViewDlg::OnButton1() 
{
	m_cListCtrl.InsertImgTextItems( IDB_IMAGES_NORMAL , 32 ,32,4,L"NewICON");

}


void CListViewDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
}

void CListViewDlg::OnButton2() 
{
	newlist = new CJWListCtrl;
 
	newlist->Create(   WS_VISIBLE | LVS_ICON /*| LVS_NOSCROLL*/ ,
					CRect(0,0,180,150), this , 1);

	/*CRgn ListRgn;
	ListRgn.CreateRectRgn(0,0,170,150);
	newlist->SetWindowRgn(ListRgn, TRUE);
	ListRgn.DeleteObject();*/
	
	newlist->SetTextBkColor(CLR_NONE);	

	newlist->ShowScrollBar( FALSE );

	newlist->SetBkImage(IDB_IMAGES_BK);

	newlist->InitVScroll();
	//newlist->ModifyStyle(0,LVS_NOSCROLL);
	newlist->ShowScrollBar( FALSE );

	//InitializeFlatSB(newlist->m_hWnd);
	//newlist->EnableScrollBar(newlist->m_hWnd, SB_BOTH, ESB_DISABLE_BOTH);
	
	newlist->EnableScrollBarCtrl(SB_HORZ,FALSE);   

	newlist->EnableScrollBarCtrl(SB_VERT,FALSE);   

	CScrollBar * pBar = newlist->GetScrollBarCtrl(SB_VERT);//SB_VERT
	if(pBar)
		pBar->ShowWindow(SW_HIDE);
	

	newlist->InsertImgTextItems(IDB_IMAGES_NORMAL , 32 ,32, 6,L"New Items");
}

void CListViewDlg::OnButton3() 
{
	if(newlist!=NULL)
		newlist->InsertImgTextItems(IDB_IMAGES_NORMAL , 32 ,32, 4,L"New Items");	
}

void CListViewDlg::OnPaletteChanged(CWnd* pFocusWnd) 
{
	CDialog::OnPaletteChanged(pFocusWnd);
	
	m_cListCtrl.SendMessage( WM_PALETTECHANGED, (WPARAM)pFocusWnd->m_hWnd );	
}

BOOL CListViewDlg::OnQueryNewPalette() 
{

	CDialog::OnQueryNewPalette();

	return m_cListCtrl.SendMessage( WM_QUERYNEWPALETTE );
}


void CListViewDlg::OnButton4() 
{
	m_cListCtrl.LineDown();
}



void CListViewDlg::OnInitVScroll() 
{
 	
}

⌨️ 快捷键说明

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