上位机MFC鼠标光标颜色更改源代码
例程运行界面如上图,
点击按钮可以更改鼠标颜色,
具有一些参考价值。
关键源代码为:
- void CColorCursorTestDlg::OnCreateCursor()
- {
- do
- {
- //Clear
- if(NULL != m_hSourceBitmap)
- ::DeleteObject(m_hSourceBitmap);
- if(NULL != m_hAndMask)
- ::DeleteObject(m_hAndMask);
- if(NULL != m_hXorMask)
- ::DeleteObject(m_hXorMask);
- m_hSourceBitmap = GetCursorBitmap();
- ::SendMessage(::GetDlgItem(this->m_hWnd,IDC_ORIGINAL),STM_SETIMAGE ,
- (WPARAM)IMAGE_BITMAP,(LPARAM)m_hSourceBitmap);
- m_hXorMask = NULL;
- m_hAndMask = NULL;
- CColorCursor::GetMaskBitmaps(m_hSourceBitmap,RGB(0,0,0),m_hAndMask,m_hXorMask);
- if(NULL == m_hAndMask || NULL == m_hXorMask)
- {
- AfxMessageBox("Cannot create And and Xor masks...!");
- break;
- }
- ::SendMessage(::GetDlgItem(this->m_hWnd,IDC_AND),STM_SETIMAGE ,
- (WPARAM)IMAGE_BITMAP,(LPARAM)m_hAndMask);
- ::SendMessage(::GetDlgItem(this->m_hWnd,IDC_XOR),STM_SETIMAGE ,
- (WPARAM)IMAGE_BITMAP,(LPARAM)m_hXorMask);
- //Now create the real one
- if(NULL != m_hNewCursor)
- {
- ::DestroyIcon(m_hNewCursor);
- }
- m_hNewCursor = CColorCursor::CreateCursorFromBitmap(m_hSourceBitmap,RGB(0,0,0),0,0);
-
- ::SendMessage(::GetDlgItem(this->m_hWnd,IDC_CURSOR),STM_SETIMAGE ,
- (WPARAM)IMAGE_CURSOR,(LPARAM)m_hNewCursor);
- }
- while(0);
- }
复制代码 源代码下载地址:
上位机VC MFC程序开发精典实例大全源码与视频讲解配套下载408例 经历1年的编程与录制点击进入查看
如果您认可,可联系功能定制! 如果您着急,充值会员可直接联系发您资料!
|