Annotation of q_a/samples/spincube/spintest.c, revision 1.1.1.1

1.1       root        1: /************************************************************************\
                      2: *
                      3: *  PROGRAM:     SPINTEST.C
                      4: *
                      5: *  PURPOSE:     Demonstrates the use of the SPINCUBE custom control.
                      6: *
                      7: *  FUNCTIONS:   WinMain()         - standard stuff; also loads the
                      8: *                                   SPINCUBE.DLL and creates a couple
                      9: *                                   of spincube controls.
                     10: *               MainWndProc()     - generic window procedure.
                     11: *               SpintestDlgProc() - generic dialog procedure.
                     12: *
                     13: \************************************************************************/
                     14: 
                     15: #include <windows.h>
                     16: #include "spintest.h"
                     17: 
                     18: 
                     19: 
                     20: /************************************************************************\
                     21: *
                     22: *  FUNCTION:    WinMain (standard WinMain INPUTS/RETURNS)
                     23: *
                     24: *  GLOBAL VARS: hInst - Handle of program instance
                     25: *
                     26: \************************************************************************/
                     27: 
                     28: int WinMain (HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine,
                     29:              int nCmdShow)
                     30: {
                     31:   WNDCLASS wc;
                     32:   HWND   hWnd;
                     33:   MSG    msg;
                     34:   HANDLE hLib;
                     35:   RECT   rect;
                     36:   WORD   i;
                     37: 
                     38:   wc.style         = NULL;
                     39:   wc.lpfnWndProc   = (WNDPROC) MainWndProc;
                     40:   wc.cbClsExtra    = 0;
                     41:   wc.cbWndExtra    = 0;
                     42:   wc.hInstance     = hInstance;
                     43:   wc.hIcon         = LoadIcon (hInstance, "spintesticon");
                     44: //  wc.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
                     45:   wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
                     46:   wc.hbrBackground = GetStockObject (WHITE_BRUSH);
                     47:   wc.lpszMenuName  = (LPSTR) "Menu";
                     48:   wc.lpszClassName = (LPSTR) "Main";
                     49: 
                     50:   if (!RegisterClass (&wc))
                     51:   {
                     52:     MessageBox (NULL, "WinMain(): RegisterClass() failed",
                     53:                 "Err! - SPINTEST", MB_OK | MB_ICONHAND);
                     54:     return(FALSE);
                     55:   }
                     56: 
                     57:   hInst = hInstance;
                     58:   if (!(hWnd = CreateWindow ("Main", "spintest Sample Application",
                     59:                              WS_OVERLAPPEDWINDOW,
                     60:                              CW_USEDEFAULT, CW_USEDEFAULT,
                     61:                              CW_USEDEFAULT, CW_USEDEFAULT,
                     62:                              NULL, NULL, hInstance, NULL)))
                     63:     return (NULL);
                     64: 
                     65:   if (!(hLib = LoadLibrary ((LPTSTR) "SPINCUBE.DLL")))
                     66:     MessageBox (NULL, "WinMain(): LoadLibrary (SPINCUBE.DLL) failed",
                     67:                 "Err! - SPINTEST", MB_OK | MB_ICONHAND);
                     68: 
                     69:   for (i = 0; i < 3; i++)
                     70:     hwndSpin[i] = CreateWindow ("Spincube", "", WS_VISIBLE | WS_CHILD,
                     71:                                 0, 0, 0, 0, hWnd, NULL, hLib, NULL);
                     72: 
                     73:   GetClientRect (hWnd, &rect);
                     74:   SendMessage (hWnd, WM_SIZE, 0,
                     75:                MAKELONG((WORD)rect.right,(WORD)rect.bottom));
                     76:   ShowWindow (hWnd, nCmdShow);
                     77: 
                     78:   while (GetMessage (&msg, NULL, NULL, NULL))
                     79:   {
                     80:     TranslateMessage (&msg);
                     81:     DispatchMessage (&msg);
                     82:   }
                     83:   FreeLibrary (hLib);
                     84:   return (msg.wParam);
                     85:   UNREFERENCED_PARAMETER(hPrevInstance);
                     86:   UNREFERENCED_PARAMETER(lpCmdLine);
                     87: }
                     88: 
                     89: 
                     90: 
                     91: /************************************************************************\
                     92: *
                     93: *  FUNCTION:    MainWndProc (standard window procedure INPUTS/RETURNS)
                     94: *
                     95: *  GLOBAL VARS: hInst - Handle of program instance
                     96: *
                     97: \************************************************************************/
                     98: 
                     99: LONG MainWndProc (HWND hWnd, UINT message, UINT wParam, LONG lParam)
                    100: {
                    101:   switch (message)
                    102:   {
                    103:     case WM_COMMAND:
                    104: 
                    105:       switch (LOWORD(wParam))
                    106:       {
                    107:         case IDM_ABOUT:
                    108: 
                    109:           DialogBox(hInst, "SpintestDlg", hWnd, (DLGPROC)SpintestDlgProc);
                    110:           break;
                    111:       }
                    112:       break;
                    113: 
                    114:     case WM_SIZE:
                    115:     {
                    116:       int width  = (int) LOWORD(lParam);
                    117:       int height = (int) HIWORD(lParam);
                    118: 
                    119:       SetWindowPos (hwndSpin[0], NULL,
                    120:                     BORDER, BORDER,
                    121:                     width/4 - BORDER, height/4 - BORDER,
                    122:                     SWP_SHOWWINDOW);
                    123:       SetWindowPos (hwndSpin[1], NULL,
                    124:                     width/4 + BORDER, height/4 + BORDER,
                    125:                     width/2 - BORDER, height/4 - BORDER,
                    126:                     SWP_SHOWWINDOW);
                    127:       SetWindowPos (hwndSpin[2], NULL,
                    128:                     3*width/4 + BORDER, height/2 + BORDER,
                    129:                     width/4 - 2*BORDER, height/2 - 2*BORDER,
                    130:                     SWP_SHOWWINDOW);
                    131:       break;
                    132:     }
                    133:     case WM_DESTROY:
                    134: 
                    135:       PostQuitMessage (NULL);
                    136:       break;
                    137: 
                    138:     default:
                    139: 
                    140:       return (DefWindowProc (hWnd, message, wParam, lParam));
                    141:   }
                    142:   return (NULL);
                    143: }
                    144: 
                    145: 
                    146: 
                    147: /************************************************************************\
                    148: *
                    149: *  FUNCTION: SpintestDlgProc (standard dialog procedure INPUTS/RETURNS)
                    150: *
                    151: \************************************************************************/
                    152: 
                    153: BOOL SpintestDlgProc (HWND hDlg, UINT message, UINT wParam, LONG lParam)
                    154: {
                    155:   switch (message)
                    156:   {
                    157:     case WM_INITDIALOG:
                    158: 
                    159:       return (TRUE);
                    160: 
                    161:     case WM_COMMAND:
                    162: 
                    163:       if (LOWORD(wParam) == IDOK)
                    164:       {
                    165:         EndDialog (hDlg, TRUE);
                    166:         return (TRUE);
                    167:       }
                    168:       return (TRUE);
                    169:   }
                    170:   return (FALSE);
                    171:   UNREFERENCED_PARAMETER(lParam);
                    172: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.