6、DuiLib控件消息响应处理

文章目录

  • 1、DuiLib控件消息响应处理
  • 2、基本的消息响应处理 Notify
  • 3、仿 MFC 形式消息响应 DUI_DECLARE_MESSAGE_MAP
  • 4、事件委托 MakeDelegate
  • 5、消息捕获(拦截)原生消息 HandleMessage

1、DuiLib控件消息响应处理

<?xml version="1.0" encoding="UTF-8"?>
<Window size="640,480" mininfo="640,480" caption="0,0,0,35" sizebox="4,4,4,4">
  <Default name="Button" value="bordersize=&quot;5&quot; bordercolor=&quot;#FF222222&quot;" />
  <Font shared="true" id="0" name="幼圆" size="12" default="true" />
  <Font shared="true" id="1" name="微软雅黑" size="18" underline="true" bold="true"/>
  <VerticalLayout>
    <!--标题栏-->
    <HorizontalLayout height="50" bkcolor="#FFD6DBE9" inset="4,4,8,6" >
      <HorizontalLayout width="185">
        <Control bkimage="logo.png" height="32" width="32"   />
        <Label text="duilib tutorial" height="32"   padding="8,-2,4,0" font="1" />
      </HorizontalLayout>
      <Control />
      <HorizontalLayout childpadding="3" width="100">
        <Button name="minbtn" height="32" width="32" normalimage="btn_min_normal.png" hotimage="btn_min_hovered.png" pushedimage="btn_min_pushed.png" />
        <Button name="maxbtn" height="32" width="32" normalimage="btn_max_normal.png" hotimage="btn_max_hovered.png" pushedimage="btn_max_pushed.png" />
        <Button name="restorebtn" visible="false" height="32" width="32" normalimage="btn_reset_normal.png" hotimage="btn_reset_hovered.png" pushedimage="btn_reset_pushed.png" />
        <Button name="closebtn" height="32" width="32" normalimage="btn_close_normal.png" hotimage="btn_close_hovered.png" pushedimage="btn_close_pushed.png" />
      </HorizontalLayout>
    </HorizontalLayout>
    <!--窗口内容区域-->
    <HorizontalLayout bkcolor="#FFD81E06">
      
    </HorizontalLayout>
  </VerticalLayout>
</Window>

上一篇我们介绍了如何通过命名的 XML 控件转化为实际可操控的对象,实际上我们已经可以调用这些控件的一些方法来操作控件了,比如:

void MainWndFrame::InitWindow(){
	btn_min_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("btn_wnd_min")));
	btn_max_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("btn_wnd_max")));
	btn_close_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("btn_wnd_close")));
	btn_min_->SetVisible(false);
}

我们调用了 CButtonUISetVisible 方法,将最小化控件隐藏了。但实际这并没有什么作用,我们真正需要的是点击某个控件后执行某些操作。
在这里插入图片描述

2、基本的消息响应处理 Notify

接下来我们希望实现更实用的功能,点击最小化按钮把窗口最小化、点击关闭按钮把窗口关闭等。这就要涉及到对控件消息的处理,同样父类 WindowImplBase 提供了 Notify 虚函数,可以提供我们覆写并处理消息。一下代码实现了点击最小化按钮将窗口最小化的功能。

// new_test_demo.cpp : 定义应用程序的入口点。
//

#include "stdafx.h"
#include "new_test_demo.h"
#include<iostream>
#include"UIlib.h"
using namespace DuiLib;

//duilib_tutorial.cpp: 定义应用程序的入口点。
//
//WindowImplBase窗口基类

class MainWndFrame : public WindowImplBase
{
public:
	MainWndFrame();
protected:
	virtual CDuiString GetSkinFolder() override;							// 获取皮肤文件的目录,如果有多层目录这里可以设置
	virtual CDuiString GetSkinFile() override;								// 设置皮肤文件名字
	virtual LPCTSTR GetWindowClassName(void) const override;				// 设置当前窗口的 class name

	virtual void InitWindow() override;										//窗口初始化函数
	virtual void Notify(TNotifyUI& msg) override;							//通知事件处理函数

