--- mstools/samples/select/select.c 2018/08/09 18:20:01 1.1.1.1 +++ mstools/samples/select/select.c 2018/08/09 18:24:05 1.1.1.2 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /**************************************************************************** PROGRAM: Select.c @@ -6,10 +17,10 @@ FUNCTIONS: - StartSelection(HWND, POINT, LPRECT, int) - begin selection area - UpdateSelection(HWND, POINT, LPRECT, int) - update selection area - EndSelection(POINT, LPRECT) - end selection area - ClearSelection(HWND, LPRECT, int) - clear selection area + StartSelection(HWND, POINT, LPRECT, int) - begin selection area + UpdateSelection(HWND, POINT, LPRECT, int) - update selection area + EndSelection(POINT, LPRECT) - end selection area + ClearSelection(HWND, LPRECT, int) - clear selection area *******************************************************************************/ @@ -17,25 +28,25 @@ #include "select.h" /**************************************************************************** - FUNCTION: LibMain(HANDLE, DWORD, LPVOID) + FUNCTION: DllMain(HANDLE, DWORD, LPVOID) - PURPOSE: LibMain is called by Windows when + PURPOSE: DllMain is called by Windows when the DLL is initialized, Thread Attached, and other times. Refer to SDK documentation, as to the different ways this may be called. - The LibMain function should perform additional initialization + The DllMain function should perform additional initialization tasks required by the DLL. In this example, no initialization - tasks are required. LibMain should return a value of 1 if + tasks are required. DllMain should return a value of 1 if the initialization is successful. *******************************************************************************/ -INT APIENTRY LibMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved) +BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_being_called, LPVOID lpReserved) { return 1; - UNREFERENCED_PARAMETER(hInst); - UNREFERENCED_PARAMETER(ul_reason_being_called); - UNREFERENCED_PARAMETER(lpReserved); + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(ul_reason_being_called); + UNREFERENCED_PARAMETER(lpReserved); } @@ -54,8 +65,8 @@ INT APIENTRY StartSelection( INT fFlags) { if (lpSelectRect->left != lpSelectRect->right || - lpSelectRect->top != lpSelectRect->bottom) - ClearSelection(hWnd, lpSelectRect, fFlags); + lpSelectRect->top != lpSelectRect->bottom) + ClearSelection(hWnd, lpSelectRect, fFlags); lpSelectRect->right = ptCurrent.x; lpSelectRect->bottom = ptCurrent.y; @@ -63,13 +74,13 @@ INT APIENTRY StartSelection( /* If you are extending the box, then invert the current rectangle */ if ((fFlags & SL_SPECIAL) == SL_EXTEND) - ClearSelection(hWnd, lpSelectRect, fFlags); + ClearSelection(hWnd, lpSelectRect, fFlags); /* Otherwise, set origin to current location */ else { - lpSelectRect->left = ptCurrent.x; - lpSelectRect->top = ptCurrent.y; + lpSelectRect->left = ptCurrent.x; + lpSelectRect->top = ptCurrent.y; } SetCapture(hWnd); return 1; @@ -96,34 +107,34 @@ INT APIENTRY UpdateSelection( switch (fFlags & SL_TYPE) { - case SL_BOX: - OldROP = (SHORT)SetROP2(hDC, R2_NOTXORPEN); - MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL); - LineTo(hDC, lpSelectRect->right, lpSelectRect->top); - LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom); - LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom); - LineTo(hDC, lpSelectRect->left, lpSelectRect->top); - LineTo(hDC, ptCurrent.x, lpSelectRect->top); - LineTo(hDC, ptCurrent.x, ptCurrent.y); - LineTo(hDC, lpSelectRect->left, ptCurrent.y); - LineTo(hDC, lpSelectRect->left, lpSelectRect->top); - SetROP2(hDC, OldROP); - break; + case SL_BOX: + OldROP = (SHORT)SetROP2(hDC, R2_NOTXORPEN); + MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL); + LineTo(hDC, lpSelectRect->right, lpSelectRect->top); + LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom); + LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom); + LineTo(hDC, lpSelectRect->left, lpSelectRect->top); + LineTo(hDC, ptCurrent.x, lpSelectRect->top); + LineTo(hDC, ptCurrent.x, ptCurrent.y); + LineTo(hDC, lpSelectRect->left, ptCurrent.y); + LineTo(hDC, lpSelectRect->left, lpSelectRect->top); + SetROP2(hDC, OldROP); + break; - case SL_BLOCK: - PatBlt(hDC, - lpSelectRect->left, - lpSelectRect->bottom, - lpSelectRect->right - lpSelectRect->left, - ptCurrent.y - lpSelectRect->bottom, - DSTINVERT); - PatBlt(hDC, - lpSelectRect->right, - lpSelectRect->top, - ptCurrent.x - lpSelectRect->right, - ptCurrent.y - lpSelectRect->top, - DSTINVERT); - break; + case SL_BLOCK: + PatBlt(hDC, + lpSelectRect->left, + lpSelectRect->bottom, + lpSelectRect->right - lpSelectRect->left, + ptCurrent.y - lpSelectRect->bottom, + DSTINVERT); + PatBlt(hDC, + lpSelectRect->right, + lpSelectRect->top, + ptCurrent.x - lpSelectRect->right, + ptCurrent.y - lpSelectRect->top, + DSTINVERT); + break; } lpSelectRect->right = ptCurrent.x; lpSelectRect->bottom = ptCurrent.y; @@ -168,24 +179,24 @@ INT APIENTRY ClearSelection( hDC = GetDC(hWnd); switch (fFlags & SL_TYPE) { - case SL_BOX: - OldROP = SetROP2(hDC, R2_NOTXORPEN); - MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL); - LineTo(hDC, lpSelectRect->right, lpSelectRect->top); - LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom); - LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom); - LineTo(hDC, lpSelectRect->left, lpSelectRect->top); - SetROP2(hDC, OldROP); - break; - - case SL_BLOCK: - PatBlt(hDC, - lpSelectRect->left, - lpSelectRect->top, - lpSelectRect->right - lpSelectRect->left, - lpSelectRect->bottom - lpSelectRect->top, - DSTINVERT); - break; + case SL_BOX: + OldROP = SetROP2(hDC, R2_NOTXORPEN); + MoveToEx(hDC, lpSelectRect->left, lpSelectRect->top, NULL); + LineTo(hDC, lpSelectRect->right, lpSelectRect->top); + LineTo(hDC, lpSelectRect->right, lpSelectRect->bottom); + LineTo(hDC, lpSelectRect->left, lpSelectRect->bottom); + LineTo(hDC, lpSelectRect->left, lpSelectRect->top); + SetROP2(hDC, OldROP); + break; + + case SL_BLOCK: + PatBlt(hDC, + lpSelectRect->left, + lpSelectRect->top, + lpSelectRect->right - lpSelectRect->left, + lpSelectRect->bottom - lpSelectRect->top, + DSTINVERT); + break; } ReleaseDC(hWnd, hDC); return 1;