text控件:新增光标后插入;新增可控边界
This commit is contained in:
Binary file not shown.
@@ -7,7 +7,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
|
||||
Application app(hInstance);
|
||||
app.EnableHighDpi();//启用高DPI
|
||||
|
||||
|
||||
//创建登录创建
|
||||
loginForm loginFrm;
|
||||
loginFrm.Show();
|
||||
|
||||
Binary file not shown.
@@ -1,2 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 DemoUi.rc 使用
|
||||
//
|
||||
#define IDD_INPUT 102
|
||||
#define IDC_EDIT1 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
#include "ezui/Application.h" //app类
|
||||
#include "EzUI/Window.h" //基础窗口类
|
||||
#include "EzUI/Button.h" //按钮
|
||||
@@ -19,3 +18,4 @@
|
||||
#include "EzUI/LayeredWindow.h"//分层窗口类-可以异型透明窗口
|
||||
#include "ezui/UIManager.h"//ui管理类(使用xml生成控件)
|
||||
#include "EzUI/Animation.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "loginForm.h"
|
||||
#include "mainForm.h"
|
||||
|
||||
@@ -10,30 +10,30 @@ void loginForm::OnNotify(Control* sender, EventArgs& args)
|
||||
TextBox* editpwd = (TextBox*)FindControl("pwd");
|
||||
CheckBox* ckbox = (CheckBox*)FindControl("ckbox");
|
||||
/*if (!ckbox->GetCheck()) {
|
||||
::MessageBoxW(Hwnd(), L"<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>Э<EFBFBD>鲢<EFBFBD><EFBFBD>ѡ!", L"<EFBFBD><EFBFBD>ʾ", MB_OK);
|
||||
::MessageBoxW(Hwnd(), L"请阅读协议并勾选!", L"提示", MB_OK);
|
||||
return;
|
||||
}*/
|
||||
UIString user = editUser->GetText();
|
||||
UIString pwd = editpwd->GetText();
|
||||
|
||||
Hide(); // <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Hide(); // 隐藏登录窗口
|
||||
static mainForm mainForm;
|
||||
mainForm.Show(); // <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mainForm.Show(); // 显示主界面
|
||||
|
||||
//if (user == "ad" && pwd == "123") {
|
||||
// ::MessageBoxW(Hwnd(), L"<EFBFBD><EFBFBD>¼<EFBFBD>ɹ<EFBFBD>!", L"<EFBFBD><EFBFBD>ʾ", MB_OK);
|
||||
// Hide(); // <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// ::MessageBoxW(Hwnd(), L"登录成功!", L"提示", MB_OK);
|
||||
// Hide(); // 隐藏登录窗口
|
||||
// static mainForm mainForm;
|
||||
// mainForm.Show(); // <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// mainForm.Show(); // 显示主界面
|
||||
//}
|
||||
//else {
|
||||
// ::MessageBoxW(Hwnd(), L"<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!", L"<EFBFBD><EFBFBD>ʾ", MB_OK);
|
||||
// ::MessageBoxW(Hwnd(), L"用户名或密码错误!", L"提示", MB_OK);
|
||||
//}
|
||||
}
|
||||
if (sender->Name == "btnExit") {
|
||||
Application::Exit();
|
||||
}
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 打开链接
|
||||
if (!sender->GetAttribute("url").empty()) {
|
||||
::ShellExecuteA(0, "open", sender->GetAttribute("url").c_str(), "", "", SW_SHOW);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ void loginForm::OnClose(bool& close)
|
||||
|
||||
loginForm::loginForm() :LayeredWindow(320, 448)
|
||||
{
|
||||
umg.LoadXml("res/loginForm.htm");//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>xml<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
umg.LoadXml("res/loginForm.htm");//加载xml里面的控件与样式
|
||||
umg.SetupUI(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
using namespace ezui;
|
||||
|
||||
using Form = LayeredWindow; //֧<><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ӱ)
|
||||
//using Form = BorderlessWindow; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޱ߿<EFBFBD>(<28><><EFBFBD><EFBFBD>Ӱ)
|
||||
//using Form = Window; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
//using Form = LayeredWindow; //支持异形透明窗口(带阴影)
|
||||
//using Form = BorderlessWindow; //常规无边框窗口(带阴影)
|
||||
//using Form = Window; //标准窗口(带系统标题栏)
|
||||
|
||||
// <EFBFBD><EFBFBD>½<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
class loginForm :public Form
|
||||
// 登陆窗口
|
||||
class loginForm :public LayeredWindow
|
||||
{
|
||||
private:
|
||||
//ui<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//ui管理类
|
||||
UIManager umg;
|
||||
protected:
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>֪ͨ
|
||||
virtual void OnClose(bool& close)override;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹرյ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//重载事件通知
|
||||
virtual void OnClose(bool& close)override;//当窗口关闭的时候
|
||||
public:
|
||||
loginForm();
|
||||
virtual ~loginForm();
|
||||
|
||||
@@ -1,28 +1,64 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "mainForm.h"
|
||||
|
||||
void mainForm::OnNotify(Control* sender, EventArgs& args)
|
||||
{
|
||||
UIString btnName = sender->Name; // <EFBFBD>ؼ<EFBFBD>id
|
||||
Event eventType = args.EventType; // <EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UIString btnName = sender->Name; // 控件id
|
||||
Event eventType = args.EventType; // 事件类型
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case ezui::OnMouseDown: //<EFBFBD><EFBFBD><EFBFBD>갴<EFBFBD><EFBFBD>
|
||||
case ezui::OnMouseDown: //鼠标按下
|
||||
{
|
||||
if (btnName == "btnExitMain") { //<EFBFBD>˳<EFBFBD>
|
||||
int result = ::MessageBoxW(Hwnd(), L"Ҫ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", L"<EFBFBD><EFBFBD>ʾ", MB_YESNO | MB_ICONQUESTION);
|
||||
if (btnName == "btnExitMain") { //退出
|
||||
int result = ::MessageBoxW(Hwnd(), L"要退出程序吗?", L"提示", MB_YESNO | MB_ICONQUESTION);
|
||||
if (result == IDYES)
|
||||
exit(0);
|
||||
}
|
||||
else if (btnName == "btnMinMain") { //<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>
|
||||
else if (btnName == "btnMinMain") { //最小化
|
||||
this->ShowMinimized();
|
||||
}
|
||||
else if (btnName == "btnMaxMain") { //最大化|还原
|
||||
if (this->IsMaximized()) {
|
||||
this->ShowNormal();
|
||||
// 修改控件文字
|
||||
Button* btnMax = (Button*)FindControl("btnMaxMain");
|
||||
btnMax->SetText(L"🗖");
|
||||
}
|
||||
else {
|
||||
this->ShowMaximized();
|
||||
// 修改控件文字
|
||||
Button* btnMax = (Button*)FindControl("btnMaxMain");
|
||||
btnMax->SetText(L"🗗");
|
||||
}
|
||||
}
|
||||
else if (btnName == "btnAdmin") { //到管理页面 获取 mainTab ,设置页面为0
|
||||
TabLayout* mainTab = (TabLayout*)FindControl("mainTab");
|
||||
mainTab->SetPageIndex(0);
|
||||
mainTab->Invalidate();
|
||||
}
|
||||
else if (btnName == "btnTools") { //到工具页面 获取 mainTab ,设置页面为1
|
||||
TabLayout* mainTab = (TabLayout*)FindControl("mainTab");
|
||||
mainTab->SetPageIndex(1);
|
||||
mainTab->Invalidate();
|
||||
}
|
||||
else if (btnName == "btnAdminConnect") { //管理页面的连接按钮按下,先获取 btnAdminConnect 按钮,设置为不可用,修改文字为“连接中...”
|
||||
Button* btnAdminConnect = (Button*)FindControl("btnAdminConnect");
|
||||
btnAdminConnect->SetText(L"🔄");
|
||||
btnAdminConnect->Style.BackColor = Color(0, 185, 107);
|
||||
}
|
||||
else if (btnName == "btnAdminTemp") { //管理页面的测试按钮
|
||||
TextBox* textAdmin = (TextBox*)FindControl("textAdminOutput"); //获取输出框
|
||||
//textAdmin->Insert(L"\n测试成功!", true);
|
||||
if (textAdmin) {
|
||||
textAdmin->Insert(L"\n测试成功!",true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ezui::OnMouseDoubleClick: //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD>
|
||||
case ezui::OnMouseDoubleClick: //鼠标双击
|
||||
{
|
||||
//if (btnName == "titleMain") { //<EFBFBD><EFBFBD><EFBFBD>Ⲽ<EFBFBD><EFBFBD>
|
||||
//if (btnName == "titleMain") { //标题布局
|
||||
// if (this->IsMaximized()) {
|
||||
// this->ShowNormal();
|
||||
// }
|
||||
@@ -49,9 +85,9 @@ void mainForm::OnClose(bool& close)
|
||||
|
||||
mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
{
|
||||
SetResizable(true); // <EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD>ڴ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SetMiniSize(Size(600, 450)); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ߴ<EFBFBD>
|
||||
umg.LoadXml("res/mainForm.htm");//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>xml<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
SetResizable(true); // 启用窗口大小调整
|
||||
SetMiniSize(Size(600, 450)); // 设置最小尺寸
|
||||
umg.LoadXml("res/mainForm.htm");//加载xml里面的控件与样式
|
||||
umg.SetupUI(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
using namespace ezui;
|
||||
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 主窗口
|
||||
class mainForm :public LayeredWindow
|
||||
{
|
||||
private:
|
||||
//ui<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//ui管理类
|
||||
UIManager umg;
|
||||
protected:
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>֪ͨ
|
||||
virtual void OnClose(bool& close)override;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹرյ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//重载事件通知
|
||||
virtual void OnClose(bool& close)override;//当窗口关闭的时候
|
||||
public:
|
||||
mainForm();
|
||||
virtual ~mainForm();
|
||||
|
||||
@@ -1 +1 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
@@ -1,2 +1,2 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
@@ -39,12 +39,17 @@ namespace ezui {
|
||||
std::wstring m_placeholder;//placeholder懂得都懂 (在没有文字的情况下显示的文字)
|
||||
std::wstring m_passwordChar;
|
||||
bool m_readOnly = false;//是否只读
|
||||
// 内边距(四边独立)
|
||||
int m_padLeft = 6;
|
||||
int m_padTop = 4;
|
||||
int m_padRight = 6;
|
||||
int m_padBottom = 4;
|
||||
public:
|
||||
//文字对其方式(针对单行输入框有效)
|
||||
TextAlign TextAlign = TextAlign::MiddleLeft;
|
||||
private:
|
||||
void Init();
|
||||
void InsertUnicode(const std::wstring& str);//插入unicode文字内部使用
|
||||
void InsertUnicode(const std::wstring& str, bool isEnd = false);//插入unicode文字内部使用
|
||||
bool DeleteRange();//删除选中内容
|
||||
bool GetSelectedRange(int* outPos, int* outCount);//获取当前被选中的区域 返回下标和个数
|
||||
bool Copy();//复制到剪切板
|
||||
@@ -69,18 +74,24 @@ namespace ezui {
|
||||
virtual void OnKillFocus(const KillFocusEventArgs& arg) override;
|
||||
virtual void OnLayout();
|
||||
void Offset(int moveY);
|
||||
// 支持 TextBox 自身扩展样式属性(padding 系列)
|
||||
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value) override;
|
||||
public:
|
||||
std::function<void(const UIString&)> TextChanged = NULL;
|
||||
public:
|
||||
TextBox(Object* parentObject = NULL);
|
||||
virtual ~TextBox();
|
||||
// 设置内边距 (兼容旧接口:水平=px, 垂直=py)
|
||||
void SetPadding(int px, int py);
|
||||
// 设置四边
|
||||
void SetPadding4(int left, int top, int right, int bottom);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
//获取焦点所在光标位置
|
||||
virtual Rect GetCareRect()override;
|
||||
//分析字符串
|
||||
void Analysis();
|
||||
//在当前光标中插入文字
|
||||
void Insert(const UIString& str);
|
||||
void Insert(const UIString& str, bool isEnd = false);
|
||||
//获取输入框文字
|
||||
const UIString GetText();
|
||||
//获取滚动条
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user