VC obtains the current mouse Image

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.