Ejemplo n.º 1
0
Archivo: main.c Proyecto: Sunmonds/wine
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
{
  MSG      msg;

  Globals.lpszIniFile         = "progman.ini";
  Globals.lpszIcoFile         = "progman.ico";

  Globals.hInstance           = hInstance;
  Globals.hGroups             = 0;
  Globals.hActiveGroup        = 0;

  /* Read Options from `progman.ini' */
  Globals.bAutoArrange =
    GetPrivateProfileInt("Settings", "AutoArrange", 0, Globals.lpszIniFile);
  Globals.bMinOnRun =
    GetPrivateProfileInt("Settings", "MinOnRun", 0, Globals.lpszIniFile);
  Globals.bSaveSettings =
    GetPrivateProfileInt("Settings", "SaveSettings", 0, Globals.lpszIniFile);

  /* Load default icons */
  Globals.hMainIcon    = ExtractIcon(Globals.hInstance, Globals.lpszIcoFile, 0);
  Globals.hGroupIcon   = ExtractIcon(Globals.hInstance, Globals.lpszIcoFile, 0);
  Globals.hDefaultIcon = ExtractIcon(Globals.hInstance, Globals.lpszIcoFile, 0);
  if (!Globals.hMainIcon)    Globals.hMainIcon = LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
  if (!Globals.hGroupIcon)   Globals.hGroupIcon = LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));
  if (!Globals.hDefaultIcon) Globals.hDefaultIcon = LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON));

  /* Register classes */
  if (!prev)
    {
      if (!MAIN_RegisterMainWinClass()) return(FALSE);
      if (!GROUP_RegisterGroupWinClass()) return(FALSE);
      if (!PROGRAM_RegisterProgramWinClass()) return(FALSE);
    }

  /* Create main window */
  MAIN_CreateMainWindow();
  Globals.hAccel = LoadAccelerators(Globals.hInstance, STRING_ACCEL);

  /* Setup menu, stringtable and resourcenames */
  STRING_LoadMenus();

  MAIN_CreateMDIWindow();

  /* Initialize groups */
  MAIN_CreateGroups();

  /* Start initial applications */
  MAIN_AutoStart();

  /* Message loop */
  while (GetMessage (&msg, 0, 0, 0))
    if (!TranslateAccelerator(Globals.hMainWnd, Globals.hAccel, &msg))
      {
	TranslateMessage (&msg);
	DispatchMessage (&msg);
      }
  return 0;
}
Ejemplo n.º 2
0
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
{
    MSG msg;
    INITCOMMONCONTROLSEX icex;

    /*
     * Set our shutdown parameters: we want to shutdown the very last,
     * but before any TaskMgr instance (which has a shutdown level of 1).
     */
    SetProcessShutdownParameters(2, 0);

    Globals.hInstance    = hInstance;
    Globals.hGroups      = NULL;
    Globals.hActiveGroup = NULL;

    /* Load Program Manager's settings */
    MAIN_LoadSettings();

    /* Load the default icons */
    Globals.hDefaultIcon       = LoadIconW(NULL, MAKEINTRESOURCEW(IDI_WINLOGO));
    Globals.hMainIcon          = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_APPICON));
    Globals.hPersonalGroupIcon = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_GROUP_PERSONAL_ICON));
    Globals.hCommonGroupIcon   = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_GROUP_COMMON_ICON));

    /* Initialize the common controls */
    icex.dwSize = sizeof(icex);
    icex.dwICC  = ICC_HOTKEY_CLASS | ICC_LISTVIEW_CLASSES; // | ICC_STANDARD_CLASSES;
    InitCommonControlsEx(&icex);

    /* Register the window classes */
    if (!hPrevInstance) // FIXME: Unused on Win32!
    {
        if (!MAIN_RegisterMainWinClass())   goto Quit;
        if (!GROUP_RegisterGroupWinClass()) goto Quit;
    }

    /* Set up the strings, the main window, the accelerators, the menu, and the MDI child window */
    STRING_LoadStrings();
    MAIN_CreateMainWindow();
    Globals.hAccel = LoadAcceleratorsW(Globals.hInstance, MAKEINTRESOURCEW(IDA_ACCEL));
    STRING_LoadMenus();
    MAIN_CreateMDIWindow();

    /* Load all the groups */
    // MAIN_CreateGroups();
    MAIN_LoadGroups();

    /* Load the Startup group: start the initial applications */
    MAIN_AutoStart();

    /* Message loop */
    while (GetMessageW(&msg, NULL, 0, 0))
    {
        if (!TranslateMDISysAccel(Globals.hMDIWnd, &msg) &&
            !TranslateAcceleratorW(Globals.hMainWnd, Globals.hAccel, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

Quit:

    /* Save the settings, close the registry keys and quit */

    // MAIN_SaveSettings();
    RegCloseKey(Globals.hKeyCommonGroups);
    RegCloseKey(Globals.hKeyUnicodeGroups);
    RegCloseKey(Globals.hKeyAnsiGroups);
    RegCloseKey(Globals.hKeyPMUnicodeGroups);
    RegCloseKey(Globals.hKeyPMAnsiGroups);
    RegCloseKey(Globals.hKeyPMCommonGroups);
    RegCloseKey(Globals.hKeyPMSettings);
    RegCloseKey(Globals.hKeyProgMan);

    return 0;
}