失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > duilib实战1-模仿百度网盘登录界面

duilib实战1-模仿百度网盘登录界面

时间:2020-01-08 09:01:30

相关推荐

duilib实战1-模仿百度网盘登录界面

侵权删,未经允许禁止转载!仅供学习使用!

前言:

刚上手duilib,还不太熟悉,而且没有官方文档,所以写几个实战项目来学习并巩固一下。

使用或实现的部分技术细节:

1、主窗体的边框

2、默认字体,控件默认属性的标签定义

3、CTextUI控件的简配html功能,包括a、c标签的使用(其中当align处于center时,点击超链接有bug)

4、使用到的控件标签主要有Button,Text,Control,RichEdit,Edit,CheckBox,ComboBox等

5、实现自定义控件(此项目中使用自定义控件的原因是因为CControlUI并没有将鼠标进入和离开事件转化为Notify,所以只能自己继承并重写标签,实现对这两个事件的控制)

6、通过定时器实现动画效果(在duilib中暂时没找到类似ProcessMessage这样的方法,所以暂时通过定时器来实现相关的功能)

7、模态窗的使用

效果展示(防止动图被和谐,打码):

核心代码如下:

test.xml

<?xml version="1.0" encoding="UTF-8"?><Window size="662,442" mininfo="600,400" caption="0,0,0,75" sizebox="0,0,0,0"> <!-- 窗口的初始尺寸(宽800,高600)、窗口的最小尺寸(宽600,高400)、标题栏拖拽区域(高32)、可拖拽边框大小(这里添加sizebox后就可以拖拽边框调整大小了) --><Font id = "1" name="微软雅黑" size="15" italic="false" /> <Font id="3" name="微软雅黑" size="12" italic="false" /><Default shared="true" name="CheckBox" value="textcolor=&quot;#FF666666&quot; hottextcolor=&quot;#FF666666&quot; selectedtextcolor=&quot;#FF666666&quot; disabledtextcolor=&quot;#FFbac0c5&quot; textpadding=&quot;20,0,0,0&quot; align=&quot;left&quot; hotimage=&quot;file='hotchecked.jpg' dest='0,-2,21,19'&quot; selectedimage=&quot;file='checked.jpg' dest='0,-2,21,19'&quot; normalimage=&quot;file='unchecked.jpg' dest='0,-2,21,19'&quot;"/><Default shared="true" name="RichEdit" value="focusbordercolor=&quot;#FF58A8EC&quot; bordercolor=&quot;#FFC7C7C7&quot; height=&quot;40&quot; width=&quot;290&quot; bordersize=&quot;1&quot; inset=&quot;4,12,4,2&quot; font=&quot;1&quot; multiline=&quot;false&quot; enabled=&quot;true&quot; rich=&quot;true&quot; readonly=&quot;false&quot;" /><!-- 窗体加边框需要设置内边距,否则内部的虚拟窗口重绘时会覆盖边框 --><VerticalLayout bordersize="1" bordercolor="#FF999999" inset="1,1,1,1"><!--标题栏--><HorizontalLayout height="75" bkcolor="#FFEFF2F6"><VerticalLayout></VerticalLayout> <!--占位符--><!--上图片--><VerticalLayout width="143"><VerticalLayout></VerticalLayout><Control bkimage="logo.png" height="52" width="143"/><VerticalLayout></VerticalLayout></VerticalLayout><HorizontalLayout><!--按钮组--><HorizontalLayout></HorizontalLayout><Button name="setbtn" width="25" height="25" padding="5,8,5,0" normalimage="file='btn_set.png'" hotimage="file='btn_set_hot.png'"/><Button name="minbtn" width="25" height="25" padding="5,8,5,0" normalimage="file='btn_min.png'" hotimage="file='btn_min_hot.png'"/><Button name="closebtn" width="25" height="25" padding="5,8,5,0" normalimage="file='btn_close.png'" hotimage="file='btn_close_hot.png'"/></HorizontalLayout></HorizontalLayout><!-- 客户区 --><HorizontalLayout bkcolor="#FFFFFFFF"> <!-- 整个窗口的背景色 --><!-- 客户区的左右结构 --><VerticalLayout width="325"><HorizontalLayout height="94"><VerticalLayout></VerticalLayout><Control padding="0,32,0,32" bkimage="scan_login.jpg" width="117" height="30"/><VerticalLayout></VerticalLayout></HorizontalLayout><HorizontalLayout height="37"><VerticalLayout></VerticalLayout><Text name="linkOpenApp" width="210" align="center" padding="0,0,0,17" font="1" text="请使用{a /download#android?from=guanjia&amp;version=7.13.0.21&amp;channel=00000000000000000000000000000000}{c #3CB8FF}百度网盘App{/c}{/a}扫码登录" showhtml="true" /><VerticalLayout></VerticalLayout></HorizontalLayout><HorizontalLayout height="154"><!-- Control没有mouseenter和mouseleave消息,因为控件中未实现将这两个事件转化为消息,故单独实现了CMoveControlUI类(MoveControl标签) --><!-- <Control name="ImageQR" mouse="true" bkimage="qr.jpg" padding="0,0,0,0" width="154" height="154"/> --><!-- pos的4个值分别表示左上右下距离x轴(左右)或y轴(上下)的距离--><MoveControl float="true" pos="86,0,240,154" name="ImageQR" bkimage="file='qr.jpg' dest='0,0,154,154'" padding="0,0,0,0" /><!-- mouse要设置成false,否则该控件与ImageQR的重叠部分,会影响ImageQR的mouse事件 --><MoveControl name="ImageHelp" float="true" pos="188,0,303,154" mouse="false" visible="true" bkimage=""/><!-- <VerticalLayout></VerticalLayout> --></HorizontalLayout><HorizontalLayout height="51"><VerticalLayout></VerticalLayout><Button text="" normalimage="btn_refresh_qr.jpg" padding="0,15,0,0" hotimage="btn_refresh_qr_hot.jpg" width="102" height="36" /><VerticalLayout></VerticalLayout></HorizontalLayout></VerticalLayout><VerticalLayout><!-- 账号密码登录、短信快捷登录 --><VerticalLayout name="PasswordLogin" visible="true"><HorizontalLayout padding="0,35,0,10"><HorizontalLayout></HorizontalLayout><HorizontalLayout width="290"><Text font="1" text="账号密码登录" width="100"/><VerticalLayout></VerticalLayout><Text name="LinkUseMsgLogin" font="1" width="106" text="{a}{c #3CB8FF}短信快捷登陆&gt;{/c}{/a}" showhtml="true"/></HorizontalLayout><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="20"><HorizontalLayout></HorizontalLayout><Text name="PasswordLoginWarn" text="请输入密码" bkimage="file='info_error.jpg' dest='0,0,20,20'" textpadding="22,0,0,0" font="3" width="290" padding="0,0,0,0" textcolor="#FFFF4040"/><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="45" padding="0,0,0,15"><HorizontalLayout></HorizontalLayout><RichEdit name="edtUsername" textcolor="#FF000000" tooltip="手机/邮箱/用户名" textpadding="30,0,0,0" bkimage="file='edt_user_placeholder.jpg' dest='0,7,140,37'" /><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="45" padding="0,0,0,15"><HorizontalLayout></HorizontalLayout><RichEdit name="edtPassword" password="true" textpadding="30,0,0,0" textcolor="#FF000000" tooltip="请输入密码" bkimage="file='edt_pass_placeholder.jpg' dest='0,7,140,37'" /><HorizontalLayout></HorizontalLayout></HorizontalLayout><!-- checkbox --><HorizontalLayout><HorizontalLayout></HorizontalLayout><HorizontalLayout width="290"><CheckBox name="chkRememberPass" height="20" font="3" text="记住密码" padding="0,0,25,0"/><CheckBox name="chkAutoLogin" height="20" font="3" text="自动登录" /><HorizontalLayout></HorizontalLayout><Text name="linkForgetPass" text="{a /?getpass_index}{c #3CB8FF}忘记密码?{/c}{/a}" font="3" width="60" padding="0,4,0,0" showhtml="true" align="right"/></HorizontalLayout><HorizontalLayout></HorizontalLayout></HorizontalLayout></VerticalLayout><!-- 用短信验证码登录 --><VerticalLayout name="MsgLogin" height="200" visible="false"><HorizontalLayout padding="0,35,0,10"><HorizontalLayout></HorizontalLayout><HorizontalLayout width="290"><Text font="1" text="短信快捷登录" width="100"/><VerticalLayout></VerticalLayout><Text name="LinkUsePasswordLogin" font="1" width="106" text="{a}{c #3CB8FF}账号密码登录&gt;{/c}{/a}" showhtml="true"/></HorizontalLayout><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="20"><HorizontalLayout></HorizontalLayout><Text name="MsgLoginWarn" text="输入手机号" bkimage="file='info_error.jpg' dest='0,0,20,20'" textpadding="22,0,0,0" font="3" width="290" padding="0,0,0,0" textcolor="#FFFF4040"/><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="45" padding="0,0,0,15"><HorizontalLayout></HorizontalLayout><RichEdit name="edtPhone" textcolor="#FF000000" textpadding="30,0,0,0" tooltip="输入手机号" bkimage="file='edt_phone_placeholder.jpg' dest='0,4,140,34'" /><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout height="45" padding="0,0,0,5"><HorizontalLayout></HorizontalLayout><RichEdit name="edtCode" width="155" textpadding="30,0,0,0" textcolor="#FF000000" tooltip="输入动态密码" bkimage="file='edt_msg_placeholder.jpg' dest='0,4,140,34'" /><Button padding="13,0,0,0" height="40" borderround="3,3" font="3" text="获取动态密码" width="120" bordersize="1" bordercolor="#06A8FF" textcolor="#06A8FF"/><HorizontalLayout></HorizontalLayout></HorizontalLayout></VerticalLayout><!-- 登录按钮 --><HorizontalLayout height="50" padding="0,10,0,10"><HorizontalLayout></HorizontalLayout><Button width="310" height="50" normalimage="btn_login.jpg" hotimage="btn_login_hot.jpg"/><HorizontalLayout></HorizontalLayout></HorizontalLayout><HorizontalLayout name="BDProtocolLayout" height="47" visible="false"><VerticalLayout></VerticalLayout><!-- align=center在超链接的时候有bug,鼠标点击事件不能正确响应 --><Text name="BDProtocol" padding="0,0,0,30" width="180" text="阅读并接受{a /static/passpc-account/html/protocal.html}{c #3CB8FF}《百度用户协议》{/c}{/a}" font="3" textcolor="#FF666666" align="left" showhtml="true" /><VerticalLayout></VerticalLayout></HorizontalLayout><!-- 注册账号以及分享 --><HorizontalLayout height="50" inset="0,0,0,15"><HorizontalLayout></HorizontalLayout><HorizontalLayout width="290"><Text name="linkRegistry" text="{a /v2/?reg&amp;regType=1&amp;overseas=1&amp;u=/&amp;tpl=netdisk&amp;from=guanjia&amp;version=7.13.0.21&amp;channel=00000000000000000000000000000000}{c #3CB8FF}注册账号{/c}{/a}" font="3" textpadding="0,9,0,0" showhtml="true"/><Button width="30" height="30" bkimage="btn_wechat.jpg" /><Button width="30" height="30" bkimage="btn_weibo.jpg" /><Button width="30" height="30" bkimage="btn_qq.jpg" /></HorizontalLayout><HorizontalLayout></HorizontalLayout></HorizontalLayout></VerticalLayout></HorizontalLayout></VerticalLayout></Window>

networkset.xml

<?xml version="1.0" encoding="UTF-8"?><Window size="432,206" sizebox="0,0,0,0" caption="0,0,0,34" ><!-- Font标签的shared要设置成true,否则combobox下拉后字体会发生改变 --><Font id="1" name="微软雅黑" textcolor="#FF636363" size="13" shared="true"/><Font id="2" name="微软雅黑" textcolor="#FF636363" size="10" shared="true"/><!-- 窗体加边框需要设置内边距,否则内部的虚拟窗口重绘时会覆盖边框 --><VerticalLayout bordersize="1" bordercolor="#FF999999" inset="1,1,1,1"><!-- 标题栏 --><HorizontalLayout height="34" bkcolor="#FFEEF0F5"><!-- 标题和关闭按钮 --><Text bkimage="file='bd_logo.jpg' dest='0,0,30,30'" width="100" text="网络设置" font="1" textpadding="32,4,0,0"/><HorizontalLayout></HorizontalLayout><Button name="closebtn" normalimage="btn_close.png" hotimage="btn_close_hot.png" width="25" height="25"/></HorizontalLayout><!-- 客户区 --><VerticalLayout bkcolor="#FFFFFFFF"><HorizontalLayout height="30" padding="0,35,0,0" ><Text text="类型" font="1" width="30" padding="20,0,10,0"/><Combo bordersize="1" itemfont="1" bordercolor="#FFB5C6DB" width="140" height="20" bkimage="file='combobox.png' dest='122,2,137,17'"><ListLabelElement selected="true" text="不使用代理"/><ListLabelElement text="使用HTTP代理"/><ListLabelElement text="使用SOCK代理"/><ListLabelElement text="使用IE代理"/></Combo></HorizontalLayout><HorizontalLayout height="20" padding="0,20,0,0"><Text text="地址" font="1" width="30" padding="20,0,10,0"/> <RichEdit bordercolor="#FFB5C6DB" focusbordercolor="#FFB5C6DB" font="2" height="20" width="140" inset="3,2,0,0" /><Text text="端口" font="1" width="30" padding="50,0,10,0"/> <RichEdit bordercolor="#FFB5C6DB" focusbordercolor="#FFB5C6DB" font="2" height="20" width="90" inset="3,2,0,0" /></HorizontalLayout><HorizontalLayout float="true" pos="0,170,0,200"><Button text="确定" width="72" height="24"/><Button text="取消" width="72" height="24"/></HorizontalLayout></VerticalLayout></VerticalLayout></Window>