	//virtual DuiLib::UILIB_RESOURCETYPE GetResourceType() const override;
	//virtual LPCTSTR GetResourceID() const override;

public:
	static const LPCTSTR kClassName;
	static const LPCTSTR kMainWndFrame;

private:
	CButtonUI* btn_min_;
	CButtonUI* btn_max_;
	CButtonUI* btn_reset_;
	CButtonUI* btn_close_;
};

MainWndFrame::MainWndFrame(){
	btn_min_ = nullptr;
	btn_max_ = nullptr;
	btn_reset_ = nullptr;
	btn_close_ = nullptr;
}

DuiLib::CDuiString MainWndFrame::GetSkinFolder()
{
	// GetInstancePath 接口返回默认的皮肤文件位置
	// 在 main 函数中我们可以通过 SetResourcePath 来设置路径
	return m_PaintManager.GetInstancePath();
}

DuiLib::CDuiString MainWndFrame::GetSkinFile()
{
	// 成员变量定义的皮肤文件名
	return kMainWndFrame;
}

LPCTSTR MainWndFrame::GetWindowClassName(void) const
{
	// 成员变量定义的窗口 class name
	return kClassName;
}

void MainWndFrame::InitWindow(){
	btn_min_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("minbtn")));
	btn_max_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("maxbtn")));
	btn_reset_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("restorebtn")));
	btn_close_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));
	//btn_min_->SetVisible(false);
}

void MainWndFrame::Notify(TNotifyUI& msg){
	if (msg.sType == DUI_MSGTYPE_CLICK){
		CDuiString str_name = msg.pSender->GetName();
		if (str_name == _T("mintbn")){
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
		}
		else if (str_name == _T("maxbtn")){
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		}
		else if (str_name==_T("restorebtn")){
			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
		}
		else if (str_name == _T("closebtn")){
			SendMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
		}
	}
	__super::Notify(msg);
}

//theme压缩包资源
//DuiLib::UILIB_RESOURCETYPE MainWndFrame::GetResourceType() const
//{
//	return UILIB_ZIPRESOURCE;
//}
//
//LPCTSTR MainWndFrame::GetResourceID() const
//{
//	return MAKEINTRESOURCE(IDR_ZIPRES1);
//}

//生成的窗口名字
const LPCTSTR MainWndFrame::kClassName = _T("main_wnd_frame");
//theme文件下的xml文件
const LPCTSTR MainWndFrame::kMainWndFrame = _T("main_wnd_frame.xml");

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPWSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	//UNREFERENCED_PARAMETER(hPrevInstance);
	//UNREFERENCED_PARAMETER(lpCmdLine);

	// 设置窗口关联的实例
	CPaintManagerUI::SetInstance(hInstance);

	// 设置皮肤的默认路径
	CPaintManagerUI::SetCurrentPath(CPaintManagerUI::GetInstancePath());

	//theme文件夹
	CPaintManagerUI::SetResourcePath(_T("theme"));

	//theme压缩包
	//CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());
	//CPaintManagerUI::SetResourceZip(_T("theme.zip"));

	// 创建窗口
	MainWndFrame* pMainWndFrame = new MainWndFrame();
	if (nullptr == pMainWndFrame){
		return 0;
	}
	pMainWndFrame->Create(nullptr, MainWndFrame::kClassName, UI_WNDSTYLE_DIALOG, 0);
	pMainWndFrame->CenterWindow();
	pMainWndFrame->ShowWindow();
	CPaintManagerUI::MessageLoop();

	if (nullptr != pMainWndFrame)
	{
		delete pMainWndFrame;
	}

	return 0;
}

首先我们在 Notify 函数中判断了一下消息的类型,如果是鼠标点击那么我们获取一下触发的控件名称,根据名称判断是不是 btn_wnd_min 然后执行指定操作。最后别忘记调用父类的 Notify 函数来继续其他消息的处理(其实父类什么都没做)。

然后这里我在加上放大和关闭按钮:

void MainWndFrame::Notify(TNotifyUI& msg){
	if (msg.sType == DUI_MSGTYPE_CLICK){
		CDuiString str_name = msg.pSender->GetName();
		if (str_name == _T("minbtn")){
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
		}
		else if (str_name == _T("maxbtn")){
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		}
		else if (str_name==_T("restorebtn")){
			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
		}
		else if (str_name == _T("closebtn")){
			SendMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
		}
	}
	__super::Notify(msg);
}

在这里插入图片描述

