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

📄 floatwindow1.cpp

📁 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口 透明的浮动子窗口
💻 CPP
字号:
// FloatWindow1.cpp : implementation file
//

#include "stdafx.h"
#include "FloatWindow.h"
#include "FloatWindow1.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFloatWindow

CFloatWindow::CFloatWindow()
{
}

CFloatWindow::~CFloatWindow()
{
}


BEGIN_MESSAGE_MAP(CFloatWindow, CWnd)
	//{{AFX_MSG_MAP(CFloatWindow)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CFloatWindow message handlers

CFloatWindow::CFloatWindow(double width_ratio, double height_ratio)
{
	bitmap=NULL;
	bitmap=new CBitmap;
	bitmap->LoadBitmap(MAKEINTRESOURCE(IDB_BITMAP));
	m_width_ratio=width_ratio;
	m_height_ratio=height_ratio;

}

BOOL CFloatWindow::Create(int left, int top)
{
	BITMAP bm;
	int    count=0;
	//	bm.bmType=0;
	
	count=(bitmap->GetObject(sizeof(BITMAP),&bm));
	if(count==0)
		MessageBoxEx(NULL,_T("位图资源选择错误"),_T("系统错误"),MB_OK|MB_ICONSTOP,0x0804);
	m_wndWidth=bm.bmWidth;
	m_wndHeight=bm.bmHeight;

	m_winWidth=(int)(m_wndWidth*m_width_ratio);
	m_winHeight=(int)(m_wndHeight*m_height_ratio);
	
	return CWnd::CreateEx(WS_EX_TOPMOST|WS_EX_WINDOWEDGE,AfxRegisterWndClass(CS_NOCLOSE,0,0,0),_T(""),WS_POPUP|WS_VISIBLE,
		left,top,m_winWidth,m_winHeight,NULL,NULL);

}

void CFloatWindow::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
//	dc.SetBkMode(TRANSPARENT );
	CDC memDC;
	memDC.CreateCompatibleDC(&dc);
	CBitmap *pOld=memDC.SelectObject(bitmap);
	if(pOld==NULL)
		return;
	dc.StretchBlt(0,0,m_winWidth,m_winHeight,&memDC,0,0,m_wndWidth,
		m_wndHeight,SRCCOPY);
	memDC.SelectObject(pOld);	
	// Do not call CWnd::OnPaint() for painting messages
}

⌨️ 快捷键说明

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