| | |
| | | m_hIcon[0] = nullptr; |
| | | m_hIcon[1] = nullptr; |
| | | m_nIconWidth = 0; |
| | | m_nFlashState = 0; |
| | | } |
| | | |
| | | |
| | |
| | | if (BS_NORMAL <= index && index <= BS_DISABLE) { |
| | | m_crFrame[index] = color; |
| | | } |
| | | } |
| | | |
| | | void CBlButton::SetFrameColor(COLORREF color) |
| | | { |
| | | m_crFrame[BS_NORMAL] = color; |
| | | m_crFrame[BS_HOVER] = color; |
| | | m_crFrame[BS_PRESS] = color; |
| | | m_crFrame[BS_FOCUS] = color; |
| | | Invalidate(); |
| | | } |
| | | |
| | | void CBlButton::SetRoundWidth(int width) |
| | |
| | | m_nIconWidth = width; |
| | | } |
| | | |
| | | void CBlButton::Flash(int ms) |
| | | { |
| | | m_nFlashState = 1; |
| | | SetTimer(1, ms, nullptr); |
| | | } |
| | | |
| | | void CBlButton::StopFlash() |
| | | { |
| | | m_nFlashState = 0; |
| | | KillTimer(1); |
| | | } |
| | | |
| | | void CBlButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) |
| | | { |
| | | HDC hDC = lpDrawItemStruct->hDC; |
| | |
| | | |
| | | // è¾¹æ¡+èæ¯ |
| | | int state = GetDrawState(); |
| | | if (m_nFlashState != 0) { |
| | | if (state != BS_DISABLE) { |
| | | state = m_nFlashState == 1 ? BS_NORMAL : BS_PRESS; |
| | | } |
| | | } |
| | | HBRUSH hBrush = CreateSolidBrush(m_crBkgnd[state]); |
| | | HPEN hPen = CreatePen(PS_SOLID, state == BS_FOCUS ? 2 : 1, m_crFrame[state]); |
| | | HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen); |
| | |
| | | |
| | | // 徿 |
| | | RECT rcText = rcClient; |
| | | if (m_hIcon != nullptr) { |
| | | HICON hIcon = this->IsWindowEnabled() ? m_hIcon[0] : m_hIcon[01]; |
| | | if (hIcon != nullptr) { |
| | | int xIcon = (rcClient.right - rcClient.top - m_nIconWidth) / 2; |
| | | if (m_hMenu != nullptr) xIcon -= 10; |
| | | int yIcon = (rcClient.bottom - rcClient.top - m_nIconWidth) / 2; |
| | |
| | | } |
| | | |
| | | DrawIconEx(hDC, xIcon, yIcon, |
| | | this->IsWindowEnabled() ? m_hIcon[0] : m_hIcon[01], m_nIconWidth, m_nIconWidth, 0, 0, DI_NORMAL); |
| | | hIcon, m_nIconWidth, m_nIconWidth, 0, 0, DI_NORMAL); |
| | | rcText.top = yIcon + m_nIconWidth + 2; |
| | | } |
| | | |
| | | |
| | | // ææ¬ |
| | | HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); |
| | | CFont* pFont = GetFont(); |
| | | if (pFont != nullptr) { |
| | | hFont = (HFONT)pFont->GetSafeHandle(); |
| | | } |
| | | |
| | | |
| | | ::SelectObject(hDC, hFont); |
| | | ::SetBkMode(hDC, TRANSPARENT); |
| | |
| | | ON_WM_LBUTTONDOWN() |
| | | ON_CONTROL_REFLECT_EX(BN_CLICKED, &CBlButton::OnBnClicked) |
| | | ON_WM_LBUTTONUP() |
| | | ON_WM_TIMER() |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | blbNmhdr.dwData2 = dwData2; |
| | | pParent->SendMessage(WM_NOTIFY, (WPARAM)blbNmhdr.nmhdr.idFrom, (LPARAM)&blbNmhdr); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void CBlButton::OnTimer(UINT_PTR nIDEvent) |
| | | { |
| | | if (1 == nIDEvent) { |
| | | m_nFlashState++; |
| | | if (m_nFlashState > 2) m_nFlashState = 1; |
| | | Invalidate(); |
| | | } |
| | | |
| | | CButton::OnTimer(nIDEvent); |
| | | } |
| | |
| | | void SetRoundWidth(int width); |
| | | int GetDrawState(); |
| | | void SetFrameColor(int index, COLORREF color); |
| | | void SetFrameColor(COLORREF color); |
| | | void SetBkgndColor(int index, COLORREF color); |
| | | void SetTextColor(int index, COLORREF color); |
| | | void SetBkgndBmp(const char* pszBmpFile); |
| | |
| | | void SetCurrentMenuItem(UINT nPosition); |
| | | HMENU GetMenu(); |
| | | void SetIcon(HICON hIcon, HICON hIconGray, int width); |
| | | void Flash(int ms); |
| | | void StopFlash(); |
| | | |
| | | private: |
| | | BOOL CustomBitBlt(HDC hDC, LPRECT lprc, CString& strBkgndBmp, int nFrame, int nAllFrame, |
| | |
| | | HMENU m_hMenu; |
| | | HICON m_hIcon[2]; |
| | | int m_nIconWidth; |
| | | int m_nFlashState; // éªçç¶æï¼0ï¼ä¸éªï¼1å2为éªçåæ¢ä¸ |
| | | |
| | | public: |
| | | virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/); |
| | |
| | | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); |
| | | afx_msg BOOL OnBnClicked(); |
| | | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); |
| | | afx_msg void OnTimer(UINT_PTR nIDEvent); |
| | | }; |
| | | |
| | |
| | | #define BTN1_TEXT_FOCUS RGB(51, 51, 51) |
| | | #define BTN1_TEXT_DISABLE RGB(191, 191, 191) |
| | | |
| | | |
| | | /* 轴设å®é¡µé¢é¢è²å®ä¹ */ |
| | | |
| | | /* 5个æé®é¡µ, æé®èæ¯è²ï¼æ£å¸¸ç¶æ*/ |
| | | #define BTN_PAGE_FACE_NORMAL_COLOR RGB(240, 240, 240) |
| | | #define BTN_PAGE_FACE_SELECT_COLOR RGB(0, 122, 204) |
| | | #define BTN_PAGE_TEXT_NORMAL_COLOR RGB(22, 22, 22) |
| | | #define BTN_PAGE_TEXT_SELECT_COLOR RGB(222, 222, 222) |
| | | |
| | | /* JOG+, JOG-*/ |
| | | #define BTN_JOG_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_JOG_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_JOG_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_JOG_BKGND_NORMAL RGB(0, 232, 0) |
| | | #define BTN_JOG_BKGND_HOVER RGB(0, 222, 0) |
| | | #define BTN_JOG_BKGND_PRESS RGB(0, 168, 0) |
| | | |
| | | /* Sevæé® */ |
| | | #define BTN_SEV_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_SEV_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_SEV_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_SEV_BKGND_NORMAL RGB(0, 232, 0) |
| | | #define BTN_SEV_BKGND_HOVER RGB(0, 222, 0) |
| | | #define BTN_SEV_BKGND_PRESS RGB(222, 0, 0) |
| | | |
| | | /* Stopæé® */ |
| | | #define BTN_STOP_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_STOP_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_STOP_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_STOP_BKGND_NORMAL RGB(0, 168, 0) |
| | | #define BTN_STOP_BKGND_HOVER RGB(0, 138, 0) |
| | | #define BTN_STOP_BKGND_PRESS RGB(222, 0, 0) |
| | | |
| | | /* OPR æé® */ |
| | | #define BTN_OPR_FRAME_NORMAL RGB(88, 88, 88) |
| | | #define BTN_OPR_FRAME_HOVER RGB(88, 88, 88) |
| | | #define BTN_OPR_FRAME_PRESS RGB(88, 88, 88) |
| | | #define BTN_OPR_BKGND_NORMAL RGB(222, 222, 222) |
| | | #define BTN_OPR_BKGND_HOVER RGB(208, 208, 222) |
| | | #define BTN_OPR_BKGND_PRESS RGB(0, 232, 0) |
| | | |
| | | |
| | | /* æé®id */ |
| | | #define VIEW_TOOL_BTN_CLOSE 0x1016 |
| | | |
| | |
| | | m_bReady = FALSE; |
| | | m_bBusy = FALSE; |
| | | m_bErr = FALSE; |
| | | for (int i = 0; i < 9; i++) { |
| | | for (int i = 0; i < BTN_MAX; i++) { |
| | | m_pBlBtns[i] = new CBlButton(); |
| | | } |
| | | } |
| | |
| | | } |
| | | m_mapFonts.clear(); |
| | | |
| | | for (int i = 0; i < 9; i++) { |
| | | for (int i = 0; i < BTN_MAX; i++) { |
| | | delete m_pBlBtns[i]; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // æé®åå§å |
| | | m_pBlBtns[0]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, this); |
| | | m_pBlBtns[1]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, this); |
| | | m_pBlBtns[2]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP3, this); |
| | | m_pBlBtns[3]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP4, this); |
| | | m_pBlBtns[4]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP5, this); |
| | | m_pBlBtns[5]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_JOG_ADD, this); |
| | | m_pBlBtns[5]->SetFrameColor(BS_NORMAL, BTN_JOG_FRAME_NORMAL); |
| | | m_pBlBtns[5]->SetFrameColor(BS_HOVER, BTN_JOG_FRAME_HOVER); |
| | | m_pBlBtns[5]->SetFrameColor(BS_PRESS, BTN_JOG_FRAME_PRESS); |
| | | m_pBlBtns[5]->SetBkgndColor(BS_NORMAL, BTN_JOG_BKGND_NORMAL); |
| | | m_pBlBtns[5]->SetBkgndColor(BS_HOVER, BTN_JOG_BKGND_HOVER); |
| | | m_pBlBtns[5]->SetBkgndColor(BS_PRESS, BTN_JOG_BKGND_PRESS); |
| | | m_pBlBtns[6]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_JOG_SUB, this); |
| | | m_pBlBtns[6]->SetFrameColor(BS_NORMAL, BTN_JOG_FRAME_NORMAL); |
| | | m_pBlBtns[6]->SetFrameColor(BS_HOVER, BTN_JOG_FRAME_HOVER); |
| | | m_pBlBtns[6]->SetFrameColor(BS_PRESS, BTN_JOG_FRAME_PRESS); |
| | | m_pBlBtns[6]->SetBkgndColor(BS_NORMAL, BTN_JOG_BKGND_NORMAL); |
| | | m_pBlBtns[6]->SetBkgndColor(BS_HOVER, BTN_JOG_BKGND_HOVER); |
| | | m_pBlBtns[6]->SetBkgndColor(BS_PRESS, BTN_JOG_BKGND_PRESS); |
| | | m_pBlBtns[7]->SubclassDlgItem(IDC_BUTTON_AXIS_SEV, this); |
| | | m_pBlBtns[7]->SetFrameColor(BS_NORMAL, BTN_SEV_FRAME_NORMAL); |
| | | m_pBlBtns[7]->SetFrameColor(BS_HOVER, BTN_SEV_FRAME_HOVER); |
| | | m_pBlBtns[7]->SetFrameColor(BS_PRESS, BTN_SEV_FRAME_PRESS); |
| | | m_pBlBtns[7]->SetBkgndColor(BS_NORMAL, BTN_SEV_BKGND_NORMAL); |
| | | m_pBlBtns[7]->SetBkgndColor(BS_HOVER, BTN_SEV_BKGND_HOVER); |
| | | m_pBlBtns[7]->SetBkgndColor(BS_PRESS, BTN_SEV_BKGND_PRESS); |
| | | m_pBlBtns[8]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_STOP, this); |
| | | m_pBlBtns[8]->SetFrameColor(BS_NORMAL, BTN_STOP_FRAME_NORMAL); |
| | | m_pBlBtns[8]->SetFrameColor(BS_HOVER, BTN_STOP_FRAME_HOVER); |
| | | m_pBlBtns[8]->SetFrameColor(BS_PRESS, BTN_STOP_FRAME_PRESS); |
| | | m_pBlBtns[8]->SetBkgndColor(BS_NORMAL, BTN_STOP_BKGND_NORMAL); |
| | | m_pBlBtns[8]->SetBkgndColor(BS_HOVER, BTN_STOP_BKGND_HOVER); |
| | | m_pBlBtns[8]->SetBkgndColor(BS_PRESS, BTN_STOP_BKGND_PRESS); |
| | | |
| | | m_pBlBtns[BTN_PAGE1]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, this); |
| | | m_pBlBtns[BTN_PAGE2]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, this); |
| | | m_pBlBtns[BTN_PAGE3]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP3, this); |
| | | m_pBlBtns[BTN_PAGE4]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP4, this); |
| | | m_pBlBtns[BTN_PAGE5]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP5, this); |
| | | m_pBlBtns[BTN_JOG_ADD]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_JOG_ADD, this); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetFrameColor(BS_NORMAL, BTN_JOG_FRAME_NORMAL); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetFrameColor(BS_HOVER, BTN_JOG_FRAME_HOVER); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetFrameColor(BS_PRESS, BTN_JOG_FRAME_PRESS); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetBkgndColor(BS_NORMAL, BTN_JOG_BKGND_NORMAL); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetBkgndColor(BS_HOVER, BTN_JOG_BKGND_HOVER); |
| | | m_pBlBtns[BTN_JOG_ADD]->SetBkgndColor(BS_PRESS, BTN_JOG_BKGND_PRESS); |
| | | m_pBlBtns[BTN_JOG_SUB]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_JOG_SUB, this); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetFrameColor(BS_NORMAL, BTN_JOG_FRAME_NORMAL); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetFrameColor(BS_HOVER, BTN_JOG_FRAME_HOVER); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetFrameColor(BS_PRESS, BTN_JOG_FRAME_PRESS); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetBkgndColor(BS_NORMAL, BTN_JOG_BKGND_NORMAL); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetBkgndColor(BS_HOVER, BTN_JOG_BKGND_HOVER); |
| | | m_pBlBtns[BTN_JOG_SUB]->SetBkgndColor(BS_PRESS, BTN_JOG_BKGND_PRESS); |
| | | m_pBlBtns[BTN_JOG_SEV]->SubclassDlgItem(IDC_BUTTON_AXIS_SEV, this); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetFrameColor(BS_NORMAL, BTN_SEV_FRAME_NORMAL); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetFrameColor(BS_HOVER, BTN_SEV_FRAME_HOVER); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetFrameColor(BS_PRESS, BTN_SEV_FRAME_PRESS); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetBkgndColor(BS_NORMAL, BTN_SEV_BKGND_NORMAL); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetBkgndColor(BS_HOVER, BTN_SEV_BKGND_HOVER); |
| | | m_pBlBtns[BTN_JOG_SEV]->SetBkgndColor(BS_PRESS, BTN_SEV_BKGND_PRESS); |
| | | m_pBlBtns[BTN_JOG_STOP]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_STOP, this); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetFrameColor(BS_NORMAL, BTN_STOP_FRAME_NORMAL); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetFrameColor(BS_HOVER, BTN_STOP_FRAME_HOVER); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetFrameColor(BS_PRESS, BTN_STOP_FRAME_PRESS); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetBkgndColor(BS_NORMAL, BTN_STOP_BKGND_NORMAL); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetBkgndColor(BS_HOVER, BTN_STOP_BKGND_HOVER); |
| | | m_pBlBtns[BTN_JOG_STOP]->SetBkgndColor(BS_PRESS, BTN_STOP_BKGND_PRESS); |
| | | m_pBlBtns[BTN_JOG_OPR]->SubclassDlgItem(IDC_BUTTON_AXIS_TEST_OPR, this); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetFrameColor(BS_NORMAL, BTN_OPR_FRAME_NORMAL); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetFrameColor(BS_HOVER, BTN_OPR_FRAME_HOVER); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetFrameColor(BS_PRESS, BTN_OPR_FRAME_PRESS); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_NORMAL, BTN_OPR_BKGND_NORMAL); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_HOVER, BTN_OPR_BKGND_HOVER); |
| | | m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_PRESS, BTN_OPR_BKGND_PRESS); |
| | | |
| | | // åå§åå½å页é¢ä¸ºç¬¬ä¸é¡µ |
| | | m_currentPage = 1; |
| | |
| | | handleAxisOperation(AxisOperationType::OPR, true); |
| | | Sleep(200); |
| | | handleAxisOperation(AxisOperationType::OPR, false); |
| | | m_pBlBtns[BTN_JOG_OPR]->Flash(1000); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnBnClickedButtonAxisTestStop() |
| | |
| | | handleAxisOperation(AxisOperationType::STOP, true); |
| | | Sleep(200); |
| | | handleAxisOperation(AxisOperationType::STOP, false); |
| | | m_pBlBtns[BTN_JOG_OPR]->StopFlash(); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnSelchangeComboAxisName() |
| | |
| | | #include "BLLabel.h" |
| | | #include "CPLC.h" |
| | | |
| | | |
| | | #define BTN_MAX 10 |
| | | #define BTN_PAGE1 0 |
| | | #define BTN_PAGE2 1 |
| | | #define BTN_PAGE3 2 |
| | | #define BTN_PAGE4 3 |
| | | #define BTN_PAGE5 4 |
| | | #define BTN_JOG_ADD 5 |
| | | #define BTN_JOG_SUB 6 |
| | | #define BTN_JOG_SEV 7 |
| | | #define BTN_JOG_STOP 8 |
| | | #define BTN_JOG_OPR 9 |
| | | |
| | | |
| | | // CAxisSettingsDlg å¯¹è¯æ¡ |
| | | |
| | | enum class AxisOperationType { |
| | |
| | | CStatic m_staticAxisNO, m_staticAxisDescription, m_staticStartAddress; |
| | | CEdit m_editManualSpeed, m_editAutoSpeed, m_editAccelerationTime, m_editDecelerationTime, m_editJogDistance; |
| | | |
| | | CBlButton* m_pBlBtns[9]; |
| | | CBlButton* m_pBlBtns[BTN_MAX]; |
| | | std::map<int, CRect> m_mapCtrlLayouts; |
| | | std::map<int, CFont*> m_mapFonts; |
| | | |