main.cpp

// 定义应用程序的入口点。//#include "stdafx.h"#include "duiTest.h"#include <UIlib.h>#include <shellapi.h>using namespace DuiLib;#define TIMER_QR_MOVE 1001#define TIMER_QR_RESTORE 1002#define TIMER_INVALIDATE 1003#ifdef _DEBUG# ifdef _UNICODE# pragma comment(lib, "DuiLib_ud.lib")# else# pragma comment(lib, "DuiLib_d.lib")# endif#else# ifdef _UNICODE# pragma comment(lib, "DuiLib_u.lib")# else# pragma comment(lib, "DuiLib.lib")# endif#endif//重写一个可以响应mouseenter和mousemove的control控件class CMoveControlUI :public CControlUI{public:virtual void DoEvent(TEventUI&event){if (event.Type == UIEVENT_MOUSEENTER){m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSEENTER, event.wParam, event.lParam);return;}if (event.Type == UIEVENT_MOUSELEAVE){m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSELEAVE, event.wParam, event.lParam);return;}if (m_pParent != NULL) m_pParent->DoEvent(event);}LPVOID GetInterface(LPCTSTR pstrName){if (_tcscmp(pstrName, _T("MoveControl")) == 0) return static_cast<CMoveControlUI*>(this);return CControlUI::GetInterface(pstrName);}LPCTSTR GetClass() const{return _T("MoveControl");}};class CSetFrameWnd : public WindowImplBase{public:virtual LPCTSTR GetWindowClassName() const { return _T("NetworkSet"); }virtual CDuiString GetSkinFile() { return _T("networkset.xml"); }virtual CDuiString GetSkinFolder() { return _T("skin"); }virtual void Notify(TNotifyUI& msg) override{__super::Notify(msg);}};class CMainFrameWnd : public WindowImplBase{public:virtual LPCTSTR GetWindowClassName() const { return _T("DUIMainFrame"); }virtual CDuiString GetSkinFile() { return _T("test.xml"); }virtual CDuiString GetSkinFolder() { return _T("skin"); }virtual CControlUI* CreateControl(LPCTSTR pstrClass) override{//创建自定义控件if (0 == _tcsicmp(pstrClass, _T("MoveControl"))){return new CMoveControlUI;}return __super::CreateControl(pstrClass);}//初始化virtual void InitWindow() override{//刷新一次窗口,猜测richedit在绘制背景图片后有个bug??初次点击输入账号会自动focus到输入密码的richedit::SetTimer(GetHWND(), TIMER_INVALIDATE, 800, NULL);}virtual void Notify(TNotifyUI& msg){if (msg.sType == DUI_MSGTYPE_CLICK){if (msg.pSender->GetName() == _T("setbtn")){//弹出设置窗口!CSetFrameWnd setFrameWnd;//第一个参数为NULL时为非模态窗,否则为模态窗setFrameWnd.Create(this->GetHWND(), _T("SetFrameWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);setFrameWnd.CenterWindow();setFrameWnd.ShowModal();}else if (msg.pSender->GetName() == _T("ImageQR")){}else if (msg.pSender->GetName() == _T("chkAutoLogin")){//勾选自动登录CCheckBoxUI* pAutoLogin = static_cast<CCheckBoxUI*>(msg.pSender);//此时虽然点击了勾选,但实际上控件还处于未勾选状态if (pAutoLogin && !pAutoLogin->GetCheck()){//自动勾选记住密码CCheckBoxUI* pRememberPass = static_cast<CCheckBoxUI*>(m_PaintManager.FindControl(_T("chkRememberPass")));if (pRememberPass && !pRememberPass->GetCheck()){pRememberPass->SetCheck(true, false);}}}else if (msg.pSender->GetName() == _T("chkRememberPass")){//取消勾选记住密码时,自动取消自动登录选项CCheckBoxUI* pRememberPass = static_cast<CCheckBoxUI*>(msg.pSender);if (pRememberPass && pRememberPass->GetCheck()){//取消自动登录选项CCheckBoxUI* pAutoLogin = static_cast<CCheckBoxUI*>(m_PaintManager.FindControl(_T("chkAutoLogin")));if (pAutoLogin && pAutoLogin->GetCheck()){pAutoLogin->SetCheck(false, false);}}}}else if (msg.sType == DUI_MSGTYPE_LINK){if (msg.pSender->GetName() == _T("LinkUseMsgLogin") || msg.pSender->GetName() == _T("LinkUsePasswordLogin")){bool bUseMsgLogin = (msg.pSender->GetName() == _T("LinkUseMsgLogin"));//隐藏账号密码登录,并显示手机验证码登录CVerticalLayoutUI*pMsgLogin = static_cast<CVerticalLayoutUI*>(this->m_PaintManager.FindControl(_T("MsgLogin")));if (pMsgLogin)pMsgLogin->SetVisible(bUseMsgLogin);CVerticalLayoutUI*pPasswordLogin = static_cast<CVerticalLayoutUI*>(this->m_PaintManager.FindControl(_T("PasswordLogin")));if (pPasswordLogin)pPasswordLogin->SetVisible(!bUseMsgLogin);CHorizontalLayoutUI* pBDProtocol = static_cast<CHorizontalLayoutUI*>(this->m_PaintManager.FindControl(_T("BDProtocolLayout")));if (pBDProtocol)pBDProtocol->SetVisible(bUseMsgLogin);}else if (msg.pSender->GetName() == _T("linkOpenApp") ||msg.pSender->GetName() == _T("linkForgetPass") ||msg.pSender->GetName() == _T("linkRegistry") ||msg.pSender->GetName() == _T("BDProtocol")){//打开超链接CTextUI *pLinkOpenApp = static_cast<CTextUI*>(msg.pSender);if (pLinkOpenApp){//用默认浏览器打开网页::ShellExecute(NULL, _T("open"), pLinkOpenApp->GetLinkContent(0)->GetData(), NULL, NULL, SW_SHOW);}}}else if (msg.sType == DUI_MSGTYPE_MOUSEENTER){//移动图片if (msg.pSender->GetName() == _T("ImageQR") || msg.pSender->GetName() == _T("ImageHelp")){::KillTimer(GetHWND(), TIMER_QR_MOVE);::KillTimer(GetHWND(), TIMER_QR_RESTORE);::SetTimer(GetHWND(), TIMER_QR_MOVE, 10, NULL);}}else if (msg.sType == DUI_MSGTYPE_MOUSELEAVE){//复原图片if (msg.pSender->GetName() == _T("ImageQR") || msg.pSender->GetName() == _T("ImageHelp")){::KillTimer(GetHWND(), TIMER_QR_MOVE);::KillTimer(GetHWND(), TIMER_QR_RESTORE);::SetTimer(GetHWND(), TIMER_QR_RESTORE, 10, NULL);}}else if (msg.sType == DUI_MSGTYPE_KILLFOCUS){//richedit失去焦点if (msg.pSender->GetName() == _T("edtPhone")){//如果此时没有数据,则显示placeholderCRichEditUI *pEdtPhone = static_cast<CRichEditUI*>(msg.pSender);if (pEdtPhone && pEdtPhone->GetText().IsEmpty()){pEdtPhone->SetBkImage(_T("file='edt_phone_placeholder.jpg' dest='0,4,140,34'"));}}else if (msg.pSender->GetName() == _T("edtCode")){CRichEditUI *pEdtCode = static_cast<CRichEditUI*>(msg.pSender);if (pEdtCode && pEdtCode->GetText().IsEmpty()){pEdtCode->SetBkImage(_T("file='edt_msg_placeholder.jpg' dest='0,4,140,34'"));}}else if (msg.pSender->GetName() == _T("edtUsername")){CRichEditUI *pEdtUsername = static_cast<CRichEditUI*>(msg.pSender);if (pEdtUsername && pEdtUsername->GetText().IsEmpty()){pEdtUsername->SetBkImage(_T("file='edt_user_placeholder.jpg' dest='0,7,140,37'"));pEdtUsername->Invalidate();}}else if (msg.pSender->GetName() == _T("edtPassword")){CRichEditUI *pEdtPassword = static_cast<CRichEditUI*>(msg.pSender);if (pEdtPassword && pEdtPassword->GetText().IsEmpty()){pEdtPassword->SetBkImage(_T("file='edt_pass_placeholder.jpg' dest='0,7,140,37'"));pEdtPassword->Invalidate();}}}else if (msg.sType == DUI_MSGTYPE_SETFOCUS){//richedit获得焦点if (msg.pSender->GetName() == _T("edtPhone")){//如果没有数据,则清除placeholder背景图片CRichEditUI *pEdtPhone = static_cast<CRichEditUI*>(msg.pSender);if (pEdtPhone && pEdtPhone->GetText().IsEmpty()){pEdtPhone->SetBkImage(_T("file='edt_phone.jpg' dest='0,7,30,37'"));}}else if (msg.pSender->GetName() == _T("edtCode")){CRichEditUI *pEdtCode = static_cast<CRichEditUI*>(msg.pSender);if (pEdtCode && pEdtCode->GetText().IsEmpty()){pEdtCode->SetBkImage(_T("file='edt_msg.jpg' dest='0,7,30,37'"));}}else if (msg.pSender->GetName() == _T("edtUsername")){CRichEditUI *pEdtUsername = static_cast<CRichEditUI*>(msg.pSender);if (pEdtUsername && pEdtUsername->GetText().IsEmpty()){pEdtUsername->SetBkImage(_T("file='edt_user.png' dest='0,7,30,37'"));pEdtUsername->Invalidate();}}else if (msg.pSender->GetName() == _T("edtPassword")){CRichEditUI *pEdtPassword = static_cast<CRichEditUI*>(msg.pSender);if (pEdtPassword && pEdtPassword->GetText().IsEmpty()){pEdtPassword->SetBkImage(_T("file='edt_pass.png' dest='0,7,30,37'"));pEdtPassword->Invalidate();}}}//基类中处理了一些默认按钮的点击事件,子类不处理的就给转到基类__super::Notify(msg);}//通过定时器来实现动画效果virtual LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) override{//switch (uMsg){case WM_TIMER:if (wParam == TIMER_QR_MOVE || wParam == TIMER_QR_RESTORE){static int nMove = 0;if (wParam == TIMER_QR_MOVE){//移动CMoveControlUI *pImageQR = static_cast<CMoveControlUI*>(m_PaintManager.FindControl(_T("ImageQR")));if (pImageQR){if (nMove > 10){//显示帮助图片CMoveControlUI* pImageHelp = static_cast<CMoveControlUI*>(m_PaintManager.FindControl(_T("ImageHelp")));if (pImageHelp){pImageHelp->SetBkImage(_T("scan_help.jpg"));//开启mouse事件,事件响应同ImageQR控件pImageHelp->SetMouseEnabled(true);}::KillTimer(GetHWND(), TIMER_QR_MOVE);return 0;}++nMove;SIZE moveSize;moveSize.cx = -5;moveSize.cy = 0;pImageQR->Move(moveSize);m_PaintManager.Invalidate();}}else if (wParam == TIMER_QR_RESTORE){//恢复CMoveControlUI *pImageQR = static_cast<CMoveControlUI*>(m_PaintManager.FindControl(_T("ImageQR")));if (pImageQR){CMoveControlUI* pImageHelp = static_cast<CMoveControlUI*>(m_PaintManager.FindControl(_T("ImageHelp")));if (pImageHelp && _wcsicmp(pImageHelp->GetBkImage(), _T("scan_help.jpg")) == 0){pImageHelp->SetBkImage(_T(""));}if (nMove <= 0){//关闭mouse事件pImageHelp->SetMouseEnabled(false);::KillTimer(GetHWND(), TIMER_QR_RESTORE);return 0;}--nMove;SIZE moveSize;moveSize.cx = 5;moveSize.cy = 0;pImageQR->Move(moveSize);m_PaintManager.Invalidate();}}}else if (wParam == TIMER_INVALIDATE){::KillTimer(GetHWND(), TIMER_INVALIDATE);m_PaintManager.Invalidate();}break;default:break;}return WindowImplBase::HandleCustomMessage(uMsg, wParam, lParam, bHandled);}};int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow){CPaintManagerUI::SetInstance(hInstance);CMainFrameWnd mainFrame;mainFrame.Create(NULL, _T("MainWindow"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);mainFrame.CenterWindow();mainFrame.ShowModal();return 0;}

如果觉得《duilib实战1-模仿百度网盘登录界面》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。