動態創建cursor

void CbobDlg::OnBnClickedOk()
{
 int* pCursorBuffer = (int *)malloc(132*132*4);
 //memset(pCursorBuffer,0x0Aff0000,32*32*4);

 for (int i=0;i<132*132; i++)
 {
  pCursorBuffer[i] = 0x80ff0000;
 }

 

 //HCURSOR pCursor = CreateCursor(NULL,0,0,38,38,pCursorBuffer,pCursorBuffer);
 //::SetCursor(pCursor);

 
 BITMAP bmp;
 bmp.bmType = 0;
 bmp.bmWidth = 132;
 bmp.bmHeight = 132;
 bmp.bmWidthBytes = 4*bmp.bmWidth;
 bmp.bmPlanes = 1;
 bmp.bmBitsPixel = 32;
 bmp.bmBits = pCursorBuffer;

 HBITMAP pBmp = CreateBitmapIndirect(&bmp);

 if (pBmp)
 {
  ICONINFO icon;
  icon.fIcon = false;
  icon.xHotspot = 10;
  icon.yHotspot = 10;
  icon.hbmColor = pBmp;
  icon.hbmMask = pBmp;

  HICON pIcon = CreateIconIndirect(&icon);

  if (pIcon)
  {
   //::SetClassLong(NULL,GCL_HCURSOR,(long)pIcon);
   ::SetCursor(pIcon);
  }
 }

 free(pCursorBuffer);

 

// OnOK();
}

BOOL CbobDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
 /*
 // TODO: Add your message handler code here and/or call default

 return CDialog::OnSetCursor(pWnd, nHitTest, message);
 */

 return true;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章