当前位置:网站首页>MFC中利用CDockablePane实现悬浮窗
MFC中利用CDockablePane实现悬浮窗
2022-06-29 06:39:00 【sam-zy】


Camera.h
#pragma once
#include "afxdialogex.h"
// Camera 对话框
class Camera : public CDialogEx
{
DECLARE_DYNAMIC(Camera)
public:
Camera(CWnd* pParent = nullptr); // 标准构造函数
virtual ~Camera();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum {
IDD = IDD_CAMERA };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
};
class CCameraPane : public CDockablePane
{
public:
CCameraPane();
virtual ~CCameraPane();
private:
Camera m_Camera;
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP()
};
Camera.cpp
// Camera.cpp: 实现文件
//
#include "pch.h"
#include "afxdialogex.h"
#include "Camera.h"
// Camera 对话框
IMPLEMENT_DYNAMIC(Camera, CDialogEx)
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum {
IDD = IDD_CAMERA };
#endif
Camera::Camera(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_CAMERA, pParent)
{
}
Camera::~Camera()
{
}
void Camera::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Camera, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &Camera::OnBnClickedButton1)
END_MESSAGE_MAP()
// Camera 消息处理程序
void Camera::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
}
CCameraPane::CCameraPane()
{
}
CCameraPane::~CCameraPane()
{
}
void CCameraPane::OnDestroy()
{
CDockablePane::OnDestroy();
m_Camera.DestroyWindow();
}
/// <summary>
/// 子窗体悬浮
/// </summary>
/// <param name="lpCreateStruct"></param>
/// <returns></returns>
int CCameraPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (!m_Camera.Create(IDD_CAMERA, this))
{
TRACE0("未能创建窗口/n");
return -1;
}
m_Camera.ShowWindow(SW_SHOW);
return 0;
}
/// <summary>
/// 消除窗体残影
/// </summary>
/// <param name="nType"></param>
/// <param name="cx"></param>
/// <param name="cy"></param>
void CCameraPane::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
if (m_Camera.GetSafeHwnd())
{
CRect rect;
GetClientRect(rect);
m_Camera.MoveWindow(rect);
}
}
BEGIN_MESSAGE_MAP(CCameraPane, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
END_MESSAGE_MAP()
MainFrm.h
CCameraPane m_wndCameraPane;
MainFrm.cpp
// 创建测试对话框
if (!m_wndCameraPane.Create(_T("测试"), this, CRect(0, 0, 200, 200), TRUE, IDD_CAMERA, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI))
{
TRACE0("未能创建窗口\n");
return FALSE; // 未能创建
}
m_wndCameraPane.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndCameraPane);
边栏推荐
猜你喜欢

部署Prometheus-server服务 system管理
![[qnx hypervisor 2.2 user manual]6.2.1 communication between guests](/img/3d/6a0cde206a09a7ef03038fb99cf532.png)
[qnx hypervisor 2.2 user manual]6.2.1 communication between guests

YGG cooperated with Web3 platform leader to empower the creative community with Dao tools and resources

多模态 —— Learnable pooling with Context Gating for video classification

Redis of NoSQL database (II): introduction to redis configuration file

To: Hou Hong: the key to enterprise digital transformation is not technology, but strategy

JVM系列之对象深度探秘
![[QNX Hypervisor 2.2用户手册]6.2.1 Guest之间通信](/img/3d/6a0cde206a09a7ef03038fb99cf532.png)
[QNX Hypervisor 2.2用户手册]6.2.1 Guest之间通信

The realization of changing pop-up background at any time

A hybrid model of machine learning notes time series
随机推荐
QT custom bit operation class
uva10635
[translation] [Chapter 2 ③] mindshare PCI Express technology 3.0
国内代码托管中心- 码云
Spark RDD case: Statistics of daily new users
数字ic设计——UART
uva10635
LeetCode_ Dynamic programming_ Medium_ 91. decoding method
详解Autosar Arxml中的CANFD报文及格式
NoSQL数据库之Redis(五):Redis_Jedis_测试
Message queue batch processing refund order through queue
ES 查询语法
Markdown 技能树(9):表格
What are the conditions for a high-quality public chain?
QT qframe details
Solve the problem that NPM does not have permission
uva11825
Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
Uniapp obtains the date implementation of the beginning and end of the previous month and the next month
shell条件判断详解