How to draw Christmas Crystal Ball in C language
This article introduces the knowledge of "how to draw Christmas Crystal Ball in C language". In the operation of practical cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Let's show you the effect first.
Project code
This is the first time I only use a code segment, because the code is really not much, I think segmentation is not necessary, and where necessary, I also added detailed comments, it should be all right, it is difficult not to use the Windows library before, this time, the effect will look much more comfortable, how to learn to quickly show the heart to the person to see it!
# include # pragma comment (lib, "winmm.lib") int main () {keybd_event (VK_LWIN, 0,0,0); keybd_event (0,0,0); keybd_event (0,2,0); keybd_event (VK_LWIN, 0,2,0); Sleep (3000); int CX = GetSystemMetrics (SM_CXSCREEN) Int CY = GetSystemMetrics (SM_CYSCREEN); HWND hwnd = initgraph (500500); / / create a window hwnd HRGN Ellip = CreateEllipticRgn (10,32,100,10,100,32); / / set a logical graph rect SetWindowRgn (hwnd, Ellip, true); / / set the area of the window SetForegroundWindow (hwnd); MoveWindow (hwnd, CX / 2-120, CY / 2500,500, true) MciSendString ("open res/music.mp3", 0,0,0); / / Open mciSendString ("play res/music.mp3 repeat", 0,0,0); / / play bool isplay = true; / / whether music is playing int sence = 3; / / scene int frame = 0; / / number of frames IMAGE img [30] Int maxframe [] = {20, 7, 4, 15, 10}; / / the number of pictures in each scene char picpath [30] = {0}; / / the path of the string image for (int I = 0; I < maxframe [sence]; iSense +) {sprintf (picpath, "res/d-d.bmp", sence, I) Loadimage (& IMG [I], picpath, 100,100); HWND zmWnd = FindWindow ("Progman", "Program Manager") / / Desktop window HWND bzWnd = FindWindowEx (zmWnd, 0, "SHELLDLL_DefView", NULL); / / Wallpaper window HWND tbWnd = FindWindowEx (bzWnd, 0, "SysListView32", "FolderView"); / / Icon window HWND workHwnd = NULL; while (tbWnd = = NULL) / / there must be a desktop window hierarchy {workHwnd = FindWindowExA (0, workHwnd, "WorkerW", NULL) / / get the window of WorkerW class if (workHwnd = = NULL) break;// unknown error bzWnd = FindWindowExA (workHwnd, NULL, "SHELLDLL_DefView", NULL); if (bzWnd = = NULL) continue; tbWnd = FindWindowExA (bzWnd, NULL, "SysListView32", NULL) } DWORD dwStyle = (DWORD) GetWindowLong (tbWnd, GWL_STYLE); if (dwStyle & LVS_AUTOARRANGE) SetWindowLong (tbWnd, GWL_STYLE, dwStyle & ~ LVS_AUTOARRANGE); DWORD dwExStyle = (DWORD) ListView_GetExtendedListViewStyle (tbWnd, GWL_EXSTYLE); if (dwExStyle & LVS_EX_SNAPTOGRID) ListView_SetExtendedListViewStyle (tbWnd, dwExStyle & ~ LVS_EX_SNAPTOGRID) / / the window that commands it to threaten its icon int count = SendMessage (tbWnd, LVM_GETITEMCOUNT, 0,0); for (int I = 0; I < count; I +) SendMessage (tbWnd, LVM_SETITEMPOSITION, I, (3000 maxframe [sence]-1) frame = 0; for (int I = 0; I < 14) SendMessage +) {SendMessage (tbWnd, LVM_SETITEMPOSITION, I, (dir[ I] .y)