3、仿 MFC 形式消息响应 DUI_DECLARE_MESSAGE_MAP

以上是一个基本的响应过程。另外还有一种类似 MFC 方式的响应方法,首先在 new_test_demo.h 中添加一句 DUI_DECLARE_MESSAGE_MAP()

在这里插入图片描述

void MainWndFrame::OnClick(TNotifyUI& msg){
	CDuiString str_name = msg.pSender->GetName();
	if (str_name == _T("mintbn")){
		SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
		return;
	}
	else if (str_name == _T("maxbtn")){
		SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		return;
	}
	else if (str_name == _T("restorebtn")){
		SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
		return;
	}
	else if (str_name == _T("closebtn")){
		Close();
		return;
	}
	return;
}

然后在 new_test_demo.h 中添加如下代码:

DUI_BEGIN_MESSAGE_MAP(MainWndFrame, CNotifyPump)
	DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK, OnClick)
DUI_END_MESSAGE_MAP()

这样我们就将 DUI_MSGTYPE_CLICK 类型的消息映射到了 OnClick 函数中,而 OnClick 函数在父类 WindowImplBase 中已经提供了一个虚函数了。

void WindowImplBase::OnClick(TNotifyUI& msg)
{
	CDuiString sCtrlName = msg.pSender->GetName();
	if( sCtrlName == _T("closebtn") )
	{
		Close();
		return; 
	}
	else if( sCtrlName == _T("minbtn"))
	{ 
		SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); 
		return; 
	}
	else if( sCtrlName == _T("maxbtn"))
	{ 
		SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); 
		return; 
	}
	else if( sCtrlName == _T("restorebtn"))
	{ 
		SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0); 
		return; 
	}
	return;
}

可以看出,DuiLib 已经默认帮我们实现了几个按钮的鼠标点击功能。我们只需要根据它设定的名字修改一下我们控件的 name 属性就可以实现几个功能了。当然如果我们要添加其他控件的处理,是需要覆写这个 OnClick 函数的。
在这里插入图片描述
修改完成后最小化、最大化、还原三个按钮都可以正常工作了,但是关闭按钮点击后并不能完全退出程序,而仅仅是把程序隐藏了,这主要原因是当我们点击关闭按钮时调用的是父类的 Close 函数,该函数发送了退出消息后,窗口接收到该消息的处理函数 OnClose 未做任何措施,如下所示:
在这里插入图片描述
父类中的**WindowImplBase::OnClose()**任务管理器中的进程并没有结束掉:
在这里插入图片描述

要解决这个问题很简单,我们只需要覆写一下这个 OnClose 方法,然后执行退出操作就可以了。

LRESULT MainWndFrame::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (uMsg == WM_CLOSE)
	{
		PostQuitMessage(0L);
	}

	return __super::OnClose(uMsg, wParam, lParam, bHandled);
}

在这里插入图片描述
覆写完成后,我们三个功能按钮(哦不,是四个)就都可以正常使用了。另外我自己还发现了两个小问题,窗口的标题栏双击是无法最大化的,这个解决很简单,在 main 函数创建窗口的时候,将窗口的 UI_WNDSTYLE_DIALOG 属性修改为 UI_WNDSTYLE_FRAME 就可以了,至于两个参数什么意思,我有一篇DuiLib文章介绍了,有兴趣可以去查看。
在这里插入图片描述

pMainWndFrame->Create(nullptr, MainWndFrame::kClassName, UI_WNDSTYLE_FRAME, 0);

