The class CCursorMetadata
{
Virtual bool InitMetadata (HCURSOR HCURSOR, unsigned short sBitCount);
HDC m_hdc_mem;//The compatible DC memory of The desktop.
HBITMAP m_hBitmap;
LPBITMAPINFO m_lpBitmapInfo;//Pointer to the BITMAPINFO of the bitmap.
Void * m_lpBitmapBits;//Pointer to the bitmap bits values.
}
Bool CCursorMetadata: : InitMetadata (HCURSOR HCURSOR, unsigned short sBitCount)
{
ICONINFO ICONINFO;
if(! GetIconInfo (hCursor, & amp; IconInfo)) {
return false;
}
If (iconInfo hbmMask==NULL) {
return false;
}
Bool isColorShape=(iconInfo hbmColor!=NULL);
BITMAP bmMask;
if(! GetObject (iconInfo hbmMask, sizeof (BITMAP), (void *) & amp; BmMask)) {
DeleteObject (iconInfo hbmMask);
return false;
}
If (bmMask bmPlanes!=1 | | bmMask bmBitsPixel!=1) {
DeleteObject (iconInfo hbmMask);
return false;
}
Int iWidth=bmMask. BmWidth;
Int iHeight=isColorShape? BmMask. BmHeight: bmMask. BmHeight/2;
//int widthBytes=bmMask. BmWidthBytes;
HDC hdcDesktop=GetDC (NULL);
M_hdc_mem=CreateCompatibleDC (hdcDesktop);
Int cColor=(sBitCount<=8)? (1 & lt;Int iBmInfoSize=sizeof (BITMAPINFOHEADER) + cColor * sizeof (RGBQUAD);
M_lpBitmapInfo=(LPBITMAPINFO) new unsigned char [iBmInfoSize];
BITMAPINFOHEADER& BmiHeader=m_lpBitmapInfo - & gt; BmiHeader;
BmiHeader. BiSize=sizeof (BITMAPINFOHEADER);
BmiHeader. BiWidth=iWidth;
BmiHeader. BiHeight=iHeight;
BmiHeader. BiPlanes=1;
BmiHeader. BiBitCount=sBitCount;
BmiHeader. BiCompression=BI_RGB;
BmiHeader. BiSizeImage=(((bmiHeader. BiWidth * bmiHeader. BiBitCount + 31) & amp; ~ 31) & gt;> 3) * bmiHeader. BiHeight;
BmiHeader. BiXPelsPerMeter=0;
BmiHeader. BiYPelsPerMeter=0;
BmiHeader. BiClrUsed=0;
BmiHeader. BiClrImportant=0;
HBITMAP HBITMAP=CreateCompatibleBitmap (hdcDesktop, 1, 1);
GetDIBits (hdcDesktop hBitmap, 0, 0, NULL, m_lpBitmapInfo, DIB_RGB_COLORS);
DeleteObject (hBitmap);
M_hBitmap=CreateDIBSection (hdcDesktop m_lpBitmapInfo, DIB_RGB_COLORS, & amp; M_lpBitmapBits, NULL, 0);
SelectObject (m_hdc_mem m_hBitmap);
DeleteObject (iconInfo hbmMask);
Return (m_hBitmap!=NULL);
};
DrawIconEx (hCursor m_hdc_mem, 0, 0, 0, 0, NULL, DI_IMAGE);
NetSend (m_lpBitmapBits);
When the receiver to receive m_lpBitmapBits said bitmap data, how to display the cursor bitmap?
If use DrawIconEx function to draw the cursor, then how to get it by the bitmap byte of data corresponding to the HCURSOR? The second parameter, DrawIconEx
CodePudding user response:
The intention of the program is to want to let the receiver can monitor to the sending end of the mouse operation (mobile, shape changed, etc.), including the sender also can monitor when using a custom mouse, but is not restricted to the system take shape of the mouse pointer, note that the receiver shows that when the cursor pointer cannot use StretchDIBits function, such asCodePudding user response:
HIconHandle to the icon or cursor to be drawn. This parameter can identify an animated cursor. The icon or cursor resource must have had previously the loaded by using the LoadImage function.
LoadImage
The LoadImage function loads an icon, cursor, or bitmap.
HANDLE LoadImage (
HINSTANCE hinst,//handle of the instance containing the image
LPCTSTR lpszName,//the name or identifier of the image
UINT uType,//the type of image
Int cxDesired,//desired width
Int cyDesired,//desired height
UINT fuLoad//the load flags
);
The Parameters
Hinst
Handle to an instance of the module that contains the image to be the loaded. To load an OEM image, set this parameter to zero.
LpszName
Handle to the image to load.
If the hinst parameter is non - NULL and the fuLoad parameter does not include LR_LOADFROMFILE, lpszName is a pointer to a NULL - terminated string that contains the name of the image resource in the hinst module.
If hinst is NULL and LR_LOADFROMFILE is not specified, the low - order word of this parameter must be the identifier of the OEM image to load. The OEM image identifiers are defined in WINUSER. H and have the following prefixes: Prefix fancy
OBM_ OEM bitmaps
OIC_ OEM ICONS
OCR_ OEM your cursors
If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the image.
UType
Specifies the type of image to be the loaded. This parameter can be one of the following values: Value a fancy
IMAGE_BITMAP Loads a bitmap.
IMAGE_CURSOR Loads a cursor.
IMAGE_ICON Loads an icon.
CxDesired
Specifies the width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function USES the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not 2, the function USES the actual resource width.
CyDesired
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull