/* The start of 'MyWinFunc' function */ LRESULT CALLBACK MyWinFunc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { HDC hDC; PAINTSTRUCT ps; static INT w, h; static BITMAP bm; static HBITMAP hBm, hBmLogo; static HDC hMemDC, hMemDCLogo; switch (Msg) { case WM_CREATE: SetTimer(hWnd, 30, 2, NULL); hBmLogo = LoadImage(NULL, "M.BMP", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); GetObject(hBmLogo, sizeof(bm), &bm); hDC = GetDC(hWnd); hMemDC = CreateCompatibleDC(hDC); hMemDCLogo = CreateCompatibleDC(hDC); SelectObject(hMemDCLogo, hBmLogo); ReleaseDC(hWnd, hDC); LoadSphere(); case WM_SIZE: w = LOWORD(lParam); h = HIWORD(lParam); if (hBm != NULL) DeleteObject(hBm); hDC = GetDC(hWnd); hBm = CreateCompatibleBitmap(hDC, w, h); ReleaseDC(hWnd, hDC); SelectObject(hMemDC, hBm); SendMessage(hWnd, WM_TIMER, 0, 0); return 0; case WM_ERASEBKGND: return 0; case WM_KEYDOWN: if (LOWORD(wParam) == 'F') FlipFullScreen(hWnd); if (LOWORD(wParam) == VK_ESCAPE) SendMessage(hWnd, WM_DESTROY, 0, 0); return 0; case WM_TIMER: Rectangle(hMemDC, 0, 0, w + 1, h + 1); DrawSphere( hMemDC, w / 2 + sin(clock() / 600.0) * 450.0, h / 2, 256); BitBlt(hMemDC, 725 + sin(clock() / 600.0) * 650.0, 0, bm.bmWidth, bm.bmHeight, hMemDCLogo, 0, 0, SRCAND); SetBkMode(hMemDC, TRANSPARENT); SetTextColor(hMemDC, RGB(255, 0, 255)); TextOut(hMemDC, 5, 5, "THE PROGRAMMER IN THE WORLD", 15); InvalidateRect(hWnd, NULL, FALSE); return 0; case WM_PAINT: hDC = BeginPaint(hWnd, &ps); BitBlt(hDC, 0, 0, w, h, hMemDC, 0, 0, SRCCOPY); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: KillTimer(hWnd, 30); DeleteObject(hBm); DeleteObject(hMemDC); PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, Msg, wParam, lParam); } /* End of 'MyWinFunc' function */
void LoadModel() { LoadSphere(); LoadBox(); }