The processing of warning C4005: 'winver ': macro redefinition is in Windows. h has the following definitions: # ifndef WINVER # define WINVER 0x0400 # endif if you place # define WINVER 0x500 in # include <windows. h> there will be no warning before.
Files to be included: # include "Winuser. h"
Hcursor getcur () {cursorinfo hcur; // hcursor hcur; zeromemory (& hcur, sizeof (hcur); hcur. cbsize = sizeof (hcur); getcursorinfo (& hcur); Return hcur. hcursor ;}void cmy123dlg: onbutton1 () {sleep (2000); // warning: This code snippet is not bullet proof. hcursor hcur = getcur (); //: getcursor (); If (hcur = NULL) return; iconinfo icon;: geticoninfo (hcur, & icon); hbitmap hbmp; bitmap bm;: GetObject (icon. hbmmask, siz EOF (Bitmap), & BM); HDC hglobal, hdcmask, hdccolor; hglobal =: getdc (null); hdcmask =: createcompatibledc (hglobal); hdccolor = :: createcompatibledc (hglobal); hbmp =: createcompatiblebitmap (hglobal, BM. bmwidth, BM. bmwidth);: SelectObject (hdccolor, hbmp);: floodfill (hdccolor, 255,255,255, RGB (); // background color: SelectObject (hdcmask, icon. hbmmask);: bitblt (hdccolor, 0, 0, BM. bmwidth, BM. bmwidth, hdcmask, 0, 0, srcand ); If (icon. hbmcolor = NULL): bitblt (hdccolor, 0, 0, BM. bmwidth, BM. bmwidth, hdcmask, 0, BM. bmwidth, SRCINVERT); else {: SelectObject (hdcmask, icon. hbmcolor);: bitblt (hdccolor, 0, 0, BM. bmwidth, BM. bmwidth, hdcmask, 0, 0, SRCINVERT);} pictdesc picdesc; picdesc. cbsizeofstruct = sizeof (pictdesc); picdesc. pictype = pictype_bitmap; picdesc.bmp. hbitmap = hbmp; ipicture * ppicture = NULL; olecreatepictureindirect (& Pi CDESC, iid_ipicture, true, (void **) & ppicture); lpstream pstream; createstreamonhglobal (null, true, & pstream); long size; hresult hR = ppicture-> saveasfile (pstream, true, & size); char pathbuf [1024]; strcpy (pathbuf, "C: \ myarrow.bmp"); file * stream; stream = fopen (pathbuf, "W"); large_integer Li; Li. highpart = 0; Li. lowpart = 0; ularge_integer ulnewpos; pstream-> seek (Li, stream_seek_set, & ulnewpos); UlO Ng ureadcount = 1; while (ureadcount> 0) {pstream-> Read (pathbuf, sizeof (pathbuf), & ureadcount); If (ureadcount> 0) fwrite (pathbuf, sizeof (char), ureadcount, stream);} pstream-> release (); fclose (Stream);: deleteobject (icon. hbmmask); If (icon. hbmcolor! = NULL): deleteobject (icon. hbmcolor);: deleteobject (hbmp);: releasedc (null, hdcmask);: releasedc (null, hdccolor);: releasedc (null, hglobal ); afxmessagebox (_ T ("OK "));}
CBitmap bmp; CDC memDC; memDC.CreateCompa... memDC.SelectObiect(bmp) memDC.GetPixel(x, y)