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

1.1.1.2 ! root        1: /******************************************************************************\
1.1       root        2: *
                      3: *  PROGRAM:     SPINTEST.C
                      4: *
                      5: *  PURPOSE:     Demonstrates the use of the SPINCUBE custom control.
                      6: *
1.1.1.2 ! root        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: *               AboutDlgProc   - processes about dialog messages
1.1       root       13: *
1.1.1.2 ! root       14: *
        !            15: *                           Microsoft Developer Support
        !            16: *                     Copyright (c) 1992 Microsoft Corporation
        !            17: *
        !            18: \******************************************************************************/
1.1       root       19: 
                     20: #include <windows.h>
                     21: #include "spintest.h"
                     22: 
                     23: 
                     24: 
1.1.1.2 ! root       25: /******************************************************************************\
1.1       root       26: *
                     27: *  FUNCTION:    WinMain (standard WinMain INPUTS/RETURNS)
                     28: *
                     29: *  GLOBAL VARS: hInst - Handle of program instance
                     30: *
1.1.1.2 ! root       31: \******************************************************************************/
1.1       root       32: 
1.1.1.2 ! root       33: int WINAPI WinMain (HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine,
        !            34:                    int nCmdShow)
1.1       root       35: {
                     36:   WNDCLASS wc;
1.1.1.2 ! root       37:   HWND   hwnd;
1.1       root       38:   MSG    msg;
                     39:   HANDLE hLib;
                     40:   RECT   rect;
                     41:   WORD   i;
                     42: 
                     43:   wc.style         = NULL;
                     44:   wc.lpfnWndProc   = (WNDPROC) MainWndProc;
                     45:   wc.cbClsExtra    = 0;
                     46:   wc.cbWndExtra    = 0;
                     47:   wc.hInstance     = hInstance;
                     48:   wc.hIcon         = LoadIcon (hInstance, "spintesticon");
                     49:   wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
                     50:   wc.hbrBackground = GetStockObject (WHITE_BRUSH);
                     51:   wc.lpszMenuName  = (LPSTR) "Menu";
                     52:   wc.lpszClassName = (LPSTR) "Main";
                     53: 
                     54:   if (!RegisterClass (&wc))
                     55:   {
                     56:     MessageBox (NULL, "WinMain(): RegisterClass() failed",
1.1.1.2 ! root       57:                 "Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION);
1.1       root       58:     return(FALSE);
                     59:   }
                     60: 
1.1.1.2 ! root       61:   ghInst = hInstance;
        !            62:   if (!(hwnd = CreateWindow ("Main", "spintest Sample Application",
1.1       root       63:                              WS_OVERLAPPEDWINDOW,
                     64:                              CW_USEDEFAULT, CW_USEDEFAULT,
                     65:                              CW_USEDEFAULT, CW_USEDEFAULT,
1.1.1.2 ! root       66:                              NULL, NULL, ghInst, NULL)))
1.1       root       67:     return (NULL);
                     68: 
                     69:   if (!(hLib = LoadLibrary ((LPTSTR) "SPINCUBE.DLL")))
1.1.1.2 ! root       70: 
1.1       root       71:     MessageBox (NULL, "WinMain(): LoadLibrary (SPINCUBE.DLL) failed",
1.1.1.2 ! root       72:                 "Err! - SPINTEST", MB_OK | MB_ICONEXCLAMATION);
1.1       root       73: 
                     74:   for (i = 0; i < 3; i++)
                     75: 
1.1.1.2 ! root       76:     gahwndSpin[i] = CreateWindow ("Spincube", "", WS_VISIBLE | WS_CHILD,
        !            77:                                 0, 0, 0, 0, hwnd, NULL, hLib, NULL);
        !            78: 
        !            79:   GetClientRect (hwnd, &rect);
        !            80:   SendMessage (hwnd, WM_SIZE, 0,
1.1       root       81:                MAKELONG((WORD)rect.right,(WORD)rect.bottom));
1.1.1.2 ! root       82:   ShowWindow (hwnd, nCmdShow);
1.1       root       83: 
                     84:   while (GetMessage (&msg, NULL, NULL, NULL))
                     85:   {
                     86:     TranslateMessage (&msg);
1.1.1.2 ! root       87:     DispatchMessage  (&msg);
1.1       root       88:   }
                     89:   FreeLibrary (hLib);
                     90:   return (msg.wParam);
                     91: }
                     92: 
                     93: 
                     94: 
1.1.1.2 ! root       95: /******************************************************************************\
1.1       root       96: *
                     97: *  FUNCTION:    MainWndProc (standard window procedure INPUTS/RETURNS)
                     98: *
1.1.1.2 ! root       99: *  GLOBAL VARS: ghInst - Handle of program instance
1.1       root      100: *
1.1.1.2 ! root      101: \******************************************************************************/
1.1       root      102: 
1.1.1.2 ! root      103: LRESULT CALLBACK MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1.1       root      104: {
1.1.1.2 ! root      105:   switch (msg)
1.1       root      106:   {
                    107:     case WM_COMMAND:
                    108: 
                    109:       switch (LOWORD(wParam))
                    110:       {
1.1.1.2 ! root      111:         case IDM_DLGEDITDIALOG:
        !           112: 
        !           113:           DialogBox (ghInst, (LPCTSTR)"SpintestDlg", hwnd,
        !           114:                      (DLGPROC) SpintestDlgProc);
        !           115:           break;
        !           116: 
1.1       root      117:         case IDM_ABOUT:
                    118: 
1.1.1.2 ! root      119:           DialogBox (ghInst, (LPCTSTR)"About", hwnd, (DLGPROC) AboutDlgProc);
1.1       root      120:           break;
1.1.1.2 ! root      121: 
1.1       root      122:       }
                    123:       break;
                    124: 
                    125:     case WM_SIZE:
                    126:     {
                    127:       int width  = (int) LOWORD(lParam);
                    128:       int height = (int) HIWORD(lParam);
                    129: 
1.1.1.2 ! root      130:       SetWindowPos (gahwndSpin[0], NULL,
1.1       root      131:                     BORDER, BORDER,
                    132:                     width/4 - BORDER, height/4 - BORDER,
                    133:                     SWP_SHOWWINDOW);
1.1.1.2 ! root      134:       SetWindowPos (gahwndSpin[1], NULL,
1.1       root      135:                     width/4 + BORDER, height/4 + BORDER,
                    136:                     width/2 - BORDER, height/4 - BORDER,
                    137:                     SWP_SHOWWINDOW);
1.1.1.2 ! root      138:       SetWindowPos (gahwndSpin[2], NULL,
1.1       root      139:                     3*width/4 + BORDER, height/2 + BORDER,
                    140:                     width/4 - 2*BORDER, height/2 - 2*BORDER,
                    141:                     SWP_SHOWWINDOW);
                    142:       break;
                    143:     }
1.1.1.2 ! root      144: 
1.1       root      145:     case WM_DESTROY:
                    146: 
                    147:       PostQuitMessage (NULL);
                    148:       break;
                    149: 
                    150:     default:
                    151: 
1.1.1.2 ! root      152:       return (DefWindowProc (hwnd, msg, wParam, lParam));
1.1       root      153:   }
                    154:   return (NULL);
                    155: }
                    156: 
                    157: 
                    158: 
1.1.1.2 ! root      159: /******************************************************************************\
1.1       root      160: *
                    161: *  FUNCTION: SpintestDlgProc (standard dialog procedure INPUTS/RETURNS)
                    162: *
1.1.1.2 ! root      163: \******************************************************************************/
1.1       root      164: 
1.1.1.2 ! root      165: LRESULT CALLBACK SpintestDlgProc (HWND hwnd, UINT message, WPARAM wParam,
        !           166:                                   LPARAM lParam)
1.1       root      167: {
                    168:   switch (message)
                    169:   {
                    170:     case WM_INITDIALOG:
                    171: 
                    172:       return (TRUE);
                    173: 
                    174:     case WM_COMMAND:
                    175: 
                    176:       if (LOWORD(wParam) == IDOK)
                    177:       {
1.1.1.2 ! root      178:         EndDialog (hwnd, TRUE);
        !           179:         return (TRUE);
        !           180:       }
        !           181:       return (TRUE);
        !           182:   }
        !           183:   return (FALSE);
        !           184: }
        !           185: 
        !           186: 
        !           187: 
        !           188: /******************************************************************************\
        !           189: *
        !           190: *  FUNCTION:    AboutDlgProc (standard dialog procedure INPUTS/RETURNS)
        !           191: *
        !           192: *  COMMENTS:    Displays "about" message
        !           193: *
        !           194: \******************************************************************************/
        !           195: 
        !           196: LRESULT CALLBACK AboutDlgProc (HWND hwnd, UINT message, WPARAM wParam,
        !           197:                                LPARAM lParam)
        !           198: { switch (message)
        !           199:   {
        !           200:     case WM_COMMAND:
        !           201: 
        !           202:       if (LOWORD(wParam) == IDOK)
        !           203:       {
        !           204:         EndDialog(hwnd, TRUE);
1.1       root      205:         return (TRUE);
                    206:       }
                    207:       return (TRUE);
                    208:   }
                    209:   return (FALSE);
                    210: }

unix.superglobalmegacorp.com

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