--- q_a/samples/spincube/spintest.c 2018/08/09 18:29:19 1.1 +++ q_a/samples/spincube/spintest.c 2018/08/09 18:29:20 1.1.1.2 @@ -1,35 +1,40 @@ -/************************************************************************\ +/******************************************************************************\ * * PROGRAM: SPINTEST.C * * PURPOSE: Demonstrates the use of the SPINCUBE custom control. * -* FUNCTIONS: WinMain() - standard stuff; also loads the -* SPINCUBE.DLL and creates a couple -* of spincube controls. -* MainWndProc() - generic window procedure. -* SpintestDlgProc() - generic dialog procedure. +* FUNCTIONS: WinMain - standard stuff; also loads the +* SPINCUBE.DLL and creates a couple +* of spincube controls. +* MainWndProc - generic window procedure. +* SpintestDlgProc- generic dialog procedure. +* AboutDlgProc - processes about dialog messages * -\************************************************************************/ +* +* Microsoft Developer Support +* Copyright (c) 1992 Microsoft Corporation +* +\******************************************************************************/ #include #include "spintest.h" -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: WinMain (standard WinMain INPUTS/RETURNS) * * GLOBAL VARS: hInst - Handle of program instance * -\************************************************************************/ +\******************************************************************************/ -int WinMain (HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine, - int nCmdShow) +int WINAPI WinMain (HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine, + int nCmdShow) { WNDCLASS wc; - HWND hWnd; + HWND hwnd; MSG msg; HANDLE hLib; RECT rect; @@ -41,7 +46,6 @@ int WinMain (HANDLE hInstance,HANDLE hPr wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon (hInstance, "spintesticon"); -// wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = GetStockObject (WHITE_BRUSH); wc.lpszMenuName = (LPSTR) "Menu"; @@ -50,64 +54,71 @@ int WinMain (HANDLE hInstance,HANDLE hPr if (!RegisterClass (&wc)) { MessageBox (NULL, "WinMain(): RegisterClass() failed", - "Err! - SPINTEST", MB_OK | MB_ICONHAND); + "Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION); return(FALSE); } - hInst = hInstance; - if (!(hWnd = CreateWindow ("Main", "spintest Sample Application", + ghInst = hInstance; + if (!(hwnd = CreateWindow ("Main", "spintest Sample Application", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hInstance, NULL))) + NULL, NULL, ghInst, NULL))) return (NULL); if (!(hLib = LoadLibrary ((LPTSTR) "SPINCUBE.DLL"))) + MessageBox (NULL, "WinMain(): LoadLibrary (SPINCUBE.DLL) failed", - "Err! - SPINTEST", MB_OK | MB_ICONHAND); + "Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION); for (i = 0; i < 3; i++) - hwndSpin[i] = CreateWindow ("Spincube", "", WS_VISIBLE | WS_CHILD, - 0, 0, 0, 0, hWnd, NULL, hLib, NULL); - GetClientRect (hWnd, &rect); - SendMessage (hWnd, WM_SIZE, 0, + gahwndSpin[i] = CreateWindow ("Spincube", "", WS_VISIBLE | WS_CHILD, + 0, 0, 0, 0, hwnd, NULL, hLib, NULL); + + GetClientRect (hwnd, &rect); + SendMessage (hwnd, WM_SIZE, 0, MAKELONG((WORD)rect.right,(WORD)rect.bottom)); - ShowWindow (hWnd, nCmdShow); + ShowWindow (hwnd, nCmdShow); while (GetMessage (&msg, NULL, NULL, NULL)) { TranslateMessage (&msg); - DispatchMessage (&msg); + DispatchMessage (&msg); } FreeLibrary (hLib); return (msg.wParam); - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: MainWndProc (standard window procedure INPUTS/RETURNS) * -* GLOBAL VARS: hInst - Handle of program instance +* GLOBAL VARS: ghInst - Handle of program instance * -\************************************************************************/ +\******************************************************************************/ -LONG MainWndProc (HWND hWnd, UINT message, UINT wParam, LONG lParam) +LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (message) + switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { + case IDM_DLGEDITDIALOG: + + DialogBox (ghInst, (LPCTSTR)"SpintestDlg", hwnd, + (DLGPROC) SpintestDlgProc); + break; + case IDM_ABOUT: - DialogBox(hInst, "SpintestDlg", hWnd, (DLGPROC)SpintestDlgProc); + DialogBox (ghInst, (LPCTSTR)"About", hwnd, (DLGPROC) AboutDlgProc); break; + } break; @@ -116,20 +127,21 @@ LONG MainWndProc (HWND hWnd, UINT messag int width = (int) LOWORD(lParam); int height = (int) HIWORD(lParam); - SetWindowPos (hwndSpin[0], NULL, + SetWindowPos (gahwndSpin[0], NULL, BORDER, BORDER, width/4 - BORDER, height/4 - BORDER, SWP_SHOWWINDOW); - SetWindowPos (hwndSpin[1], NULL, + SetWindowPos (gahwndSpin[1], NULL, width/4 + BORDER, height/4 + BORDER, width/2 - BORDER, height/4 - BORDER, SWP_SHOWWINDOW); - SetWindowPos (hwndSpin[2], NULL, + SetWindowPos (gahwndSpin[2], NULL, 3*width/4 + BORDER, height/2 + BORDER, width/4 - 2*BORDER, height/2 - 2*BORDER, SWP_SHOWWINDOW); break; } + case WM_DESTROY: PostQuitMessage (NULL); @@ -137,20 +149,21 @@ LONG MainWndProc (HWND hWnd, UINT messag default: - return (DefWindowProc (hWnd, message, wParam, lParam)); + return (DefWindowProc (hwnd, msg, wParam, lParam)); } return (NULL); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: SpintestDlgProc (standard dialog procedure INPUTS/RETURNS) * -\************************************************************************/ +\******************************************************************************/ -BOOL SpintestDlgProc (HWND hDlg, UINT message, UINT wParam, LONG lParam) +LRESULT CALLBACK SpintestDlgProc (HWND hwnd, UINT message, WPARAM wParam, + LPARAM lParam) { switch (message) { @@ -162,11 +175,36 @@ BOOL SpintestDlgProc (HWND hDlg, UINT me if (LOWORD(wParam) == IDOK) { - EndDialog (hDlg, TRUE); + EndDialog (hwnd, TRUE); + return (TRUE); + } + return (TRUE); + } + return (FALSE); +} + + + +/******************************************************************************\ +* +* FUNCTION: AboutDlgProc (standard dialog procedure INPUTS/RETURNS) +* +* COMMENTS: Displays "about" message +* +\******************************************************************************/ + +LRESULT CALLBACK AboutDlgProc (HWND hwnd, UINT message, WPARAM wParam, + LPARAM lParam) +{ switch (message) + { + case WM_COMMAND: + + if (LOWORD(wParam) == IDOK) + { + EndDialog(hwnd, TRUE); return (TRUE); } return (TRUE); } return (FALSE); - UNREFERENCED_PARAMETER(lParam); }