/************************************************************************* ** ** OLE 2 Sample Code ** ** debug2.c ** ** This file contains various debug / subclass routines for the ** ABOUT dialog ** ** (c) Copyright Microsoft Corp. 1992 - 1993 All Rights Reserved ** *************************************************************************/ #include "outline.h" #include #include extern LPOUTLINEAPP g_lpApp; LONG CALLBACK EXPORT DebugAbout(HWND hWnd, unsigned uMsg, WORD wParam, LONG lParam); void RandomizeStars(HDC hDC); BOOL InitStrings(void); BOOL DrawString(int iCount, HDC hDC, LPRECT rcDrawIn); static FARPROC lpRealAboutProc = 0L; static int width, height; static RECT rc; static HANDLE hStrBlock = NULL; static LPSTR lpStrings = NULL; static WORD wLineHeight; /* TraceDebug * ---------- * * Called once when our About Box's gets the INITDIALOG message. Subclasses * dialog. */ void TraceDebug(HWND hDlg, int iControl) { // Load strings, if the strings aren't there, then don't subclass // the dialog if (InitStrings() != TRUE) return; // Subclass the dialog lpRealAboutProc = (FARPROC)(LONG_PTR)GetWindowLongPtr(hDlg, GWLP_WNDPROC); SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)(FARPROC)DebugAbout); // Get rect of control in screen coords, and translate to our dialog // box's coordinates GetWindowRect(GetDlgItem(hDlg, iControl), &rc); MapWindowPoints(NULL, hDlg, (LPPOINT)&rc, 2); width = rc.right - rc.left; height = rc.bottom - rc.top; } /* DebugAbout * ---------- * * The subclassed About dialog's main window proc. */ LONG CALLBACK EXPORT DebugAbout(HWND hWnd, unsigned uMsg, WORD wParam, LONG lParam) { RECT rcOut; static BOOL bTimerStarted = FALSE; static int iTopLocation; HDC hDCScr; static HDC hDCMem; static HBITMAP hBitmap; static HBITMAP hBitmapOld; static RECT rcMem; static HFONT hFont; switch (uMsg) { /* * If we get a LBUTTONDBLCLICK in the upper left of * the dialog, fire off the about box effects */ case WM_LBUTTONDBLCLK: if ((wParam & MK_CONTROL) && (wParam & MK_SHIFT) && LOWORD(lParam) < 10 && HIWORD(lParam) < 10 && bTimerStarted == FALSE) { if (SetTimer ( hWnd, 1, 10, NULL )) { LOGFONT lf; int i; bTimerStarted = TRUE; // "Open up" the window hDCScr = GetDC ( hWnd ); hDCMem = CreateCompatibleDC ( hDCScr ); hBitmap = CreateCompatibleBitmap(hDCScr, width, height); hBitmapOld = SelectObject(hDCMem, hBitmap); // Blt from dialog to memDC BitBlt(hDCMem, 0, 0, width, height, hDCScr, rc.left, rc.top, SRCCOPY); for (i=0;im_hInst, MAKEINTRESOURCE(9999), RT_RCDATA)) == NULL) return FALSE; if ((hStrBlock = LoadResource(g_lpApp->m_hInst, hResStrings)) == NULL) return FALSE; if ((lpStrings = LockResource(hStrBlock)) == NULL) return FALSE; if (lpStrings && *(lpStrings+2)!=0x45) { lpWalk = lpStrings; while (*(LPWORD)lpWalk != (WORD)0x0000) { if (*lpWalk != (char)0x00) *lpWalk ^= 0x98; lpWalk++; } } return TRUE; } /* DrawString * ---------- * * Draws the next string on the specified hDC using the * output rectangle. If iCount == 0, reset to start of list. * * Returns: TRUE to contine, FALSE if we're done */ BOOL DrawString(int iCount, HDC hDC, LPRECT rcDrawIn) { static LPSTR lpPtr = NULL; if (iCount == 0) // First time, reset pointer lpPtr = lpStrings; if (*lpPtr == '\0') // If we've hit a NULL string, we're done return FALSE; // If we're drawing outside of visible box, don't call DrawText if ((rcDrawIn->bottom > 0) && (rcDrawIn->top < height)) DrawText(hDC, lpPtr, -1, rcDrawIn, DT_CENTER); // Advance pointer to next string lpPtr += lstrlen(lpPtr) + 1; return TRUE; }