// 这段 MFC 示例源代码演示如何使用 MFC Microsoft Office Fluent 用户界面 // (“Fluent UI”)。该示例仅供参考, // 用以补充《Microsoft 基础类参考》和 // MFC C++ 库软件随附的相关电子文档。 // 复制、使用或分发 Fluent UI 的许可条款是单独提供的。 // 若要了解有关 Fluent UI 许可计划的详细信息,请访问 // https://go.microsoft.com/fwlink/?LinkId=238214. // // 版权所有(C) Microsoft Corporation // 保留所有权利。 #include "stdafx.h" #include "framework.h" #include "DevicesWnd.h" #include "Resource.h" #include "MainFrm.h" #include "SATHelper.h" #include #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[] = __FILE__; #define new DEBUG_NEW #endif extern CMainFrame* g_pMainFrame; // 重启进程按钮id; #define ID_BUTTON_RESTART_PROC 4 // 复制框控件id; #define ID_CHECKBOX_SIGNAL_TYPE 5 // 下拉框控件id; #define ID_COMBOBOX_SIGNAL_FILE 6 ///////////////////////////////////////////////////////////////////////////// // CResourceViewBar CDevicesWnd::CDevicesWnd() noexcept { m_nComboHeight = 0; } CDevicesWnd::~CDevicesWnd() { RedRat::UnloadLibrary(); } BEGIN_MESSAGE_MAP(CDevicesWnd, CDockablePane) ON_WM_CREATE() ON_WM_SIZE() ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties) ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties) ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties) ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties) ON_COMMAND(ID_PROPERTIES1, OnProperties1) ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1) ON_COMMAND(ID_PROPERTIES2, OnProperties2) ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2) ON_WM_SETFOCUS() ON_WM_SETTINGCHANGE() ON_WM_PAINT() ON_WM_CONTEXTMENU() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CResourceViewBar 消息处理程序 void CDevicesWnd::AdjustLayout() { if (GetSafeHwnd() == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic())) { return; } CRect rectClient; GetClientRect(rectClient); m_dlgService.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight, rectClient.Width(), rectClient.Height(), SWP_NOACTIVATE); } int CDevicesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDockablePane::OnCreate(lpCreateStruct) == -1) return -1; CRect rectDummy; rectDummy.SetRectEmpty(); // 创建组合: const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; if (!m_dlgService.Create(IDD_DLG_SERVICE, this)) { TRACE0("未能创建遥控器主窗口 \n"); return -1; // 未能创建 } m_dlgService.ShowWindow(SW_SHOW); // 设置最小窗体; SetMinSize((530, 300)); // 校正布局; AdjustLayout(); return 0; } void CDevicesWnd::OnSize(UINT nType, int cx, int cy) { CDockablePane::OnSize(nType, cx, cy); TRACE2("坐标:%d,%d\n", cx, cy); AdjustLayout(); } void CDevicesWnd::OnExpandAllProperties() { //m_wndPropList.ExpandAll(); } void CDevicesWnd::OnUpdateExpandAllProperties(CCmdUI* /* pCmdUI */) { } void CDevicesWnd::OnSortProperties() { //m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode()); } void CDevicesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI) { //pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode()); } void CDevicesWnd::OnProperties1() { // TODO: 在此处添加命令处理程序代码 } void CDevicesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/) { // TODO: 在此处添加命令更新 UI 处理程序代码 } void CDevicesWnd::OnProperties2() { // TODO: 在此处添加命令处理程序代码 } void CDevicesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/) { // TODO: 在此处添加命令更新 UI 处理程序代码 } void CDevicesWnd::OnSetFocus(CWnd* pOldWnd) { CDockablePane::OnSetFocus(pOldWnd); } void CDevicesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { CDockablePane::OnSettingChange(uFlags, lpszSection); //SetPropListFont(); } void CDevicesWnd::SetPropListFont() { ::DeleteObject(m_fntPropList.Detach()); LOGFONT lf; afxGlobalData.fontRegular.GetLogFont(&lf); NONCLIENTMETRICS info; info.cbSize = sizeof(info); afxGlobalData.GetNonClientMetrics(info); lf.lfHeight = info.lfMenuFont.lfHeight; lf.lfWeight = info.lfMenuFont.lfWeight; lf.lfItalic = info.lfMenuFont.lfItalic; m_fntPropList.CreateFontIndirect(&lf); //m_wndObjectCombo.SetFont(&m_fntPropList); } // 如果CDockablePane无控件,改变大小时背景会刷新失败; // 所以要重载onpaint; void CDevicesWnd::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CDockablePane::OnPaint(); CRect rc; GetClientRect(rc); CBrush brush; brush.CreateSolidBrush(0xFFEFD5); dc.FillRect(&rc, &brush); } void CDevicesWnd::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/) { // TODO: 在此处添加消息处理程序代码 }