home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / soundb / sndhack / init.c < prev    next >
C/C++ Source or Header  |  1991-07-30  |  4KB  |  144 lines

  1. #include <windows.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "app.h"
  5.  
  6. /*
  7.  * Module: init.c
  8.  *
  9.  * Contains: Application and instance initialization
  10.  * functions.
  11.  *
  12.  */
  13.  
  14.  
  15. /*********************************************************************/
  16. /* Local Function Prototypes                                         */
  17. /*********************************************************************/
  18.  
  19.  
  20. /*********************************************************************/
  21. /* Local data and structures                                         */
  22. /*********************************************************************/
  23.  
  24.  
  25. /*********************************************************************/
  26. /* Global functions                                                  */
  27. /*********************************************************************/
  28.  
  29. /*-------------------------------------------------------------------*/
  30. /* Initialize the application for only the first time its executed   */
  31. /*-------------------------------------------------------------------*/
  32. BOOL InitApplication(hInstance)
  33. HANDLE hInstance;
  34. {
  35.   WNDCLASS   AppClass;
  36.  
  37.   AppClass.style           = NULL;
  38.   AppClass.lpfnWndProc     = WinProc;
  39.   AppClass.cbClsExtra      = 0;
  40.   AppClass.cbWndExtra      = 0;
  41.   AppClass.hInstance       = hInstance;
  42.   AppClass.hIcon           = LoadIcon(hInstance, "ClassIcon");
  43.   AppClass.hCursor         = LoadCursor(NULL,IDC_ARROW);
  44.   AppClass.hbrBackground   = GetStockObject(WHITE_BRUSH);
  45.   AppClass.lpszMenuName    = (LPSTR)"ClassMenu";
  46.   AppClass.lpszClassName   = (LPSTR)ClassName;
  47.  
  48.   return (RegisterClass(&AppClass));
  49. }
  50.  
  51. /*-------------------------------------------------------------------*/
  52. /* Initialize the instance, done everytime its executed              */
  53. /*-------------------------------------------------------------------*/
  54.  
  55. BOOL InitInstance(hInstance,nCmdShow)
  56. HANDLE hInstance;
  57. int nCmdShow;
  58. {
  59.   RECT Rect;
  60.   char *HelpFilePtr;
  61.   int i;
  62.  
  63.   hAccelTable = LoadAccelerators(hInstance, (LPSTR)"ClassAccel");
  64.  
  65.   hWindow = CreateWindow(
  66.     (LPSTR)ClassName,
  67.     (LPSTR)WindowName,
  68.     WS_OVERLAPPEDWINDOW,
  69.     CW_USEDEFAULT,
  70.     CW_USEDEFAULT,
  71.     CW_USEDEFAULT,
  72.     CW_USEDEFAULT,
  73.     (HWND)NULL,
  74.     (HMENU)NULL,
  75.     (HANDLE)hInstance,
  76.     (LPSTR)NULL);
  77.  
  78.   if (hWindow == NULL) {
  79.     MessageBox(
  80.       GetFocus(),
  81.       (LPSTR)"Could not create the Instance Class Window",
  82.       (LPSTR)"CreateWindow Fatal Error",
  83.       MB_ICONSTOP);
  84.     return FALSE;
  85.   }
  86.  
  87.   hInst = hInstance;
  88.   hMenu = GetMenu(hWindow);
  89.  
  90.   GetClientRect(hWindow, (LPRECT) &Rect);
  91.  
  92.   hEditWindow = CreateWindow(
  93.     "Edit",
  94.     NULL,
  95.     WS_CHILD | WS_VISIBLE |
  96.     ES_MULTILINE |
  97.     WS_VSCROLL | WS_HSCROLL |
  98.     ES_AUTOHSCROLL | ES_AUTOVSCROLL,
  99.     0,
  100.     0,
  101.     (Rect.right-Rect.left),
  102.     (Rect.bottom-Rect.top),
  103.     hWindow,
  104.     IDC_EDIT,                          /* Child control i.d. */
  105.     hInst,
  106.     NULL);
  107.  
  108.   if (!hEditWindow) {
  109.     DestroyWindow(hWindow);
  110.     MessageBox(
  111.       GetFocus(),
  112.       (LPSTR)"Could not create the Edit Window",
  113.       (LPSTR)"CreateWindow Fatal Error",
  114.       MB_ICONSTOP);
  115.     return FALSE;
  116.   }
  117.  
  118.   i = GetModuleFileName(hInst,HelpFileName,sizeof(HelpFileName)-1);
  119.   for (; i > 0; i--) {
  120.     if (HelpFileName[i] == '\\' || HelpFileName[i] == ':') {
  121.       HelpFileName[i+1] = '\0';
  122.       break;
  123.     }
  124.   }
  125.  
  126.   if (i + 13 < sizeof(HelpFileName))
  127.     strcat(HelpFileName, "sndhack.hlp");
  128.   else
  129.     strcpy(HelpFileName, "sndhack.hlp");
  130.  
  131.   hHourGlass = LoadCursor(NULL, IDC_WAIT);
  132.   hNote = LoadCursor(hInstance, "NoteCursor");
  133.   ShowWindow(hWindow, nCmdShow);
  134.   UpdateWindow(hWindow);
  135.  
  136.   return TRUE;
  137. }
  138.  
  139.  
  140. /**********************************************************************/
  141. /* Local functions                                                    */
  142. /**********************************************************************/
  143.  
  144.