Sweden-Number/programs/progman/main.c

555 lines
15 KiB
C
Raw Normal View History

Release 960302 Sat Mar 2 18:19:06 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/scroll.c] Fixed SCROLL_THUMB painting fixes from Alex Korobka to store the current tracking window. * [files/file.c] Fixed two file descriptor leaks in FILE_OpenFile(). * [if1632/relay32.c] [loader/module.c] [loader/pe_image.c] [tools/build.c] Replaced LOADEDFILEINFO structure by OFSTRUCT. * [memory/atom.c] Reload the pointer to the atom table in ATOM_GetTable() and ATOM_AddAtom() in case the LOCAL_Alloc() calls caused the table to move in linear memory. Fri Mar 1 11:57:13 1996 Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl> * [include/callback.h] Added support for CallWordBreakProc(). * [controls/edit.c] New caret handling (really efficient / fast). Implemented EM_SETWORDBREAKPROC and EM_GETWORDBREAKPROC. Fixed EM_SETFONT so it now also creates a proper new caret. Wed Feb 28 22:03:34 1996 Daniel Schepler <daniel@frobnitz.wustl.edu> * [controls/desktop.c] [misc/main.c] [windows/event.c] [windows/win.c] Added WM_DELETE protocol to top-level windows. * [controls/scroll.c] Fixed a problem which caused slow scrolling to continue uncontrollably. * [misc/exec.c] Implemented ExitWindows(). * [windows/win.c] Set top-level owned windows to be transient. Wed Feb 28 19:13:22 1996 Ulrich Schmid <uschmid@mail.hh.provi.de> * [programs/progman/*] Added a program manager. Wed Feb 28 18:38:01 1996 Duncan C Thomson <duncan@spd.eee.strath.ac.uk> * [resources/sysres_Eo.c] Added support for Esperanto [Eo] language. Wed Feb 28 00:23:00 1996 Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk> * [if1632/user32.spec] Added EndDialog, GetDlgItem, GetDlgItemInt, SetDlgItemInt, * [win32/init.c] Added task.h to includes. GetModuleHandleA() - return hInstance if called with NULL parameter. Freecell needs this. NOTE this may indicate a problem with differentiation between hModule and hInstance within Wine. * [win32/resource.c] FindResource32() and LoadResource32() - Removed #if 0's around conversion from hInstance to hModule. See remarks above. * [win32/string32.c] WIN32_UniLen() - removed stray semicolon. Tue Feb 27 21:05:18 1996 Jim Peterson <jspeter@birch.ee.vt.edu> * [windows/caret.c] Set blink rate with call to GetProfileInt(). * [rc/winerc.c] In new_style(), made initial flag settings WS_CHILD | WS_VISIBLE instead of 0. This seems to correspond to Borland's defaults, and the flags can be unset by using the (rather obtuse) "| NOT WS_CHILD" or "| NOT WS_VISIBLE" technique in the *.rc file. * [win32/time.c] In GetLocalTime() and GetSystemTime(), used tv_sec field of result returned by gettimeofday() instead of making second call to time(). This eliminates clock jitter if the seconds change between the two calls (rare, but possible). * [include/wintypes.h] Added "#define _far" and "#define _pascal". * [windows/win.c] Added function GetDesktopHwnd(). * [include/xmalloc.h] Removed the '#ifdef HAVE_STDLIB_H' structure, since it seemed to have been removed from 'configure', and was causing redefinition warnings. Tue Feb 27 19:31:11 1996 Albrecht Kleine <kleine@ak.sax.de> * [windows/winpos.c] Added RDW_ALLCHILDREN flag in SetWindowPos (handling SWP_FRAMECHANGED) to force a repaint when setting menu bars with different rows. Sun Feb 25 21:15:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [windows/syscolors.c] [controls/scroll.c] Fixed DrawFocusRect pen and SCROLL_THUMB painting.
1996-03-02 20:34:10 +01:00
/*
* Program Manager
*
* Copyright 1996 Ulrich Schmid <uschmid@mail.hh.provi.de>
*/
#include <stdio.h>
#include <windows.h>
#include "license.h"
#include "progman.h"
#ifdef WINELIB
Release 960309 Fri Mar 8 19:07:18 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [configure.in] Quote '[' and ']' in the test program for the strength-reduce bug. This should work much better... * [files/file.c] Augmented DOS_FILE structure. Most internal functions now return a DOS_FILE* instead of a Unix handle. Added a local file array to replace the PDB list upon startup, to allow using file I/O functions before the first task is created. Added FILE_SetDateTime() and FILE_Sync() functions. * [loader/module.c] Use the DOS file I/O functions in MODULE_LoadExeHeader(). * [objects/bitblt.c] Use visible region instead of GC clip region to clip source area. This fixes the card drawing bug in freecell. * [objects/region.c] Fixed CombineRgn() to allow src and dest regions to be the same. Fri Mar 8 16:32:23 1996 Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl> * [controls/EDIT.TODO] Updated so it reflects the current status. * [controls/edit.c] Implemented internal EDIT_WordBreakProc(). Implemented ES_READONLY. Implemented WM_LBUTTONDBLCLK to select whole words. Fixed a lot of types in the function definitions. Wed Mar 6 19:55:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [debugger/info.c] Added "walk window" command to walk window list. * [windows/mdi.c] Added proper(?) WM_MDISETMENU message handling. Wed Mar 6 09:27:12 1996 Martin von Loewis <loewis@informatik.hu-berlin.de> * [if1632/callback.c][if1632/relay32.c] RELAY32_CallWindowProcConvStruct: new function. * [win32/struct32.c][win32/Makefile.in][win32/param.c][win32/user32.c] struct32.c: new file. Moved all structure conversions into that file PARAM32_POINT32to16,MSG16to32,USER32_RECT32to16: renamed to STRUCT32_POINT32to16, ... WIN32_POINT,WIN32_MSG,WIN32_RECT,WIN32_PAINTSTRUCT: renamed to POINT32, ... New conversion functions for NCCALCSIZE_PARAMS, WINDOWPOS, CREATESTRUCT. * [include/windows.h][misc/exec.c] WINHELP, MULTIKEYHELP, HELPWININFO: new structures WinHelp: Reimplemented. Thanks to Peter Balch (100710.2566@compuserve.com) for his valuable research. * [win32/winprocs.c] WIN32_CallWindowProcTo16: new function, call in USER32_DefWindowProcA,... Mon Mar 4 23:22:40 1996 Jim Peterson <jspeter@birch.ee.vt.edu> * [include/wintypes.h] Added "#define __export". * [objects/bitblt.c] Put in a few hacks to make bitblt-ing work when upside-down and/or mirrored. BITBLT_StretchImage should really be checked over thoroughly. * [programs/progman/main.c] Added "#include <resource.h>" for definition of HAVE_WINE_CONSTRUCTOR. * [rc/parser.h] [rc/parser.l] [rc/parser.y] [rc/winerc.c] Eliminated shift/reduce conflict in style definition. Added crude error message support: "stdin:%d: parse error before '%s'". Implemented string table support to the best of my ability (it works with LoadString() calls). * [windows/nonclient.c] Fixed bug in NC_DoSizeMove() that made system menu pop up when title bar of non-iconized window was clicked (checked for iconization). Mon Mar 04 20:55:19 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [if1632/lzexpand.spec] [if1632/relay.c] [include/lzexpand.h][misc/lzexpand.c] LZEXPAND.DLL added. Sun Mar 03 18:10:22 1996 Albrecht Kleine <kleine@ak.sax.de> * [windows/win.c] Prevent usage of invalid HWNDs in WIN_EnumChildWin(), this prevents too early termination of EnumChildWindows().
1996-03-09 17:12:43 +01:00
#include <resource.h>
Release 960302 Sat Mar 2 18:19:06 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/scroll.c] Fixed SCROLL_THUMB painting fixes from Alex Korobka to store the current tracking window. * [files/file.c] Fixed two file descriptor leaks in FILE_OpenFile(). * [if1632/relay32.c] [loader/module.c] [loader/pe_image.c] [tools/build.c] Replaced LOADEDFILEINFO structure by OFSTRUCT. * [memory/atom.c] Reload the pointer to the atom table in ATOM_GetTable() and ATOM_AddAtom() in case the LOCAL_Alloc() calls caused the table to move in linear memory. Fri Mar 1 11:57:13 1996 Frans van Dorsselaer <dorssel@rulhm1.leidenuniv.nl> * [include/callback.h] Added support for CallWordBreakProc(). * [controls/edit.c] New caret handling (really efficient / fast). Implemented EM_SETWORDBREAKPROC and EM_GETWORDBREAKPROC. Fixed EM_SETFONT so it now also creates a proper new caret. Wed Feb 28 22:03:34 1996 Daniel Schepler <daniel@frobnitz.wustl.edu> * [controls/desktop.c] [misc/main.c] [windows/event.c] [windows/win.c] Added WM_DELETE protocol to top-level windows. * [controls/scroll.c] Fixed a problem which caused slow scrolling to continue uncontrollably. * [misc/exec.c] Implemented ExitWindows(). * [windows/win.c] Set top-level owned windows to be transient. Wed Feb 28 19:13:22 1996 Ulrich Schmid <uschmid@mail.hh.provi.de> * [programs/progman/*] Added a program manager. Wed Feb 28 18:38:01 1996 Duncan C Thomson <duncan@spd.eee.strath.ac.uk> * [resources/sysres_Eo.c] Added support for Esperanto [Eo] language. Wed Feb 28 00:23:00 1996 Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk> * [if1632/user32.spec] Added EndDialog, GetDlgItem, GetDlgItemInt, SetDlgItemInt, * [win32/init.c] Added task.h to includes. GetModuleHandleA() - return hInstance if called with NULL parameter. Freecell needs this. NOTE this may indicate a problem with differentiation between hModule and hInstance within Wine. * [win32/resource.c] FindResource32() and LoadResource32() - Removed #if 0's around conversion from hInstance to hModule. See remarks above. * [win32/string32.c] WIN32_UniLen() - removed stray semicolon. Tue Feb 27 21:05:18 1996 Jim Peterson <jspeter@birch.ee.vt.edu> * [windows/caret.c] Set blink rate with call to GetProfileInt(). * [rc/winerc.c] In new_style(), made initial flag settings WS_CHILD | WS_VISIBLE instead of 0. This seems to correspond to Borland's defaults, and the flags can be unset by using the (rather obtuse) "| NOT WS_CHILD" or "| NOT WS_VISIBLE" technique in the *.rc file. * [win32/time.c] In GetLocalTime() and GetSystemTime(), used tv_sec field of result returned by gettimeofday() instead of making second call to time(). This eliminates clock jitter if the seconds change between the two calls (rare, but possible). * [include/wintypes.h] Added "#define _far" and "#define _pascal". * [windows/win.c] Added function GetDesktopHwnd(). * [include/xmalloc.h] Removed the '#ifdef HAVE_STDLIB_H' structure, since it seemed to have been removed from 'configure', and was causing redefinition warnings. Tue Feb 27 19:31:11 1996 Albrecht Kleine <kleine@ak.sax.de> * [windows/winpos.c] Added RDW_ALLCHILDREN flag in SetWindowPos (handling SWP_FRAMECHANGED) to force a repaint when setting menu bars with different rows. Sun Feb 25 21:15:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu> * [windows/syscolors.c] [controls/scroll.c] Fixed DrawFocusRect pen and SCROLL_THUMB painting.
1996-03-02 20:34:10 +01:00
#include <options.h>
#include <shell.h>
#endif
GLOBALS Globals;
static VOID MAIN_CreateGroups(void);
static VOID MAIN_MenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);
static ATOM MAIN_RegisterMainWinClass(void);
static VOID MAIN_CreateMainWindow(void);
static VOID MAIN_CreateMDIWindow(void);
static VOID MAIN_AutoStart(void);
#define BUFFER_SIZE 1000
/***********************************************************************
*
* WinMain
*/
int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show)
{
MSG msg;
#ifndef WINELIB
Globals.lpszIniFile = "progman.ini";
Globals.lpszIcoFile = "progman.ico";
#else /* Configuration in `wine.ini' */
{
CHAR buffer[MAX_PATHNAME_LEN], *p;
/* Redirect `progman.ini' */
PROFILE_GetWineIniString("progman", "progman.ini", "progman.ini",
buffer, sizeof(buffer));
Globals.lpszIniFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)));
hmemcpy(p, buffer, 1 + lstrlen(buffer));
/* Redirect `progman.ico' */
PROFILE_GetWineIniString("progman", "progman.ico", "progman.ico",
buffer, sizeof(buffer));
Globals.lpszIcoFile = p = LocalLock(LocalAlloc(LMEM_FIXED, lstrlen(buffer)));
hmemcpy(p, buffer, 1 + lstrlen(buffer));
}
#endif
/* Select Language */
Globals.lpszLanguage = "En";
#ifdef WINELIB
if (Options.language == LANG_Cz) Globals.lpszLanguage = "Cz";
if (Options.language == LANG_Da) Globals.lpszLanguage = "Da";
if (Options.language == LANG_De) Globals.lpszLanguage = "De";
if (Options.language == LANG_Es) Globals.lpszLanguage = "Es";
if (Options.language == LANG_Fi) Globals.lpszLanguage = "Fi";
if (Options.language == LANG_Fr) Globals.lpszLanguage = "Fr";
if (Options.language == LANG_No) Globals.lpszLanguage = "No";
#ifndef HAVE_WINE_CONSTRUCTOR
/* Register resources */
LIBWINE_Register_accel();
LIBWINE_Register_De();
LIBWINE_Register_En();
#endif
#endif
Globals.hInstance = hInstance;
Globals.hGroups = 0;
/* FIXME should use MDI */
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_SelectLanguage(Globals.lpszLanguage);
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;
}
/***********************************************************************
*
* MAIN_CreateGroups
*/
static VOID MAIN_CreateGroups()
{
CHAR buffer[BUFFER_SIZE];
CHAR szPath[MAX_PATHNAME_LEN];
CHAR key[20], *ptr;
/* Initialize groups according the `Order' entry of `progman.ini' */
GetPrivateProfileString("Settings", "Order", "", buffer, sizeof(buffer), Globals.lpszIniFile);
ptr = buffer;
while (ptr < buffer + sizeof(buffer))
{
int num, skip, ret;
ret = sscanf(ptr, "%d%n", &num, &skip);
if (ret == 0) MAIN_FileReadError(Globals.lpszIniFile);
if (ret != 1) break;
sprintf(key, "Group%d", num);
GetPrivateProfileString("Groups", key, "", szPath,
sizeof(szPath), Globals.lpszIniFile);
if (!szPath[0]) continue;
GRPFILE_ReadGroupFile(szPath);
ptr += skip;
}
/* FIXME initialize other groups, not enumerated by `Order' */
}
/***********************************************************************
*
* MAIN_AutoStart
*/
VOID MAIN_AutoStart()
{
CHAR buffer[BUFFER_SIZE];
HLOCAL hGroup, hProgram;
GetPrivateProfileString("Settings", "AutoStart", "Autostart", buffer,
sizeof(buffer), Globals.lpszIniFile);
for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
if (!lstrcmp(buffer, GROUP_GroupName(hGroup)))
for (hProgram = PROGRAM_FirstProgram(hGroup); hProgram;
hProgram = PROGRAM_NextProgram(hProgram))
PROGRAM_ExecuteProgram(hProgram);
}
/***********************************************************************
*
* MAIN_MainWndProc
*/
static LRESULT MAIN_MainWndProc (HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
#if 0
printf("M %4.4x %4.4x\n", msg, wParam);
#endif
switch (msg)
{
case WM_INITMENU:
CheckMenuItem(Globals.hOptionMenu, PM_AUTO_ARRANGE,
MF_BYCOMMAND | (Globals.bAutoArrange ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(Globals.hOptionMenu, PM_MIN_ON_RUN,
MF_BYCOMMAND | (Globals.bMinOnRun ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(Globals.hOptionMenu, PM_SAVE_SETTINGS,
MF_BYCOMMAND | (Globals.bSaveSettings ? MF_CHECKED : MF_UNCHECKED));
break;
case WM_COMMAND:
if (wParam < PM_FIRST_CHILD)
MAIN_MenuCommand(hWnd, wParam, lParam);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
}
return(DefFrameProc(hWnd, Globals.hMDIWnd, msg, wParam, lParam));
}
/***********************************************************************
*
* MAIN_MenuCommand
*/
static VOID MAIN_MenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
HLOCAL hActiveGroup = GROUP_ActiveGroup();
HLOCAL hActiveProgram = PROGRAM_ActiveProgram(hActiveGroup);
HWND hActiveGroupWnd = GROUP_GroupWnd(hActiveGroup);
switch(wParam)
{
/* Menu File */
case PM_NEW:
switch (DIALOG_New((hActiveGroupWnd && !IsIconic(hActiveGroupWnd)) ?
PM_NEW_PROGRAM : PM_NEW_GROUP))
{
case PM_NEW_PROGRAM:
if (hActiveGroup) PROGRAM_NewProgram(hActiveGroup);
break;
case PM_NEW_GROUP:
GROUP_NewGroup();
break;
}
break;
case PM_OPEN:
if (hActiveProgram)
PROGRAM_ExecuteProgram(hActiveProgram);
else if (hActiveGroupWnd)
OpenIcon(hActiveGroupWnd);
break;
case PM_MOVE:
case PM_COPY:
if (hActiveProgram)
PROGRAM_CopyMoveProgram(hActiveProgram, wParam == PM_MOVE);
break;
case PM_DELETE:
if (hActiveProgram)
{
if (DIALOG_Delete(STRING_DELETE_PROGRAM_s, PROGRAM_ProgramName(hActiveProgram)))
PROGRAM_DeleteProgram(hActiveProgram, TRUE);
}
else if (hActiveGroup)
{
if (DIALOG_Delete(STRING_DELETE_GROUP_s, GROUP_GroupName(hActiveGroup)))
GROUP_DeleteGroup(hActiveGroup);
}
break;
case PM_ATTRIBUTES:
if (hActiveProgram)
PROGRAM_ModifyProgram(hActiveProgram);
else if (hActiveGroup)
GROUP_ModifyGroup(hActiveGroup);
break;
case PM_EXECUTE:
DIALOG_Execute();
break;
case PM_EXIT:
PostQuitMessage(0);
break;
/* Menu Options */
case PM_AUTO_ARRANGE:
Globals.bAutoArrange = !Globals.bAutoArrange;
CheckMenuItem(Globals.hOptionMenu, PM_AUTO_ARRANGE,
MF_BYCOMMAND | (Globals.bAutoArrange ?
MF_CHECKED : MF_UNCHECKED));
WritePrivateProfileString("Settings", "AutoArrange",
Globals.bAutoArrange ? "1" : "0",
Globals.lpszIniFile);
WriteOutProfiles();
break;
case PM_MIN_ON_RUN:
Globals.bMinOnRun = !Globals.bMinOnRun;
CheckMenuItem(Globals.hOptionMenu, PM_MIN_ON_RUN,
MF_BYCOMMAND | (Globals.bMinOnRun ?
MF_CHECKED : MF_UNCHECKED));
WritePrivateProfileString("Settings", "MinOnRun",
Globals.bMinOnRun ? "1" : "0",
Globals.lpszIniFile);
WriteOutProfiles();
break;
case PM_SAVE_SETTINGS:
Globals.bSaveSettings = !Globals.bSaveSettings;
CheckMenuItem(Globals.hOptionMenu, PM_SAVE_SETTINGS,
MF_BYCOMMAND | (Globals.bSaveSettings ?
MF_CHECKED : MF_UNCHECKED));
WritePrivateProfileString("Settings", "SaveSettings",
Globals.bSaveSettings ? "1" : "0",
Globals.lpszIniFile);
WriteOutProfiles();
break;
/* Menu Windows */
case PM_ARRANGE:
SendMessage(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0);
break;
/* Menu Language */
case PM_Da: STRING_SelectLanguage("Da"); break;
case PM_De: STRING_SelectLanguage("De"); break;
case PM_En: STRING_SelectLanguage("En"); break;
case PM_Es: STRING_SelectLanguage("Es"); break;
case PM_Fi: STRING_SelectLanguage("Fi"); break;
case PM_Fr: STRING_SelectLanguage("Fr"); break;
case PM_No: STRING_SelectLanguage("No"); break;
/* Menu Help */
case PM_CONTENTS:
if (!WinHelp(Globals.hMainWnd, "progman.hlp", HELP_INDEX, 0))
MAIN_WinHelpError();
break;
case PM_HELPONHELP:
if (!WinHelp(Globals.hMainWnd, "progman.hlp", HELP_HELPONHELP, 0))
MAIN_WinHelpError();
break;
case PM_TUTORIAL:
WinExec("wintutor.exe", SW_SHOWNORMAL);
break;
case PM_LICENSE:
WineLicense(Globals.hMainWnd, Globals.lpszLanguage);
break;
case PM_NO_WARRANTY:
WineWarranty(Globals.hMainWnd, Globals.lpszLanguage);
break;
#ifdef WINELIB
case PM_ABOUT_WINE:
{
extern const char people[];
ShellAbout(hWnd, "WINE", people, 0);
}
break;
#endif
default:
MAIN_NotImplementedError();
break;
}
}
/***********************************************************************
*
* MAIN_RegisterMainWinClass
*/
static ATOM MAIN_RegisterMainWinClass()
{
WNDCLASS class;
class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = MAIN_MainWndProc;
class.cbClsExtra = 0;
class.cbWndExtra = 0;
class.hInstance = Globals.hInstance;
class.hIcon = Globals.hMainIcon;
class.hCursor = LoadCursor (0, IDC_ARROW);
class.hbrBackground = GetStockObject (NULL_BRUSH);
class.lpszMenuName = 0;
class.lpszClassName = STRING_MAIN_WIN_CLASS_NAME;
return RegisterClass(&class);
}
/***********************************************************************
*
* MAIN_CreateMainWindow
*/
static VOID MAIN_CreateMainWindow()
{
INT left , top, right, bottom, width, height, show;
CHAR buffer[100];
Globals.hMDIWnd = 0;
Globals.hMainMenu = 0;
/* Get the geometry of the main window */
GetPrivateProfileString("Settings", "Window", "",
buffer, sizeof(buffer), Globals.lpszIniFile);
if (5 == sscanf(buffer, "%d %d %d %d %d", &left, &top, &right, &bottom, &show))
{
width = right - left;
height = bottom - top;
}
else
{
left = top = width = height = CW_USEDEFAULT;
show = SW_SHOWNORMAL;
}
/* Create main Window */
Globals.hMainWnd =
CreateWindow (STRING_MAIN_WIN_CLASS_NAME, "",
WS_OVERLAPPEDWINDOW, left, top, width, height,
0, 0, Globals.hInstance, 0);
ShowWindow (Globals.hMainWnd, show);
UpdateWindow (Globals.hMainWnd);
}
/***********************************************************************
*
* MAIN_CreateMDIWindow
*/
static VOID MAIN_CreateMDIWindow()
{
CLIENTCREATESTRUCT ccs;
RECT rect;
/* Get the geometry of the MDI window */
GetClientRect(Globals.hMainWnd, &rect);
ccs.hWindowMenu = Globals.hWindowsMenu;
ccs.idFirstChild = PM_FIRST_CHILD;
/* Create MDI Window */
Globals.hMDIWnd =
CreateWindow (STRING_MDI_WIN_CLASS_NAME, "",
WS_CHILD, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
Globals.hMainWnd, 0,
Globals.hInstance, &ccs);
ShowWindow (Globals.hMDIWnd, SW_SHOW);
UpdateWindow (Globals.hMDIWnd);
}
/**********************************************************************/
/***********************************************************************
*
* MAIN_ReplaceString
*/
VOID MAIN_ReplaceString(HLOCAL *handle, LPSTR replace)
{
HLOCAL newhandle = LocalAlloc(LMEM_FIXED, strlen(replace) + 1);
if (newhandle)
{
LPSTR newstring = LocalLock(newhandle);
lstrcpy(newstring, replace);
LocalFree(*handle);
*handle = newhandle;
}
else MAIN_OutOfMemoryError();
}
/***********************************************************************
*
* MAIN_NotImplementedError
*/
VOID MAIN_NotImplementedError()
{
MessageBox(Globals.hMainWnd,
STRING_NOT_IMPLEMENTED, STRING_ERROR, MB_OK);
}
/***********************************************************************
*
* MAIN_OutOfMemoryError
*/
VOID MAIN_OutOfMemoryError()
{
MessageBox(Globals.hMainWnd,
STRING_OUT_OF_MEMORY, STRING_ERROR, MB_OK);
}
/***********************************************************************
*
* MAIN_WinHelpError
*/
VOID MAIN_WinHelpError()
{
MessageBox(Globals.hMainWnd,
STRING_WINHELP_ERROR, STRING_ERROR, MB_OK);
}
/***********************************************************************
*
* MAIN_FileReadError
*/
VOID MAIN_FileReadError(LPCSTR lpszPath)
{
CHAR msg[MAX_PATHNAME_LEN + 1000];
if (sizeof(msg) <= strlen(STRING_FILE_READ_ERROR_s) + strlen(lpszPath)) return;
wsprintf(msg, (LPSTR)STRING_FILE_READ_ERROR_s, lpszPath);
MessageBox(Globals.hMainWnd, msg, STRING_ERROR, MB_OK);
}
/***********************************************************************
*
* MAIN_FileWriteError
*/
VOID MAIN_FileWriteError(LPCSTR lpszPath)
{
CHAR msg[MAX_PATHNAME_LEN + 1000];
if (sizeof(msg) <= strlen(STRING_FILE_WRITE_ERROR_s) + strlen(lpszPath)) return;
wsprintf(msg, (LPSTR)STRING_FILE_WRITE_ERROR_s, lpszPath);
MessageBox(Globals.hMainWnd, msg, STRING_ERROR, MB_OK);
}
/***********************************************************************
*
* MAIN_GrpFileReadError
*/
VOID MAIN_GrpFileReadError(LPCSTR lpszPath)
{
CHAR msg[MAX_PATHNAME_LEN + 1000];
if (sizeof(msg) <= strlen(STRING_GRPFILE_READ_ERROR_s) + strlen(lpszPath)) return;
wsprintf(msg, (LPSTR)STRING_GRPFILE_READ_ERROR_s, lpszPath);
MessageBox(Globals.hMainWnd, msg, STRING_ERROR, MB_YESNO);
}
/* Local Variables: */
/* c-file-style: "GNU" */
/* End: */