当前位置:网站首页>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);
边栏推荐
- 【翻译】e-Cloud。使用KubeEdge的大规模CDN
- 1183:病人排队
- Redis in NoSQL database (4): redis publishing and subscription
- 【翻译】簇拥而出。构建现代应用程序的设计方法
- Machine learning notes - time series prediction using machine learning
- Deploy Prometheus server service system management
- Oscilloscope symbols
- Autosar SWC在Simulink中Parameter的使用
- Exploring the depth of objects in JVM series
- Spark RDD案例:统计每日新增用户
猜你喜欢

Uniapp obtains the date implementation of the beginning and end of the previous month and the next month

【翻译】e-Cloud。使用KubeEdge的大规模CDN

What are the conditions for a high-quality public chain?

mmclassification安装与调试

Markdown skill tree (5): picture

The meaning and calculation method of receptive field

QT serial port programming

机器学习笔记 - 时间序列使用机器学习进行预测

【软件测试】接口——基本测试流程

Spark RDD案例:统计每日新增用户
随机推荐
Use of LSTM neural network and general neural network
How to select CRM brand suppliers in garment industry?
通过keyup监听textarea输入更改按钮样式
Crawler data analysis (introduction 2-re analysis)
Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
1183:病人排队
[translation] [Chapter II ①] mindshare PCI Express technology 3.0
WebRTC系列-网络传输之8-连通性检测
The realization of changing pop-up background at any time
Es query syntax
Multimodal learning pooling with context gating for video classification
[QNX Hypervisor 2.2用户手册]6.2.1 Guest之间通信
Redis in NoSQL database (4): redis publishing and subscription
JVM系列之对象深度探秘
uva10859
Markdown skill tree (2): paragraph and emphasis
详解Autosar Arxml中的CANFD报文及格式
idea控台中文乱码问题【亲测有效】
QT STL type iterator
Uniapp obtains the date implementation of the beginning and end of the previous month and the next month