home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / w3_prog / s13382.arj / INIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-25  |  3.1 KB  |  127 lines

  1. //*************************************************************
  2. //  File name: init.c
  3. //
  4. //  Description:
  5. //
  6. //      Routines which initialize the application and instance.
  7. //
  8. //  History:    Date       Author     Comment
  9. //              12/12/91   Don Miller Created
  10. //
  11. // Written by Microsoft Product Support Services, Windows Developer Support
  12. // Copyright (c) 1992 Microsoft Corporation. All rights reserved.
  13. //*************************************************************
  14.  
  15. #ifndef _GLOBALINC
  16. #include "global.h"
  17. #endif
  18.  
  19. //*************************************************************
  20. //
  21. //  InitApplication()
  22. //
  23. //  Purpose:
  24. //
  25. //        Initializes the application (window classes)
  26. //
  27. //
  28. //  Parameters:
  29. //
  30. //      HANDLE hInstance - Instance handle from WinMain.
  31. //      
  32. //
  33. //  Return: (BOOL)
  34. //
  35. //      TRUE  - Window class was initialized and registered.
  36. //      FALSE - Window class not initialized and registered.
  37. //
  38. //
  39. //  Comments:
  40. //
  41. //
  42. //  History:    Date       Author     Comment
  43. //              12/12/91   MSM        Created
  44. //
  45. //*************************************************************
  46.  
  47. BOOL InitApplication (HANDLE hInstance)
  48. {
  49.     WNDCLASS  wc;
  50.  
  51.     wc.style         = NULL;             
  52.     wc.lpfnWndProc   = MainWndProc;
  53.     wc.cbClsExtra    = 0;           
  54.     wc.cbWndExtra    = 0;           
  55.     wc.hInstance     = hInstance;    
  56.     wc.hIcon         = LoadIcon(hInstance, "MAINICON");
  57.     wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  58.     wc.hbrBackground = COLOR_APPWORKSPACE+1;
  59.     wc.lpszMenuName  = szMainMenu;  
  60.     wc.lpszClassName = szMainClass;
  61.  
  62.     if ( !RegisterClass(&wc) )
  63.         return(FALSE);
  64.  
  65.     return(TRUE);
  66.  
  67. } //*** InitApplication
  68.  
  69. //*************************************************************
  70. //
  71. //  InitInstance()
  72. //
  73. //  Purpose:
  74. //
  75. //        Initializes each instance (window creation)
  76. //
  77. //
  78. //  Parameters:
  79. //
  80. //      HANDLE hInstance - Instance handle of application.
  81. //      int    nCmdShow  - How window is initially displayed.
  82. //      
  83. //
  84. //  Return: (BOOL)
  85. //
  86. //      TRUE  - Window created and displayed.
  87. //      FALSE - Window not created.
  88. //
  89. //
  90. //  Comments:
  91. //
  92. //
  93. //  History:    Date       Author     Comment
  94. //              12/12/91   MSM        Created
  95. //
  96. //*************************************************************
  97.  
  98. BOOL InitInstance (HANDLE hInstance, int nCmdShow)
  99. {
  100.  
  101.     ghInst = hInstance;
  102.  
  103.     ghWndMain = CreateWindow( szMainClass, 
  104.                               "TrueType Sample Application",  
  105.                               WS_OVERLAPPEDWINDOW,           
  106.                               CW_USEDEFAULT,
  107.                               CW_USEDEFAULT,
  108.                               CW_USEDEFAULT,
  109.                               CW_USEDEFAULT,
  110.                               NULL,
  111.                               NULL,
  112.                               hInstance,
  113.                               NULL );
  114.  
  115.     if (!ghWndMain)
  116.         return(FALSE);
  117.  
  118.     ShowWindow(ghWndMain, nCmdShow);
  119.     UpdateWindow(ghWndMain);
  120.  
  121.     return(TRUE);
  122.  
  123. } //*** InitInstance
  124.  
  125. /*** EOF: init.c ***/
  126.  
  127.