在这里插入图片描述
另外一个问题是窗口是无法拖动放大缩小的,这个也很好解决,我们修改 XML,添加上窗口最小大小和可拖动范围就可以了。如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<Window size="640,480" mininfo="640,480" caption="0,0,0,35" sizebox="4,4,4,4">
  <Default name="Button" value="bordersize=&quot;5&quot; bordercolor=&quot;#FF222222&quot;" />
  <Font shared="true" id="0" name="幼圆" size="12" default="true" />
  <Font shared="true" id="1" name="微软雅黑" size="18" underline="true" bold="true"/>
  <VerticalLayout>
    <!--标题栏-->
    <HorizontalLayout height="50" bkcolor="#FFD6DBE9" inset="4,4,8,6" >
      <HorizontalLayout width="185">
        <Control bkimage="logo.png" height="32" width="32"   />
        <Label text="duilib tutorial" height="32"   padding="8,-2,4,0" font="1" />
      </HorizontalLayout>
      <Control />
      <HorizontalLayout childpadding="3" width="100">
        <Button name="btn_wnd_min" height="32" width="32" normalimage="btn_min_normal.png" hotimage="btn_min_hovered.png" pushedimage="btn_min_pushed.png" />
        <Button name="btn_wnd_max" height="32" width="32" normalimage="btn_max_normal.png" hotimage="btn_max_hovered.png" pushedimage="btn_max_pushed.png" />
        <Button name="btn_wnd_reset" height="32" width="32" normalimage="btn_reset_normal.png" hotimage="btn_reset_hovered.png" pushedimage="btn_reset_pushed.png"  visible="false"/>
        <Button name="btn_wnd_close" height="32" width="32" normalimage="btn_close_normal.png" hotimage="btn_close_hovered.png" pushedimage="btn_close_pushed.png" />
      </HorizontalLayout>
    </HorizontalLayout>
    <!--窗口内容区域-->
    <HorizontalLayout bkcolor="#FFD81E06">
      
    </HorizontalLayout>
  </VerticalLayout>
</Window>

在这里插入图片描述
mininfo 属性决定了窗口最小大小,sizebox 属性是指定当鼠标移动到窗口边缘多少像素的时候显示拖放手势。这里指定的是 4 像素,这样指定后窗口就可以拖动了,而且最小不允许小于默认的 640x480

4、事件委托 MakeDelegate

除了以上两种方式外,我们还可以通过事件委托的方式来处理指定控件的消息。如下示例演示了事件委托的实现方式。

void MainWndFrame::InitWindow()
{
	m_pMinBtn = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("minbtn")));
	m_pMaxBtn = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("maxbtn")));
	m_pRestoreBtn = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("restorebtn")));
	m_pCloseBtn = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));

	m_pMinBtn->OnNotify += MakeDelegate(this, &MainWndFrame::OnBtnTest);
}

在 InitWindow 函数中,我们给最小化按钮委托了一个 OnBtnTest 的处理函数,当我们对最小化按钮做某些操作时,就会到达 OnBtnTest 处理函数中。OnBtnTest 的实现如下:

bool MainWndFrame::OnBtnTest(void* param)
{
	TNotifyUI* msg = reinterpret_cast<TNotifyUI*>(param);
	if (msg->sType == DUI_MSGTYPE_CLICK)
	{
		// ... do something
	}

	return true;
}

这种方式同样可以实现处理控件的消息功能,如果对委托的函数指针加以改造,还可以使用 C++11 的 lambda 表达式来实现具体的处理函数功能。

5、消息捕获(拦截)原生消息 HandleMessage

DuiLib 提供了虚函数 HandleMessage,可以提供我们覆写来捕获或者拦截原声的系统消息。比如我们希望监听剪切板的消息时,就可以像一下方法一样来实现

virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);

在这里插入图片描述

在这里插入图片描述

LRESULT MainWndFrame::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam){
	if (uMsg == WM_CHANGECBCHAIN){
		//
	}
	else if (uMsg = WM_DRAWCLIPBOARD){
		//
	}
	return __super::HandleMessage(uMsg, wParam, lParam);
}

老版本的 DuiLib 中窗口创建完成后,按下 ESC 窗口会被关闭,如果想屏蔽掉 ESC 按下的消息,就可以通过这个函数来实现。

// new_test_demo.cpp : 定义应用程序的入口点。
//

#include "stdafx.h"
#include "new_test_demo.h"
#include<iostream>
#include"UIlib.h"
using namespace DuiLib;

//duilib_tutorial.cpp: 定义应用程序的入口点。
//
//WindowImplBase窗口基类

class MainWndFrame : public WindowImplBase
{
public:
	MainWndFrame();
protected:
	virtual CDuiString GetSkinFolder() override;							// 获取皮肤文件的目录,如果有多层目录这里可以设置
	virtual CDuiString GetSkinFile() override;								// 设置皮肤文件名字
	virtual LPCTSTR GetWindowClassName(void) const override;				// 设置当前窗口的 class name

	virtual void InitWindow() override;                                     //窗口初始化函数
	//virtual void Notify(TNotifyUI& msg) override;							//通知事件处理函数

