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

📄 floatdlg.cpp

📁 为联众台球游戏开发
💻 CPP
字号:
// FloatDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TaiQiu.h"
#include "FloatDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFloatDlg dialog


CFloatDlg::CFloatDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFloatDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFloatDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CFloatDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFloatDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFloatDlg, CDialog)
	//{{AFX_MSG_MAP(CFloatDlg)
	ON_WM_PAINT()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFloatDlg message handlers

void CFloatDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CDC memDC;
	memDC.CreateCompatibleDC(&dc);
	BITMAP bm;
	m_pBitmap->GetBitmap(&bm);
	CBitmap * pOldBmp=memDC.SelectObject(m_pBitmap);
	dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);
	memDC.SelectObject(pOldBmp);
	// Do not call CDialog::OnPaint() for painting messages
}

BOOL CFloatDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_pBitmap=new CBitmap;
	m_pBitmap->LoadBitmap(IDB_BITMAP1);

	SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE)|0x80000);
	HINSTANCE hInst=LoadLibrary("User32.dll");
	if(hInst)
	{
		typedef BOOL(WINAPI * MYFUNC)(HWND, COLORREF, BYTE, DWORD);
		MYFUNC fun=NULL;
		fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
		fun(m_hWnd, RGB(255, 255, 255), NULL, 1);//设白色为透明色
		FreeLibrary(hInst);
	}
	POINT pt;
	GetCursorPos(&pt);
	SetWindowPos(NULL, pt.x+1, pt.y-19, 18, 18, NULL);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFloatDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	POINT pt;
	GetCursorPos(&pt);
	//SetWindowPos(NULL, pt.x+1, pt.y-19, 18, 18, NULL);
	MoveWindow(pt.x+1, pt.y-19, 18, 18, FALSE);
	
	CDialog::OnTimer(nIDEvent);
}

void CFloatDlg::SetTimerRun(int nTimer)
{
	switch(nTimer)
	{
	case 0:
		m_nTimer=SetTimer(1, 40, 0);
		break;
	case 1:
		KillTimer(m_nTimer);
		m_nTimer=0;
		break;
	}
}

void CFloatDlg::CloseDlg()
{
	SetTimerRun(1);
	delete m_pBitmap;
	m_pBitmap=NULL;
}

⌨️ 快捷键说明

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