抛弃GdCpp*.dll/pdb历史重新建库。libhv和Sqlite的dll保留
This commit is contained in:
104
staticOnly/KsMFC/CEditWithBtn.h
Normal file
104
staticOnly/KsMFC/CEditWithBtn.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
#ifndef _EDIT_WITHBTN_H_
|
||||
#define _EDIT_WITHBTN_H_
|
||||
#include <BCGPEdit.h>
|
||||
|
||||
// 带按钮的编辑框,增加设置按钮功能的接口和按钮文本
|
||||
// 需要调用EnableBrowseButton()使能,然后对_OnBrowseFunc赋值
|
||||
class CEditWithBtn :
|
||||
public CBCGPEdit
|
||||
{
|
||||
public:
|
||||
CEditWithBtn(LPCTSTR szLabel=_T("...")) {
|
||||
EnableBrowseButton(TRUE, szLabel);
|
||||
}
|
||||
|
||||
// 执行点击按钮后的回调函数
|
||||
void OnBrowse() override
|
||||
{
|
||||
if (_OnBrowseFunc) _OnBrowseFunc();
|
||||
}
|
||||
|
||||
// 执行更新后的回调函数
|
||||
void OnAfterUpdate() override
|
||||
{
|
||||
if (_OnAfterUpdateFunc) _OnAfterUpdateFunc();
|
||||
}
|
||||
|
||||
// 设置点击按钮后的回调函数
|
||||
inline void setOnBrowseFunc(std::function<void(void)> func) {
|
||||
_OnBrowseFunc = func;
|
||||
}
|
||||
|
||||
// 设置编辑框内容更新后的回调函数
|
||||
inline void setOnAfterUpdateFunc(std::function<void(void)> func) {
|
||||
_OnAfterUpdateFunc = func;
|
||||
}
|
||||
|
||||
protected:
|
||||
// 点击按钮后的回调函数
|
||||
std::function<void(void)> _OnBrowseFunc;
|
||||
|
||||
// 更新后的回调函数
|
||||
std::function<void(void)> _OnAfterUpdateFunc;
|
||||
};
|
||||
|
||||
// 带打开文件功能的编辑框,增加更新后的回调
|
||||
// 需要调用EnableFileBrowseButton()设置参数,然后对_OnAfterUpdateFunc赋值
|
||||
class CEditWithOpenFile :
|
||||
public CBCGPEdit
|
||||
{
|
||||
public:
|
||||
// 执行更新后的回调函数
|
||||
void OnAfterUpdate() override
|
||||
{
|
||||
if (_OnAfterUpdateFunc) _OnAfterUpdateFunc();
|
||||
}
|
||||
|
||||
// 设置编辑框内容更新后的回调函数
|
||||
inline void setOnAfterUpdateFunc(std::function<void(void)> func) {
|
||||
_OnAfterUpdateFunc = func;
|
||||
}
|
||||
|
||||
protected:
|
||||
// 更新后的回调函数
|
||||
std::function<void(void)> _OnAfterUpdateFunc;
|
||||
};
|
||||
|
||||
// 带计算周长的编辑框,增加更新后的回调
|
||||
class CEditWithPiCalc :
|
||||
public CBCGPEdit
|
||||
{
|
||||
public:
|
||||
// 构造函数,设置小数位数。-1表示不限制小数位数
|
||||
CEditWithPiCalc(int decimal=8) {
|
||||
CList<UINT, UINT>lstCommands;
|
||||
lstCommands.AddTail(CBCGPCalculator::idCommandAdvPi);
|
||||
CString str;
|
||||
if (decimal < 0) {
|
||||
CBCGPEdit::EnableCalculatorButton(nullptr, &lstCommands, nullptr);
|
||||
}
|
||||
else {
|
||||
str.Format(_T("%%.%df"), decimal);
|
||||
CBCGPEdit::EnableCalculatorButton(nullptr, &lstCommands, str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 设置编辑框内容更新后的回调函数
|
||||
inline void setOnAfterUpdateFunc(std::function<void(void)> func) {
|
||||
_OnAfterUpdateFunc = func;
|
||||
}
|
||||
|
||||
// 执行更新后的回调函数
|
||||
void OnAfterUpdate() override
|
||||
{
|
||||
if (_OnAfterUpdateFunc) _OnAfterUpdateFunc();
|
||||
}
|
||||
|
||||
protected:
|
||||
// 更新后的回调函数
|
||||
std::function<void(void)> _OnAfterUpdateFunc;
|
||||
};
|
||||
|
||||
#endif // !_EDIT_WITHBTN_H_
|
||||
Reference in New Issue
Block a user