	virtual void OnClick(TNotifyUI& msg) override;            
	virtual LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override;

	virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);

	DUI_DECLARE_MESSAGE_MAP()

	//virtual DuiLib::UILIB_RESOURCETYPE GetResourceType() const override;
	//virtual LPCTSTR GetResourceID() const override;

public:
	static const LPCTSTR kClassName;
	static const LPCTSTR kMainWndFrame;

private:
	CButtonUI* btn_min_;
	CButtonUI* btn_max_;
	CButtonUI* btn_reset_;
	CButtonUI* btn_close_;
};

MainWndFrame::MainWndFrame(){
	btn_min_ = nullptr;
	btn_max_ = nullptr;
	btn_reset_ = nullptr;
	btn_close_ = nullptr;
}

DUI_BEGIN_MESSAGE_MAP(MainWndFrame, CNotifyPump)
DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK, OnClick)
DUI_END_MESSAGE_MAP()

DuiLib::CDuiString MainWndFrame::GetSkinFolder()
{
	// GetInstancePath 接口返回默认的皮肤文件位置
	// 在 main 函数中我们可以通过 SetResourcePath 来设置路径
	return m_PaintManager.GetInstancePath();
}

DuiLib::CDuiString MainWndFrame::GetSkinFile()
{
	// 成员变量定义的皮肤文件名
	return kMainWndFrame;
}

LPCTSTR MainWndFrame::GetWindowClassName(void) const
{
	// 成员变量定义的窗口 class name
	return kClassName;
}

void MainWndFrame::InitWindow(){
	btn_min_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("mintbn")));
	btn_max_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("maxbtn")));
	btn_reset_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("restorebtn")));
	btn_close_ = dynamic_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));
	//btn_min_->SetVisible(false);
}

//void MainWndFrame::Notify(TNotifyUI& msg){
//	if (msg.sType == DUI_MSGTYPE_CLICK){
//		CDuiString str_name = msg.pSender->GetName();
//		if (str_name == _T("btn_wnd_min")){
//			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
//		}
//		else if (str_name == _T("btn_wnd_max")){
//			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
//		}
//		else if (str_name==_T("btn_wnd_reset")){
//			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
//		}
//		else if (str_name == _T("btn_wnd_close")){
//			SendMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
//		}
//	}
//	__super::Notify(msg);
//}

void MainWndFrame::OnClick(TNotifyUI& msg){
	CDuiString str_name = msg.pSender->GetName();
	if (str_name == _T("minbtn")){
		SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
		return;
	}
	else if (str_name == _T("maxbtn")){
		SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		return;
	}
	else if (str_name == _T("restorebtn")){
		SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
		return;
	}
	else if (str_name == _T("closebtn")){
		Close();
		return;
	}
	return;
}

LRESULT  MainWndFrame::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	if (uMsg == WM_CLOSE){
		PostQuitMessage(0L);
	}
	return __super::OnClose(uMsg, wParam, lParam, bHandled);
}

LRESULT MainWndFrame::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam){
	if (uMsg == WM_CHANGECBCHAIN){
		//
	}
	else if (uMsg = WM_DRAWCLIPBOARD){
		//
	}
	return __super::HandleMessage(uMsg, wParam, lParam);
}

//theme压缩包资源
//DuiLib::UILIB_RESOURCETYPE MainWndFrame::GetResourceType() const
//{
//	return UILIB_ZIPRESOURCE;
//}
//
//LPCTSTR MainWndFrame::GetResourceID() const
//{
//	return MAKEINTRESOURCE(IDR_ZIPRES1);
//}

//生成的窗口名字
const LPCTSTR MainWndFrame::kClassName = _T("main_wnd_frame");
//theme文件下的xml文件
const LPCTSTR MainWndFrame::kMainWndFrame = _T("main_wnd_frame.xml");

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPWSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	//UNREFERENCED_PARAMETER(hPrevInstance);
	//UNREFERENCED_PARAMETER(lpCmdLine);

	// 设置窗口关联的实例
	CPaintManagerUI::SetInstance(hInstance);

	// 设置皮肤的默认路径
	CPaintManagerUI::SetCurrentPath(CPaintManagerUI::GetInstancePath());

	//theme文件夹
	CPaintManagerUI::SetResourcePath(_T("theme"));

	//theme压缩包
	//CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());
	//CPaintManagerUI::SetResourceZip(_T("theme.zip"));

	// 创建窗口
	MainWndFrame* pMainWndFrame = new MainWndFrame();
	if (nullptr == pMainWndFrame){
		return 0;
	}
	pMainWndFrame->Create(nullptr, MainWndFrame::kClassName, UI_WNDSTYLE_FRAME, 0);
	pMainWndFrame->CenterWindow();
	pMainWndFrame->ShowWindow();
	CPaintManagerUI::MessageLoop();

	if (nullptr != pMainWndFrame)
	{
		delete pMainWndFrame;
	}

	return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/31091.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

