duilib中使用mfc控件

我在界面相隔挺远的位置添加2个mfc控件,

需要添加: 

1. 添加 CMfcWndUI 类,这是为了调用mfc控件用的

2. 添加 duilib界面 CDuiFrameWnd

3.重写 2中界面的virtual CControlUI* CreateControl(LPCTSTR pstrClassName); 函数

需要注意的地方:

1. 需要先在xlm上有对应的控件  MyWin32Wnd MyMfcWnd为对应的类名

        <MyWin32Wnd name="btnMfc" text="MFC Button" float="true" pos="39,202,199,232" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file=&apos;button_nor.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos;" hotimage="file=&apos;button_over.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos;" pushedimage="file=&apos;button_down.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos; " />
        <MyMfcWnd name="btnMfc" text="MFC Button" float="true" pos="200,202,350,232" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file=&apos;button_nor.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos;" hotimage="file=&apos;button_over.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos;" pushedimage="file=&apos;button_down.bmp&apos; corner=&apos;4,2,4,2&apos; fade=&apos;200&apos; hsl=&apos;true&apos; " />
    

2.CControlUI* CDuiFrameWnd::CreateControl(LPCTSTR pstrClassName)中 

pstrClassName 为xml中类名

3.m_pButton->Create( WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, CRect(0, 0, 0, 0), CWnd::FromHandle(m_PaintManager.GetPaintWindow()), MFC_BUTTON_ID);

中create中 CRect的参数为 左上右下,不同控件,修改CRect的位置。

4. #define  MFC_BUTTON_ID        8001   

添加宏定义

参考:MFC与duilib之间控件相互调用_mfc程序调用duilib_byxdaz的博客-CSDN博客https://blog.csdn.net/byxdaz/article/details/72862013?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168550959016782425133423%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168550959016782425133423&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-6-72862013-null-null.142%5Ev88%5Econtrol_2,239%5Ev2%5Einsert_chatgpt&utm_term=duilib%E4%B8%AD%E4%BD%BF%E7%94%A8%20mfc%20%20%E6%8E%A7%E4%BB%B6&spm=1018.2226.3001.4187

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值