--- q_a/samples/spincube/spincube.c 2018/08/09 18:29:19 1.1.1.1 +++ q_a/samples/spincube/spincube.c 2018/08/09 18:29:20 1.1.1.2 @@ -1,4 +1,4 @@ -/************************************************************************\ +/******************************************************************************\ * * MODULE: SPINCUBE.C * @@ -21,16 +21,20 @@ * I recommend browsing the NT CUSTCNTL.H file to get an * idea of the new interface. * -\************************************************************************/ +* +* Microsoft Developer Support +* Copyright (c) 1992 Microsoft Corporation +* +\******************************************************************************/ #include #include "spincube.h" -void Paint (HWND); /* function prototype for Paint() in PAINT.C */ +void Paint (HWND); // function prototype for Paint() in PAINT.C -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLEntryPoint * @@ -42,15 +46,15 @@ void Paint (HWND); /* function p * TRUE if initialization passed, or * FALSE if initialization failed. * -* GLOBAL VARS: hMod - DLL module handle +* GLOBAL VARS: ghMod - DLL module handle * * COMMENTS: On DLL_PROCESS_ATTACH registers the SPINCUBECLASS * -\************************************************************************/ +\******************************************************************************/ -BOOL DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) +BOOL WINAPI DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) { - hMod = hDLL; + ghMod = hDLL; switch (dwReason) { case DLL_PROCESS_ATTACH: @@ -71,8 +75,9 @@ BOOL DLLEntryPoint (HANDLE hDLL, DWORD d if (!RegisterClass (&wc)) { - MessageBox (NULL, "DLLEntryPoint(): RegisterClass() failed", - "Err! - SPINCUBE.DLL", MB_OK | MB_ICONEXCLAMATION); + MessageBox (NULL, (LPCTSTR) "DLLEntryPoint(): RegisterClass() failed", + (LPCTSTR) "Err! - SPINCUBE.DLL", + MB_OK | MB_ICONEXCLAMATION); return FALSE; } break; @@ -85,7 +90,7 @@ BOOL DLLEntryPoint (HANDLE hDLL, DWORD d -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: CustomControlInfoA * @@ -95,22 +100,27 @@ BOOL DLLEntryPoint (HANDLE hDLL, DWORD d * * COMMENTS: See CUSTCNTL.H for more info * -\************************************************************************/ +\******************************************************************************/ UINT CALLBACK CustomControlInfoA (LPCCINFOA acci) { - if (!acci) /* dlgedit is querying the number of controls this DLL */ - return 1; /* supports, so return 1. Then we'll get called */ - /* again with a valid "acci" */ + // + // dlgedit is querying the number of controls this DLL supports, so return 1. + // Then we'll get called again with a valid "acci" + // + + if (!acci) + + return 1; acci[0].flOptions = 0; - acci[0].cxDefault = 40; /* default width (dialog units) */ - acci[0].cyDefault = 40; /* default height (dialog units) */ + acci[0].cxDefault = 40; // default width (dialog units) + acci[0].cyDefault = 40; // default height (dialog units) acci[0].flStyleDefault = WS_CHILD | WS_VISIBLE; acci[0].flExtStyleDefault = 0; acci[0].flCtrlTypeMask = 0; - acci[0].cStyleFlags = 1; /* entries in following style table */ + acci[0].cStyleFlags = 1; // entries in following style table if (!(acci[0].aStyleFlags = (LPCCSTYLEFLAG) LocalAlloc (LPTR, sizeof(CCSTYLEFLAG) + @@ -130,12 +140,16 @@ UINT CALLBACK CustomControlInfoA (LPCCIN lstrcpy (acci[0].szTextDefault, SPINCUBEDEFTEXT); lstrcpy ((char *)&acci[1], STYLEDEFSTR); - return 1; /* return the number of controls that the DLL supports */ + // + // return the number of controls that the DLL supports + // + + return 1; } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: SpincubeStyle * @@ -149,7 +163,7 @@ UINT CALLBACK CustomControlInfoA (LPCCIN * * LOCAL VARS: rc - return code from DialogBox * -\************************************************************************/ +\******************************************************************************/ BOOL CALLBACK SpincubeStyle (HWND hWndParent, LPCCSTYLE pccs) { @@ -157,11 +171,11 @@ BOOL CALLBACK SpincubeStyle (HWND hWndPa gpccs = pccs; - if ((rc = DialogBox (hMod, "SpincubeStyle", hWndParent, + if ((rc = DialogBox (ghMod, "SpincubeStyle", hWndParent, (DLGPROC)SpincubeDlgProc)) == -1) { - MessageBox (hWndParent, "SpincubeStyle(): DialogBox failed", - "Err!- Spincube.dll", + MessageBox (hWndParent, (LPCTSTR) "SpincubeStyle(): DialogBox failed", + (LPCTSTR) "Err!- Spincube.dll", MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL); rc = 0; } @@ -170,7 +184,7 @@ BOOL CALLBACK SpincubeStyle (HWND hWndPa -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: SpincubeSizeToText * @@ -184,7 +198,7 @@ BOOL CALLBACK SpincubeStyle (HWND hWndPa * * COMMENTS: Just no-op here * -\************************************************************************/ +\******************************************************************************/ INT CALLBACK SpincubeSizeToText (DWORD flStyle, DWORD flExtStyle, HFONT hFont, LPSTR pszText) @@ -195,7 +209,7 @@ INT CALLBACK SpincubeSizeToText (DWORD f -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: SpincubeWndProc (standard window procedure INPUTS/RETURNS) * @@ -207,17 +221,18 @@ INT CALLBACK SpincubeSizeToText (DWORD f * a new position. Left button clicks will toggle the motion * state of the control (and turn the timer on/off). * -\************************************************************************/ +\******************************************************************************/ -LONG SpincubeWndProc (HWND hWnd, UINT msg, UINT wParam, LONG lParam) +LRESULT CALLBACK SpincubeWndProc (HWND hWnd, UINT msg, WPARAM wParam, + LPARAM lParam) { switch (msg) { case WM_CREATE: { - /******************************************************************\ - * Alloc & init a SPINCUBEINFO struct for this particular control - \******************************************************************/ + // + // Alloc & init a SPINCUBEINFO struct for this particular control + // HANDLE hSCI = LocalAlloc (LHND, sizeof(SPINCUBEINFO)); PSPINCUBEINFO pSCI = (PSPINCUBEINFO) LocalLock (hSCI); @@ -249,9 +264,9 @@ LONG SpincubeWndProc (HWND hWnd, UINT ms case WM_LBUTTONDOWN: { - /******************************************************************\ - * Change the inMotion state of the control - \******************************************************************/ + // + // Change the inMotion state of the control + // HANDLE hSCI = (HANDLE) GetWindowLong (hWnd, GWL_SPINCUBEDATA); PSPINCUBEINFO pSCI = (PSPINCUBEINFO) LocalLock (hSCI); @@ -269,12 +284,14 @@ LONG SpincubeWndProc (HWND hWnd, UINT ms break; } + case WM_DESTROY: { HANDLE hSCI = (HANDLE) GetWindowLong (hWnd, GWL_SPINCUBEDATA); LocalFree (hSCI); break; } + default: return (DefWindowProc(hWnd, msg, wParam, lParam)); @@ -284,7 +301,7 @@ LONG SpincubeWndProc (HWND hWnd, UINT ms -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: SpincubeDlgProc (standard dialog procedure INPUTS/RETURNS) * @@ -296,9 +313,10 @@ LONG SpincubeWndProc (HWND hWnd, UINT ms * CCSTYLE structure pointed at by "gpccs" (a pointer * that was passed to us by dlgedit). * -\************************************************************************/ +\******************************************************************************/ -BOOL SpincubeDlgProc (HWND hDlg, UINT msg, UINT wParam, LONG lParam) +LRESULT CALLBACK SpincubeDlgProc (HWND hDlg, UINT msg, WPARAM wParam, + LPARAM lParam) { switch (msg) {