PromptBench:大型语言模型的对抗性基准测试

PromptBench是微软研究人员设计的一个用于测量大型语言模型(llm)对对抗性提示鲁棒性的基准测试。这个的工具是理解LLM的重要一步&#xff0c;随着这些模型在各种应用中越来越普遍&#xff0c;这个主题也变得越来越重要。 研究及其方法论 PromptBench采用多种对抗性文本攻击&am…

前端后端交互-ElementUI(日期选择器)

日期选择器 页面效果 页面效果 组件源码 <!-- daterange: 范围选择类型format: 绑定后表单中显示的格式value-format: 传递时显示的格式--> <template><el-date-picker v-model"rangeTime" type"daterange" range-separator"至" …

吴恩达471机器学习入门课程3第1周——K-means

K-means 聚类 1 - 实现 K-means1.1 找到最近的质心练习11.2 计算质心均值练习2 2 - K-means在样本数据集上的应用3 - 随机初始化4 - K-means图像压缩4.1 数据集可视化处理数据 4.2图像像素上的 K-mean4.3 压缩图片 实现 K-means 算法&#xff0c;并将其用于图像压缩。 您将从一…

fscan安装配置(windows、linux系统)

fscan安装配置(windows、linux系统) 1、简介 fscan一款内网综合扫描工具&#xff0c;方便一键自动化、全方位漏扫扫描。 它支持主机存活探测、端口扫描、常见服务的爆破、ms17010、redis批量写公钥、计划任务反弹shell、读取win网卡信息、web指纹识别、web漏洞扫描、netbios探…

qt 时间编程之时钟

这里写目录标题 开启time格式自动 QTIM打点 qtime qt的时间类 qtimer qt的定时类 头文件包含以及定义 #include<QTime> #include<QTimer>QTime * time; QTimer * timer;开启 右键槽 timer start&#xff08;50&#xff09; 到达50毫米的时候会触发 time out信号…

AcWing801: 二进制中1的个数(两种方法详解)

原题引出 方法一&#xff1a;使用lowbit 算法的时间复杂度为 O ( n l o g n ) O(nlogn) O(nlogn)&#xff0c;使用lowbit操作&#xff0c;每次操作截取一个数字的最后一个1后面的所有位&#xff0c;每次减去lowbit得到的数字&#xff0c;直到数字减到0&#xff0c;就得到了最终…

基于SSM+jsp的电子商城系统设计与实现

博主介绍&#xff1a; 大家好&#xff0c;我是一名在Java圈混迹十余年的程序员&#xff0c;精通Java编程语言&#xff0c;同时也熟练掌握微信小程序、Python和Android等技术&#xff0c;能够为大家提供全方位的技术支持和交流。 我擅长在JavaWeb、SSH、SSM、SpringBoot等框架…

Redis原理 - 内存策略

原文首更地址&#xff0c;阅读效果更佳&#xff01; Redis 本身是一个典型的 key-value 内存存储数据库&#xff0c;因此所有的 key、value 都保存在之前学习过的 Dict 结构中。不过在其 database 结构体中&#xff0c;有两个 Dict &#xff1a;一个用来记录 key-value&#xf…

day1

在linux内核中&#xff0c;当用户打开设备文件时&#xff0c;内核中的VFS层会调用设备驱动中的sys_open()函数&#xff0c;在sys_open()函数中&#xff0c;内核会根据文件的inode号判断文件是否存在于文件系统中&#xff0c;如果存在&#xff0c;内核会找到这个文件的文件信息结…

翻筋斗觅食策略改进灰狼算法(IGWO)

