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

📄 scrollertestdlg.cpp

📁 文本滚动控件
💻 CPP
字号:
// ScrollerTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ScrollerTest.h"
#include "ScrollerTestDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CScrollerTestDlg dialog



CScrollerTestDlg::CScrollerTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CScrollerTestDlg::IDD, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CScrollerTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CScrollerTestDlg, CDialog)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_SIZE()
END_MESSAGE_MAP()


// CScrollerTestDlg message handlers

BOOL CScrollerTestDlg::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


   // setup scroller:
   // background pattern (tileable)
   if ( ::GetTickCount()%2 )  // lazy man's rand()
   {
      m_scroller.SetPattern(CBitmap::FromHandle((HBITMAP)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BACKGROUND), IMAGE_BITMAP, 0,0, LR_SHARED)), FALSE);
      // this background should be centered over a white background
      m_scroller.SetBgColor(RGB(255,255,255));
      m_scroller.SetFgColor(RGB(0,127,0));
   }
   else
   {
      m_scroller.SetPattern(CBitmap::FromHandle((HBITMAP)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BACKGROUND2), IMAGE_BITMAP, 0,0, LR_SHARED)), TRUE);
      m_scroller.SetFgColor(RGB(255,255,225));
   }
   // logo bitmap
   m_scroller.SetLogo(CBitmap::FromHandle((HBITMAP)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_SCROLLER), IMAGE_BITMAP, 0,0, LR_SHARED)));
   // text
   CString strIntro;
   strIntro.LoadString(IDS_INTRO);
   m_scroller.SetText(strIntro);

	CRect rect;
	GetClientRect(&rect);
	m_scroller.Create(rect, this);

   // create tips dialog, and show at top-left of screen
   m_dlgTips.Create(CTipsDialog::IDD, this);
   m_dlgTips.SetWindowPos(NULL,0, 0, 0,0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

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

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CScrollerTestDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CScrollerTestDlg::OnSize(UINT nType, int cx, int cy)
{
	if ( NULL != m_scroller.GetSafeHwnd() )
	{
		m_scroller.MoveWindow(0,0,cx,cy);
	}
}

⌨️ 快捷键说明

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