VC window jitter source code

Source: Internet
Author: User
// The CPoint CurrentPos of the window jitter instance; // return to this position after shaking, so do not run it in disorder. CRect rect; // This section is calculated to meet the SetWindowPos () parameter requirements... Don't explain. GetClientRect (& rect); ClientToScreen (& rect); CurrentPos. x = rect. left; CurrentPos. y = rect. top; int FrameWidth; int FrameHight; int CaptionHight; // the three values set in my current system are 3, 3, 22 FrameWidth = GetSystemMetrics (SM_CXFIXEDFRAME ); frameHight = GetSystemMetrics (SM_CYFIXEDFRAME); CaptionHight = GetSystemMetrics (SM_CYCAPTION); // This is a good function. // you need to offset CurrentPos coordinates () to CurrentPos in the upper-left corner of the main window. offset (-FrameWidth,-CaptionHight-Fram EHight); // achieve jitter: Half a small circle + three large circles + half a small circle SetWindowPos (& wndTopMost, CurrentPos. x-1, CurrentPos. y-2, SWP_NOSIZE); Sleep (10); // The SWP_NOSIZE parameter above ignores cx, cy, so it can be set to 0 SetWindowPos (& wndTopMost, CurrentPos. x-4, CurrentPos. y-4, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-7, CurrentPos. y-2, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-8, CurrentPos. y, 0, 0, SWP_NOSIZE); Sleep (10); int I = 0; f Or (; I <3; I ++) // change the number of {SetWindowPos (& wndTopMost, CurrentPos if you want to shake a few laps. x-6, CurrentPos. y + 6, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x, CurrentPos. y + 8, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x + 6, CurrentPos. y + 6, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x + 8, CurrentPos. y, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x + 6, CurrentPos. y -6, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x, CurrentPos. y-8, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-6, CurrentPos. y-6, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-8, CurrentPos. y, 0, 0, SWP_NOSIZE); Sleep (10);} SetWindowPos (& wndTopMost, CurrentPos. x-7, CurrentPos. y + 2, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-4, Curre NtPos. y + 4, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x-1, CurrentPos. y + 2, 0, 0, SWP_NOSIZE); Sleep (10); SetWindowPos (& wndTopMost, CurrentPos. x, CurrentPos. y, SWP_NOSIZE); // The latency of Sleep () and the radius of the jitter arc. Just write it as you can. The settings here are still very cute. // In addition, there is a more useful extension. This code is generally implemented in the dlg class, SetWindowPos (), // and other functions can be used directly. If you want to call it from another class or global function, you need to obtain the pointer of the jitter object in advance. // You can add the following statements at the beginning: // CXXXXApp * pApp = (CXXXXApp *) AfxGetApp (); // CXXXXDlg * pShakeDlg = (CXXXXDlg *) pApp-> GetMainWnd (); // This pointer is used when all the members of the dlg class are called, such as: // pShakeDlg-> ClientToScreen (& rect ); // pShakeDlg-> SetWindowPos (& wndTopMost, CurrentPos. x-4, CurrentPos. y-4, 0, 0, SWP_NOSIZE); // global functions and APIs are not required. // Theoretically, you can "remotely control" the jitter from any possible location. For example, you have created an example of accessing the target dialog box object from a static member function, it is not hard to achieve. // Don't laugh at the broken lines of text and stupid methods. I only checked MSDN when writing the code, and I only wanted to indirectly calculate the main window // the upper-left corner, it looks lengthy. If there is a direct solution, I hope you will not be enlightened... If the loop is not used well, // This is not the key.

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.