winmain.c 2.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright 1998 Douglas Ridgway
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 18
 */

19
#include <windows.h>            /* required for all Windows applications */
Alexandre Julliard's avatar
Alexandre Julliard committed
20 21 22 23
#include "globals.h"            /* prototypes specific to this application */


int APIENTRY WinMain(HINSTANCE hInstance,
24 25
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
Alexandre Julliard's avatar
Alexandre Julliard committed
26 27 28 29
                     int       nCmdShow)
{
    MSG msg;
    HANDLE hAccelTable;
30

Alexandre Julliard's avatar
Alexandre Julliard committed
31 32 33 34 35 36
    /* Other instances of app running? */
    if (!hPrevInstance)
    {
      /* stuff to be done once */
      if (!InitApplication(hInstance))
      {
37
	return FALSE;              /* exit */
Alexandre Julliard's avatar
Alexandre Julliard committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
      }
    }

    /* stuff to be done every time */
    if (!InitInstance(hInstance, nCmdShow))
    {
      return FALSE;
    }

    hAccelTable = LoadAccelerators(hInstance, szAppName);

    /* Main loop */
    /* Acquire and dispatch messages until a WM_QUIT message is received */
    while (GetMessage(&msg, NULL, 0, 0))
    {
      /* Add other Translation functions (for modeless dialogs
	 and/or MDI windows) here. */

      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
59
            DispatchMessage(&msg);
Alexandre Julliard's avatar
Alexandre Julliard committed
60 61 62 63 64 65 66 67
        }
    }

    /* Add module specific instance free/delete functions here */

    /* Returns the value from PostQuitMessage */
    return msg.wParam;
}