目录 一、动态扰动因子策略 二、翻筋斗觅食策略 三、改进灰狼算法收敛曲线图 灰狼优化算法存在收敛的不合理性等缺陷&#xff0c;目前对GWO算法的收敛性改进方式较少&#xff0c;除此之外&#xff0c;当GWO迭代至后期&#xff0c;所有灰狼个体都逼近狼、狼、狼&#xff0c;…

A Neural Conversational Model 读后感

目录 摘要 1、介绍 2、相关工作 3、模型 4、数据&#xff08;后面都是具体的东西&#xff0c;不赘述&#xff09; 5、总结 使用微软翻译得到的中文原文&#xff1a; 摘要 会话建模是自然语言理解和机器智能中的一项重要任务。尽管存在以前的方法&#xff0c;但它们通常仅…

React中的HOC高阶组件处理

先了解函数柯里化 柯里化函数&#xff08;Currying Function&#xff09;是指将一个接受多个参数的函数转化成一系列只接受单个参数的函数&#xff0c;并且返回接受单个参数的函数&#xff0c;达到简化函数调用和提高可读性的目的。 简单来说&#xff0c;柯里化即将接收多个参…

Pytorch数据类型Tensor张量操作(操作比较全)

文章目录 Pytorch数据类型Tensor张量操作一.创建张量的方式1.创建无初始化张量2.创建随机张量3.创建初值为指定数值的张量4.从数据创建张量5.生成等差数列张量 二.改变张量形状三.索引四.维度变换1.维度增加unsqueeze2.维度扩展expand3.维度减少squeeze4.维度扩展repeat 五.维度…

Jenkins-pipeline自动化构建Java应用

本实验操作需要&#xff1a;Jenkins&#xff0c;git代码仓库&#xff08;如gitlab&#xff0c;gitee等都可以&#xff09;&#xff0c;maven&#xff0c;docker&#xff0c;docker镜像仓库&#xff08;habor&#xff0c;nexus或者阿里云ACR等&#xff09;以及k8s环境。 前期准…

Python网络爬虫基础进阶到实战教程

文章目录 认识网络爬虫HTML页面组成Requests模块get请求与实战效果图代码解析 Post请求与实战代码解析 发送JSON格式的POST请求使用代理服务器发送POST请求发送带文件的POST请求 Xpath解析XPath语法的规则集&#xff1a;XPath解析的代码案例及其详细讲解&#xff1a;使用XPath解…

k8s使用ceph存储

文章目录 初始化操作k8s使用ceph rbdvolumePV静态pv动态pv k8s使用cephfsvolume静态pv 初始化操作 ceph创建rbd存储池 ceph osd pool create k8s-data 32 32 replicated ceph osd pool application enable k8s-data rbd rbd pool init -p k8s-dataceph添加授权&#xff0c;需…

吴恩达ChatGPT《Building Systems with the ChatGPT API》笔记

1. 课程介绍 使用ChatGPT搭建端到端的LLM系统 本课程将演示使用ChatGPT API搭建一个端到端的客户服务辅助系统&#xff0c;其将多个调用链接到语言模型&#xff0c;根据前一个调用的输出来决定使用不同的指令&#xff0c;有时也可以从外部来源查找信息。 课程链接&#xff1a…

client-go的Indexer三部曲之三:源码阅读

欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码)&#xff1a;https://github.com/zq2599/blog_demos 《client-go的Indexer三部曲》全部链接 基本功能性能测试源码阅读 本篇概览 本文是《client-go的Indexer三部曲》系列的终篇&#xff0c;主要任务是阅读和…

VR全景智慧园区,沉浸式数字化体验,720度全视角展示

导语&#xff1a; 随着科技的迅猛发展&#xff0c;虚拟现实&#xff08;Virtual Reality&#xff0c;简称VR&#xff09;全景技术已经成为了人们趋之若鹜的新兴领域。 而城市园区作为现代社会的重要组成部分&#xff0c;也正在积极寻求创新的方式来吸引更多的人流和投资。 一&…

C++基础

C基础入门 1 C初识 1.1 第一个C程序 编写一个C程序总共分为4个步骤 创建项目创建文件编写代码运行程序 1.1.1 创建项目 ​ Visual Studio是我们用来编写C程序的主要工具&#xff0c;我们先将它打开 1.1.2 创建文件 右键源文件&#xff0c;选择添加->新建项 1.1.3 编…