home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / workshop / prog / msconf / confsdk.exe / MAIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-23  |  3.9 KB  |  149 lines

  1. /* ----------------------------------------------------------------------
  2.  
  3.  
  4.     CNFTEST sample for Microsoft ActiveX Conferencing
  5.  
  6.     Unpublished work.
  7.     Copyright (c) 1996, Microsoft Corporation
  8.     All rights reserved.
  9.  
  10.   MODULE: main.c
  11.   
  12.   PURPOSE:   Calls initialization functions and processes the message loop
  13.  
  14.   FUNCTIONS:
  15.   WinMain() - Calls initialization functions FInitApp() and FInitInstance(),
  16.               and processes message loop.
  17.  
  18.   ---------------------------------------------------------------------- */
  19.  
  20. #include "main.h"
  21.  
  22.  
  23. // Global Variables
  24.  
  25. HINSTANCE ghInst       = NULL;          // Current Instance
  26. HANDLE    ghAccelTable = NULL;          // Menu accelerators
  27. HMENU     ghMenu       = NULL;          // Main Menu
  28. HWND      ghwndMain    = hwndNil;       // Main Window
  29. HINSTANCE ghInstDll    = NULL;
  30.  
  31. HWND      ghwndTbar    = hwndNil;       // Toolbar window
  32. HWND      ghwndSbar    = hwndNil;       // Status bar window
  33. HWND      ghwndMsg     = hwndNil;       // Message window
  34. HWND      ghwndEntry   = hwndNil;       // szEntry Edit control
  35. HFONT     ghfontEntry  = hfontNil;      // Font for edit control
  36.  
  37. PREF      gPref;                        // User preferences
  38. int       gdxWndMin    = 325;           // maximum size of window
  39. int       gdyWndMin    = 250;           // maximum size of window
  40.  
  41.  
  42.  
  43. /*  W I N  M A I N */
  44. /*-------------------------------------------------------------------------
  45.     %%Function: WinMain
  46.  
  47.     Main Windows entrypoint
  48.  
  49.     FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  50.  
  51.     PURPOSE: calls initialization function, processes message loop
  52.  
  53.     PARAMETERS:
  54.  
  55.     hInstance - The handle to the instance of this application that
  56.           is currently being executed.
  57.  
  58.     hInstPrev - This parameter is always NULL in Win32
  59.           applications.
  60.  
  61.     lpszCmd - A pointer to a null terminated string specifying the
  62.           command line of the application.
  63.  
  64.     nCmdShow - Specifies how the main window is to be displayed.
  65.  
  66.   RETURN VALUE:
  67.     If the function terminates before entering the message loop,
  68.     return FALSE.
  69.     Otherwise, return the WPARAM value sent by the WM_QUIT message.
  70.  
  71.  
  72.   COMMENTS:
  73.  
  74.     Windows recognizes this function by name as the initial entry point
  75.     for the program.  This function calls the initialization routine.
  76.     It then executes a message retrieval and dispatch loop that is the
  77.     top-level control structure for the remainder of the program.  The
  78.     loop is terminated when a WM_QUIT  message is received, at which
  79.     time this function exits the application instance by returning the
  80.     value passed by PostQuitMessage.
  81.  
  82.     If this function must abort before entering the message loop, it
  83.     returns the conventional value NULL.
  84.  
  85. -------------------------------------------------------------------------*/
  86. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hInstPrev, LPSTR  lpszCmd, int nCmdShow)
  87. {
  88.     WPARAM wResult;
  89.  
  90.     ghInst = hInstance;
  91.  
  92.     if (!FInitApp(lpszCmd))
  93.     {
  94.         return 0;
  95.     }
  96.  
  97.     if (!FInitInstance(nCmdShow))
  98.     {
  99.         return 0;
  100.     }
  101.  
  102.     wResult = MsgLoop(fTrue /* fForever */);
  103.  
  104.     return wResult;
  105. }
  106.  
  107.  
  108.  
  109. /*  M S G  L O O P */
  110. /*-------------------------------------------------------------------------
  111.     %%Function: MsgLoop
  112.  
  113.     Main message loop
  114. -------------------------------------------------------------------------*/
  115. WPARAM MsgLoop(BOOL fForever)
  116. {
  117.     MSG   msg;
  118.  
  119.     for ( ; ; )
  120.     {
  121.         if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  122.         {
  123.             // Acquire and dispatch messages until a WM_QUIT message is received.
  124.  
  125.             if (!GetMessage(&msg, NULL, 0, 0))
  126.             {
  127.                 break;        // WM_QUIT received
  128.             }
  129.                 
  130.             if (!TranslateAccelerator(msg.hwnd, ghAccelTable, &msg))
  131.             {
  132.                 TranslateMessage(&msg);
  133.                 DispatchMessage(&msg);
  134.             }
  135.         }
  136.         else if (fForever)
  137.         {
  138.             WaitMessage();
  139.         }
  140.         else
  141.         {
  142.             return 0;
  143.         }
  144.     }
  145.  
  146.     return msg.wParam;
  147. }
  148.  
  149.