// 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.