Clock performance on Windows Mobile

Source: Internet
Author: User

Using the previous article "Rotating images from any angle on Windows Mobile", you can achieve a brilliant effect. Every time we need three pictures, three PNG pictures, one for the hour, one for the hour, and one for the minute.

For example:

 

 

 

 

The image is taken from Android.

The implementation code is as follows:

Void drawclock (HDC, rect RC) <br/>{< br/> systemtime; </P> <p> getlocaltime (& systemtime ); </P> <p> iimage * pcurclockhour = NULL; <br/> iimage * pcurclockmin = NULL; <br/> imageinfo imdialinfo; <br/> imageinfo imhourinfo; <br/> imageinfo immininfo; </P> <p> lpbytephourbuf = NULL; <br/> lpbyte pminbuf = NULL; <br/> point ptclockcenter; <br/> rect rcdial; <br/> rect rchour; <br/> rect rcmin; </P> <p> getclientrect (g_hwnd, & rc ); </P> <p> HDC hdcoffset = createcompatibledc (HDC); <br/> hbitmap hbmpoffset = createcompatiblebitmap (HDC, RC. right-RC. left, RC. bottom-RC. top); <br/> SelectObject (hdcoffset, hbmpoffset); <br/> fillrect (hdcoffset, & rc, (hbrush) getstockobject (white_brush )); <br/> // load the image from the JPG file. </P> <p> If (pclockdial = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockgoog_dial.png"), & pclockdial ); <br/> If (pclockhour = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockgoog_hour.png"), & pclockhour ); <br/> If (pclockmin = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockgoog_minute.png"), & pclockmin ); </P> <p>/* <br/> If (pclockdial = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockdroid2_dial.png "), & pclockdial); <br/> If (pclockhour = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockdroid2_hour.png"), & pclockhour ); <br/> If (pclockmin = NULL) <br/> pimgfactory-> createimagefromfile (text ("// clockdroid2_minute.png"), & pclockmin ); <br/> */<br/> pclockdial-> getimageinfo (& imdialinfo); <br/> rcdial. left = (RC. right-RC. left)-imdialinfo. width)/2 + RC. left; <br/> rcdial. top = (RC. bottom-RC. top)-imdialinfo. height)/2 + RC. top; <br/> rcdial. right = rcdial. left + imdialinfo. width; <br/> rcdial. bottom = rcdial. top + imdialinfo. height; </P> <p> ptclockcenter. X = rcdial. left + imdialinfo. width/2; <br/> ptclockcenter. y = rcdial. top + imdialinfo. height/2; </P> <p> rotateimage (pimgfactory, pclockhour, pcurclockhour, phourbuf, systemtime. whour * 6*3.14/180); <br/> rotateimage (pimgfactory, pclockmin, pcurclockmin, pminbuf, (systemtime. wminute * 6 + systemtime. wsecond/10) x 3.14/180); </P> <p> pcurclockhour-> getimageinfo (& imhourinfo); <br/> pcurclockmin-> getimageinfo (& immininfo ); </P> <p> rchour. left = ptclockcenter. x-imhourinfo. width/2; <br/> rchour. right = rchour. left + imhourinfo. width; <br/> rchour. top = ptclockcenter. y-imhourinfo. height/2; <br/> rchour. bottom = rchour. top + imhourinfo. height; </P> <p> rcmin. left = ptclockcenter. x-immininfo. width/2; <br/> rcmin. right = rcmin. left + immininfo. width; <br/> rcmin. top = ptclockcenter. y-immininfo. height/2; <br/> rcmin. bottom = rcmin. top + immininfo. height; </P> <p> pclockdial-> draw (hdcoffset, & rcdial, null); <br/> pcurclockhour-> draw (hdcoffset, & rchour, null ); <br/> pcurclockmin-> draw (hdcoffset, & rcmin, null); </P> <p> pcurclockhour-> release (); <br/> pcurclockmin-> release (); </P> <p> Delete phourbuf; <br/> Delete pminbuf; <br/> bitblt (HDC, RC. left, RC. top, RC. right-rc.left, RC. bottom-RC. left, hdcoffset, 0, 0, srccopy); </P> <p> deletedc (hdcoffset); <br/> deleteobject (hbmpoffset); <br/>}

 

Final effect:

Related Article

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.