当前位置:网站首页>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);
边栏推荐
- uva10635
- 国家安全局和CISA Kubernetes加固指南--1.1版的新内容
- Twitter launches the test of anti abuse tool "safe mode" and adds enabling prompt
- 【翻译】e-Cloud。使用KubeEdge的大规模CDN
- Redis (4) of NoSQL database: redis new data type
- QT program packaging and publishing windeployqt tool
- YGG cooperated with Web3 platform leader to empower the creative community with Dao tools and resources
- 测试人员需要了解的工具有哪些
- Livedata source code appreciation - basic use
- Two ways to write throttling - recently seen
猜你喜欢

1183:病人排队

Spark RDD case: Statistics of daily new users

Redis of NoSQL database (I): Installation & Introduction

软件测试面试如何正确谈论薪资?

Machine learning notes - time series prediction using machine learning

E-commerce is popular, how to improve the store conversion rate?

Crawler data analysis (introduction 2-re analysis)

Message queue batch processing refund order through queue

Multimodal learning pooling with context gating for video classification

YGG pilipinas: typhoon Odette disaster relief work update
随机推荐
Genicam gentl standard ver1.5 (3) Chapter 4
节流的两种写法-最近看到的这种写法
Markdown skill tree (5): picture
IDEA 集成 码云
Webrtc series - 8-connectivity detection for network transmission
Markdown 技能树(1):MarkDown介绍
Introduction to QT qfileinfo
Use of LSTM neural network and general neural network
【软件测试】接口——基本测试流程
VPS是干嘛用的?有哪些知名牌子?与云服务器有什么区别?
How to fix Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorli
In vscade, how to use eslint to lint and format
Redis of NoSQL database (II): introduction to redis configuration file
LiveData源码赏析 —— 基本使用
服装行业的CRM品牌供应商如何选型?
Tree drop-down selection box El select combined with El tree effect demo (sorting)
QT serial port programming
QT qlineedit details
Ci tools Jenkins installation configuration tutorial
【翻译】簇拥而出。构建现代应用程序的设计方法