--- mstools/samples/mandel/bndscan.c 2018/08/09 18:21:40 1.1.1.2 +++ mstools/samples/mandel/bndscan.c 2018/08/09 18:23:43 1.1.1.3 @@ -6,22 +6,18 @@ * Created: 14-Apr-1992 10:59:52 * Author: Petrus Wong * -* Copyright (c) 1990 Microsoft Corporation +* Copyright (c) 1993 Microsoft Corporation * * Dependencies: * * none * \**************************************************************************/ -//#define STRICT #include #include #include "jtypes.h" #include "bndscan.h" -extern LONG lMul(LONG, LONG); -extern LONG lDiv(LONG, LONG); - BOOL bBoundaryScanFix(PINFO); LPPOINT pptTrace(LONG, LONG, PINFO, INT *, HDC); DWORD dwGetNextBoundaryPoint(DWORD, POINT, LPPOINT, PINFO); @@ -95,7 +91,7 @@ BOOL bBoundaryScanFix(PINFO pInfo) BOUNDTRACE: - SelectObject(hDC, hpnGreen); + SelectObject(hDC, hpnBlack); if ((lpPt = pptTrace(o, p, pInfo, &iCount, hDC)) == NULL) { m = o+1; @@ -153,10 +149,11 @@ BOUNDTRACE: #if 0 // - // SelectClipPath doesn't seem to work at this time + // Can't use SelectClipPath to set the clipping region here + // because we are on a different thread. This is only a cached DC. // if (SelectClipPath(hDC, RGN_COPY)) { - // + // Testing if the clip region is effective or not // //MoveToEx(hDC, 0, 0, NULL); @@ -167,24 +164,14 @@ BOUNDTRACE: } if (pInfo->hRgnPath != (HRGN) NULL) { - if (SelectClipRgn(hDC, pInfo->hRgnPath) == ERROR) { - sprintf( gtext,"Error in Selecting clip region\n"); - OutputDebugString( gtext ); - goto EXIT; - } // - // Testing if the clip region is effective or not + // let the main thread who owns the DC to set the clipping region. // - //MoveToEx(hDC, 0, 0, NULL); - //GetClientRect(pInfo->hwnd, &rc); - //LineTo(hDC, rc.right, rc.bottom); + SendMessage(ghwndMain, WM_COMMAND, MM_SELCLIPRGN, 0L); } - -EXIT: - pInfo->dwElapsed = GetTickCount() - dwTick1; - pInfo->hBmpSaved = SaveBitmap(pInfo->hwnd); + pInfo->hBmpSaved = SaveBitmap(pInfo->hwnd, pInfo->hPal); pInfo->bDrawing = FALSE; ReleaseDC(pInfo->hwnd, hDC); @@ -193,9 +180,6 @@ EXIT: // GlobalFree((HANDLE) lpPt); ExitThread(0); - if (!CloseHandle(pInfo->hThrd)) - MessageBox(ghwndMain, "Failed in CloseHandle!", "Error", MB_OK); - return TRUE; } @@ -230,9 +214,7 @@ LPPOINT pptTrace(LONG m, LONG n, PINFO p // it's not enough, it is more likely that it is an error. // if ((lpPt = (PPOINT) GlobalAlloc(GMEM_FIXED, MAXPOINT * sizeof(POINT))) == NULL) { - //MessageBox(ghwndMain, "Failed in Memory Allocation for lpPt!", "Error", MB_OK); - sprintf( gtext,"Failed in Memory Allocation for lpPt!\n"); - OutputDebugString( gtext ); + MessageBox(ghwndMain, "Failed in Memory Allocation for lpPt!", "Error", MB_OK); return (LPPOINT) NULL; } lpTmpPt = lpPt; @@ -367,6 +349,7 @@ DWORD dwGetNextBoundaryPoint(DWORD dwFac * Warnings: * * History: +* 16-Feb-1993 Petrus Wong 9.23 fix * 20-Feb-1992 -by- Petrus Wong * Wrote it. \**************************************************************************/ @@ -393,7 +376,7 @@ BOOL bEscape(POINT Pt, LONG x, LONG y, L y = y1; // 2 2 2 1/2 2 z = lMul(x, x) + lMul(y, y); // |Z| = ((x1 + x2 ) ) > 2 - if (z > 8192) { + if (z > 33554432) { bEscape = TRUE; break; }