tooltiplistbox.cpp

来自「xlan 获得 ipmac」· C++ 代码 · 共 77 行

CPP
77
字号
// ToolTipListBox.cpp : implementation file
//

#include "stdafx.h"
#include "xLANInfo.h"
#include "ToolTipListBox.h"

#include "xLANInfoDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CToolTipListBox

CToolTipListBox::CToolTipListBox()
{
}

CToolTipListBox::~CToolTipListBox()
{
}


BEGIN_MESSAGE_MAP(CToolTipListBox, CListBox)
	//{{AFX_MSG_MAP(CToolTipListBox)
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolTipListBox message handlers

void CToolTipListBox::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	int n;
	CPoint ThePoint( point );
	CString str;

	n = SendMessage( LB_ITEMFROMPOINT,0,MAKELPARAM( ThePoint.x,ThePoint.y ) );
	if( !HIWORD( n ) ) {
		CToolInfo tif;
		( ( CXLANInfoDlg * )GetParent() )->m_tip.GetToolInfo( tif,this );
		GetText( n,str );
		lstrcpy( tif.lpszText,str );
		( ( CXLANInfoDlg * )GetParent() )->m_tip.SetToolInfo( &tif );
	}
	
	CListBox::OnMouseMove(nFlags, point);
}

#include "xLANInfo.h"
int CToolTipListBox::AddStringEx(LPCTSTR lpszItem)
{
	// Find the longest string in the list box.
	CString str;
	CSize sz;
	static int dx = 0;
	CDC* pDC = this->GetDC();

	str = lpszItem;
	sz = pDC->GetTextExtent( str );
	if( sz.cx > dx ) {
		dx = sz.cx * LOWORD( ( ( CXLANInfoApp* )AfxGetApp() )->dwBaseUnits ) / 4;
	}
	ReleaseDC( pDC );

	// Set the horizontal extent so every character of all strings 
	// can be scrolled to.
	SetHorizontalExtent( dx );
	return AddString( lpszItem );
}

⌨️ 快捷键说明

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