// RecipeDeviceBindDlg.cpp: 实现文件 // #include "stdafx.h" #include "Servo.h" #include "afxdialogex.h" #include "RecipeDeviceBindDlg.h" #define IDC_EDIT_DEVICEID_BASE 3000 #define IDC_EDIT_DEVICENAME_BASE 3050 #define IDC_COMBO_RECIPEID_BASE 3100 // CRecipeDeviceBindDlg 对话框 IMPLEMENT_DYNAMIC(CRecipeDeviceBindDlg, CDialogEx) CRecipeDeviceBindDlg::CRecipeDeviceBindDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DIALOG_RECIPE_DEVICE_BIND, pParent) { } CRecipeDeviceBindDlg::~CRecipeDeviceBindDlg() { } void CRecipeDeviceBindDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CRecipeDeviceBindDlg, CDialogEx) END_MESSAGE_MAP() // CRecipeDeviceBindDlg 消息处理程序 BOOL CRecipeDeviceBindDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 // 设置固定大小(例如 600x400) SetWindowPos(nullptr, 0, 0, 600, 400, SWP_NOMOVE | SWP_NOZORDER); // 创建控件 const int totalControlWidth = 340; CRect clientRect; GetClientRect(&clientRect); int xStart = (clientRect.Width() - totalControlWidth) / 2; const int nRowCount = 8; const int nRowHeight = 30; const int yStart = 30; // 顶部起始高度 for (int i = 0; i < nRowCount; ++i) { int y = yStart + i * nRowHeight; CEdit* pEditID = new CEdit(); pEditID->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(xStart, y, xStart + 100, y + 25), this, IDC_EDIT_DEVICEID_BASE + i); CEdit* pEditName = new CEdit(); pEditName->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(xStart + 110, y, xStart + 210, y + 25), this, IDC_EDIT_DEVICENAME_BASE + i); CComboBox* pCombo = new CComboBox(); pCombo->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, CRect(xStart + 220, y, xStart + 340, y + 300), this, IDC_COMBO_RECIPEID_BASE + i); } return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }