Annotation of mstools/samples/gdidemo/init.c, revision 1.1

1.1     ! root        1: /*---------------------------------------------------------------------------*\
        !             2: | INITIALIZATION MODULE
        !             3: |   This module contains startup-routines for the creation of windows for this
        !             4: |   application.
        !             5: |
        !             6: |   RegisterAppClass
        !             7: |   UnregisterAppClass
        !             8: |   CreateAppWindow
        !             9: |   CreateMDIClientWindow
        !            10: |
        !            11: |
        !            12: | segment: _INIT (DOS16)
        !            13: | created: 31-Oct-90
        !            14: | history: 31-Oct-90 <chriswil> created.
        !            15: |
        !            16: \*---------------------------------------------------------------------------*/
        !            17: 
        !            18: #include <windows.h>
        !            19: #include "gdidemo.h"
        !            20: #include "poly.h"
        !            21: #include "xform.h"
        !            22: #include "maze.h"
        !            23: #include "draw.h"
        !            24: #include "bounce.h"
        !            25: 
        !            26: /*---------------------------------------------------------------------------*\
        !            27: | REGISTER APPLICATION CLASS
        !            28: |   This routine registers all classes necessary for the application.
        !            29: |
        !            30: | created: 31-Oct-90
        !            31: | history: 31-Oct-90 <chriswil> created.
        !            32: |
        !            33: \*---------------------------------------------------------------------------*/
        !            34: BOOL FAR RegisterAppClass(HANDLE hInstance)
        !            35: {
        !            36:     WNDCLASS wndClass;
        !            37: 
        !            38: 
        !            39:     /*
        !            40:     ** Set the common wndClass information.  This is common to all windows
        !            41:     ** of this application.
        !            42:     */
        !            43:     wndClass.style         = CS_HREDRAW | CS_VREDRAW;
        !            44:     wndClass.cbClsExtra    = 0;
        !            45:     wndClass.cbWndExtra    = sizeof(LONG);
        !            46:     wndClass.hCursor       = LoadCursor(NULL,IDC_ARROW);
        !            47:     wndClass.hInstance     = hInstance;
        !            48: 
        !            49: 
        !            50:     /*
        !            51:     ** Register the main top-level window (frame).
        !            52:     */
        !            53:     wndClass.lpfnWndProc   = WndProc;
        !            54:     wndClass.hIcon         = LoadIcon(hInstance,MAKEINTRESOURCE(APPICON));
        !            55:     wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
        !            56:     wndClass.lpszMenuName  = MAKEINTRESOURCE(APPMENU);
        !            57:     wndClass.lpszClassName = APPCLASS;
        !            58: 
        !            59:     if(!RegisterClass(&wndClass))
        !            60:         return(FALSE);
        !            61: 
        !            62: 
        !            63:     /*
        !            64:     ** Register the polybezier demo window.
        !            65:     */
        !            66:     wndClass.lpfnWndProc   = PolyProc;
        !            67:     wndClass.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
        !            68:     wndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
        !            69:     wndClass.lpszMenuName  = NULL;
        !            70:     wndClass.lpszClassName = POLYCLASS;
        !            71: 
        !            72:     if(!RegisterClass(&wndClass))
        !            73:     {
        !            74:         UnregisterClass(APPCLASS,hInstance);
        !            75:         return(FALSE);
        !            76:     }
        !            77: 
        !            78: 
        !            79:     /*
        !            80:     ** Register the xform demo window.
        !            81:     */
        !            82:     wndClass.lpfnWndProc   = XFormProc;
        !            83:     wndClass.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
        !            84:     wndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
        !            85:     wndClass.lpszMenuName  = NULL;
        !            86:     wndClass.lpszClassName = XFORMCLASS;
        !            87: 
        !            88:     if(!RegisterClass(&wndClass))
        !            89:     {
        !            90:         UnregisterClass(APPCLASS ,hInstance);
        !            91:         UnregisterClass(POLYCLASS,hInstance);
        !            92:         return(FALSE);
        !            93:     }
        !            94: 
        !            95: 
        !            96:     /*
        !            97:     ** Register the maze demo window.
        !            98:     */
        !            99:     wndClass.lpfnWndProc   = MazeProc;
        !           100:     wndClass.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
        !           101:     wndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
        !           102:     wndClass.lpszMenuName  = NULL;
        !           103:     wndClass.lpszClassName = MAZECLASS;
        !           104: 
        !           105:     if(!RegisterClass(&wndClass))
        !           106:     {
        !           107:         UnregisterClass(APPCLASS  ,hInstance);
        !           108:         UnregisterClass(POLYCLASS ,hInstance);
        !           109:         UnregisterClass(XFORMCLASS,hInstance);
        !           110:         return(FALSE);
        !           111:     }
        !           112: 
        !           113: 
        !           114:     /*
        !           115:     ** Register the random draw demo window.
        !           116:     */
        !           117:     wndClass.lpfnWndProc   = DrawProc;
        !           118:     wndClass.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
        !           119:     wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
        !           120:     wndClass.lpszMenuName  = NULL;
        !           121:     wndClass.lpszClassName = DRAWCLASS;
        !           122: 
        !           123:     if(!RegisterClass(&wndClass))
        !           124:     {
        !           125:         UnregisterClass(APPCLASS  ,hInstance);
        !           126:         UnregisterClass(POLYCLASS ,hInstance);
        !           127:         UnregisterClass(XFORMCLASS,hInstance);
        !           128:         UnregisterClass(MAZECLASS ,hInstance);
        !           129:         return(FALSE);
        !           130:     }
        !           131: 
        !           132: 
        !           133:     /*
        !           134:     ** Register the bouncing ball demo window.
        !           135:     */
        !           136:     wndClass.lpfnWndProc   = BounceProc;
        !           137:     wndClass.hIcon         = LoadIcon(NULL,IDI_APPLICATION);
        !           138:     wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
        !           139:     wndClass.lpszMenuName  = NULL;
        !           140:     wndClass.lpszClassName = BOUNCECLASS;
        !           141: 
        !           142:     if(!RegisterClass(&wndClass))
        !           143:     {
        !           144:         UnregisterClass(APPCLASS  ,hInstance);
        !           145:         UnregisterClass(POLYCLASS ,hInstance);
        !           146:         UnregisterClass(XFORMCLASS,hInstance);
        !           147:         UnregisterClass(MAZECLASS ,hInstance);
        !           148:         UnregisterClass(DRAWCLASS ,hInstance);
        !           149:         return(FALSE);
        !           150:     }
        !           151: 
        !           152:     return(TRUE);
        !           153: }
        !           154: 
        !           155: 
        !           156: /*---------------------------------------------------------------------------*\
        !           157: | UNREGISTER APPLICATION CLASS
        !           158: |   This routine unregisters all classes registered for the application.
        !           159: |   It is typically called upon termination of the application.
        !           160: |
        !           161: | created: 31-Oct-90
        !           162: | history: 31-Oct-90 <chriswil> created.
        !           163: |
        !           164: \*---------------------------------------------------------------------------*/
        !           165: VOID FAR UnregisterAppClass(HANDLE hInstance)
        !           166: {
        !           167:     UnregisterClass(APPCLASS   ,hInstance);
        !           168:     UnregisterClass(POLYCLASS  ,hInstance);
        !           169:     UnregisterClass(XFORMCLASS ,hInstance);
        !           170:     UnregisterClass(MAZECLASS  ,hInstance);
        !           171:     UnregisterClass(DRAWCLASS  ,hInstance);
        !           172:     UnregisterClass(BOUNCECLASS,hInstance);
        !           173: 
        !           174:     return;
        !           175: }
        !           176: 
        !           177: 
        !           178: /*---------------------------------------------------------------------------*\
        !           179: | CREATE APPLICATION WINDOW
        !           180: |   This routine creates the main top-level window.
        !           181: |
        !           182: | created: 31-Oct-90
        !           183: | history: 31-Oct-90 <chriswil> created.
        !           184: |
        !           185: \*---------------------------------------------------------------------------*/
        !           186: HWND FAR CreateAppWindow(HANDLE hInstance)
        !           187: {
        !           188:     /*
        !           189:     ** Upon creation of the window, initialize the extra object information.
        !           190:     */
        !           191:     return(CreateWindow(APPCLASS,APPTITLE,WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
        !           192:             CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
        !           193:             NULL,NULL,hInstance,NULL));
        !           194: }
        !           195: 
        !           196: 
        !           197: /*---------------------------------------------------------------------------*\
        !           198: | CREATE MDI CLIENT WINDOW
        !           199: |   This routine creates the client window which handles the MDI windows.
        !           200: |   The window will eventually be size to fit into the frame-window's client
        !           201: |   area.
        !           202: |
        !           203: | created: 31-Oct-90
        !           204: | history: 31-Oct-90 <chriswil> created.
        !           205: |
        !           206: \*---------------------------------------------------------------------------*/
        !           207: HWND FAR CreateMDIClientWindow(HWND hWndFrame)
        !           208: {
        !           209:     HWND               hWndClient;
        !           210:     HANDLE             hInstance;
        !           211:     CLIENTCREATESTRUCT ccs;
        !           212: 
        !           213: 
        !           214:     /*
        !           215:     ** Initialize the client struct to point to define the menu and child
        !           216:     ** identifiers.  The menu item specifies the parent menu in which the
        !           217:     ** the list of MDI childs will be appended to this menu.
        !           218:     */
        !           219:     ccs.hWindowMenu  = NULL;
        !           220:     ccs.idFirstChild = 0;
        !           221: 
        !           222: 
        !           223:     hInstance = GETINSTANCE(hWndFrame);
        !           224: 
        !           225:     hWndClient = CreateWindow("MDICLIENT",NULL,WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
        !           226:             0,0,1,1,hWndFrame,NULL,hInstance,(LPVOID)&ccs);
        !           227: 
        !           228:     return(hWndClient);
        !           229: }

unix.superglobalmegacorp.com

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