我在界面相隔挺远的位置添加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='button_nor.bmp' corner='4,2,4,2' fade='200' hsl='true'" hotimage="file='button_over.bmp' corner='4,2,4,2' fade='200' hsl='true'" pushedimage="file='button_down.bmp' corner='4,2,4,2' fade='200' hsl='true' " />
<MyMfcWnd name="btnMfc" text="MFC Button" float="true" pos="200,202,350,232" textcolor="#FF000000" disabledtextcolor="#FFA7A6AA" align="center" normalimage="file='button_nor.bmp' corner='4,2,4,2' fade='200' hsl='true'" hotimage="file='button_over.bmp' corner='4,2,4,2' fade='200' hsl='true'" pushedimage="file='button_down.bmp' corner='4,2,4,2' fade='200' hsl='true' " />
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
添加宏定义