--- mstools/samples/input/input.c 2018/08/09 18:20:01 1.1 +++ mstools/samples/input/input.c 2018/08/09 18:24:34 1.1.1.3 @@ -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: Input.c @@ -6,11 +17,11 @@ FUNCTIONS: - WinMain() - calls initialization function, processes message loop - InitApplication() - initializes window data and registers window - InitInstance() - saves instance handle and creates main window - MainWndProc() - processes messages - About() - processes messages for "About" dialog box + WinMain() - calls initialization function, processes message loop + InitApplication() - initializes window data and registers window + InitInstance() - saves instance handle and creates main window + MainWndProc() - processes messages + About() - processes messages for "About" dialog box ****************************************************************************/ @@ -33,13 +44,7 @@ RECT rectCharacter; RECT rectScroll; RECT rectTimer; INT idTimer; /* timer ID */ -INT nTimerCount = 0; /* current timer count */ - - -#define GET_WM_HSCROLL_CODE(wp, lp) LOWORD(wp) -#define GET_WM_HSCROLL_POS(wp, lp) HIWORD(wp) -#define GET_WM_HSCROLL_HWND(wp, lp) (HWND)(lp) - +INT nTimerCount = 0; /* current timer count */ /**************************************************************************** @@ -61,15 +66,15 @@ int APIENTRY WinMain( UNREFERENCED_PARAMETER( lpCmdLine ); if (!hPrevInstance) - if (!InitApplication(hInstance)) - return (FALSE); + if (!InitApplication(hInstance)) + return (FALSE); if (!InitInstance(hInstance, nCmdShow)) return (FALSE); - while (GetMessage(&msg, NULL, NULL, NULL)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); } return (msg.wParam); } @@ -186,8 +191,8 @@ BOOL InitInstance( MESSAGES: - WM_COMMAND - application menu (About dialog box) - WM_CREATE - create window + WM_COMMAND - application menu (About dialog box) + WM_CREATE - create window WM_MOUSEMOVE - mouse movement WM_LBUTTONDOWN - left mouse button pressed WM_LBUTTONUP - left mouse button released @@ -209,10 +214,10 @@ BOOL InitInstance( ****************************************************************************/ LONG APIENTRY MainWndProc( - HWND hWnd, - UINT message, - UINT wParam, - LONG lParam) + HWND hWnd, + UINT message, + UINT wParam, + LONG lParam) { FARPROC lpProcAbout; @@ -223,26 +228,26 @@ LONG APIENTRY MainWndProc( RECT rect; switch (message) { - case WM_COMMAND: - if (LOWORD(wParam) == IDM_ABOUT) { - lpProcAbout = MakeProcInstance((FARPROC)About, hInst); - - DialogBox(hInst, - "AboutBox", - hWnd, - (WNDPROC)lpProcAbout); - - FreeProcInstance(lpProcAbout); - break; - } - else - return (DefWindowProc(hWnd, message, wParam, lParam)); + case WM_COMMAND: + if (LOWORD(wParam) == IDM_ABOUT) { + lpProcAbout = MakeProcInstance((FARPROC)About, hInst); + + DialogBox(hInst, + "AboutBox", + hWnd, + lpProcAbout); + + FreeProcInstance(lpProcAbout); + break; + } + else + return (DefWindowProc(hWnd, message, wParam, lParam)); case WM_CREATE: /* Set the timer for five-second intervals */ - idTimer = SetTimer(hWnd, NULL, 5000, (WNDPROC)(LPVOID)NULL); + idTimer = SetTimer(hWnd, 0, 5000, (TIMERPROC)(LPVOID)NULL); break; @@ -358,15 +363,15 @@ LONG APIENTRY MainWndProc( break; case WM_DESTROY: - /* Bug?, SetTimer returns an int, KillTimer takes a WORD*/ + /* Bug?, SetTimer returns an int, KillTimer takes a WORD*/ KillTimer(hWnd, (WORD)idTimer); /* Stops the timer */ PostQuitMessage(0); break; - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); + default: + return (DefWindowProc(hWnd, message, wParam, lParam)); } - return (NULL); + return (0); } @@ -378,28 +383,28 @@ LONG APIENTRY MainWndProc( MESSAGES: - WM_INITDIALOG - initialize dialog box - WM_COMMAND - Input received + WM_INITDIALOG - initialize dialog box + WM_COMMAND - Input received ****************************************************************************/ BOOL APIENTRY About( - HWND hDlg, - UINT message, - UINT wParam, - LONG lParam) + HWND hDlg, + UINT message, + UINT wParam, + LONG lParam) { switch (message) { - case WM_INITDIALOG: - return (TRUE); + case WM_INITDIALOG: + return (TRUE); - case WM_COMMAND: - if (LOWORD(wParam) == IDOK) { - EndDialog(hDlg, TRUE); - return (TRUE); - } - break; + case WM_COMMAND: + if (LOWORD(wParam) == IDOK) { + EndDialog(hDlg, TRUE); + return (TRUE); + } + break; } return (FALSE); - UNREFERENCED_PARAMETER(lParam); + UNREFERENCED_PARAMETER(lParam); }