工控编程吧
标题:
上位机MFC鼠标光标颜色更改源代码
[打印本页]
作者:
qq263946146
时间:
2019-10-17 10:20
标题:
上位机MFC鼠标光标颜色更改源代码
(, 下载次数: 3)
上传
点击文件名下载附件
例程运行界面如上图,
点击按钮可以更改鼠标颜色,
具有一些参考价值。
关键源代码为:
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);
}
复制代码
源代码下载地址:
(, 下载次数: 0)
上传
点击文件名下载附件
[halcon]1[/halcon]
[MFC408]1[/MFC408]
[weixinlianxi]1[/weixinlianxi]
欢迎光临 工控编程吧 (https://www.gkbc8.com/)
Powered by Discuz! X3.4