wine/programs/progman/dialog.c
Alexandre Julliard 46ea8b3f73 Release 980503
Thu Apr 30 16:28:12 1998  James Juran <jrj120@psu.edu>

	* [scheduler/process.c]
	Implemented GetExitCodeProcess.  The code is a direct translation
	of GetExitCodeThread.

Mon Apr 27 22:20:25 1998  Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>

	* [loader/pe_image.c]
	Unload dummy module when PE_LoadLibraryEx32A fails with
	PE_LoadImage (makes Encarta 98 installer proceed).

	* [files/drive.c]
	Make GetDriveType16 return DRIVE_REMOVABLE for TYPE_CDROM.
	Make GetCurrentDirectory32 behave like the code does and not
	like the help describes.

	* [files/profile.c]
	Revoke recent change in PROFILE_GetSection and try better 
	handling of special case.

	* [include/windows.h]
	Change definition of ACCEL32.

	* [misc/commdlg.c]
	Replace the GetXXXFilename32 macros by normal code.
	Fix two reported bugs in my changes to commdlg.

	* [windows/win.c]
	Add a hook to catch bogus WM_SIZE messages by emitting a warning
	in the appropriate case.

	* [objects/bitmap.c]
	Reject unreasonbable large size arguments in
	CreateCompatibleBitmap32 and add an fixme for that situation.

Sun Apr 26 18:30:07 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [include/ldt.h] [debugger/*.c] [miscemu/instr.c]
	Added IS_SELECTOR_SYSTEM and IS_SELECTOR_32BIT macros.
	Make instruction emulation support system selectors.

	* [loader/*.c]
	Started moving NE specific functions to the new loader/ne
	directory.

	* [memory/environ.c]
	Enforce the 127 chars limit only when creating the environment of
	a Win16 process.

Sun Apr 26 12:22:23 1998  Andreas Mohr <100.30936@germany.net>

	* [files/file.c]
	Fixed an incredible typo in CopyFile32A that made it unusable
	since a rewrite in 970112 (!!).

	* [files/directory.c]
	Fixed GetTempPath32A/W to include trailing backslash.

	* [misc/ver.c]
	Make find_pe_resource "work" with corrupt files.

	* [misc/wsprintf.c]
	Altered WPRINTF_ParseFormatA/W to treat invalid format chars
	as normal output, too.

	* [msdos/dpmi.c]
	Implemented "Allocate/Free real mode callback" (0x0303/0x0304).
	Cross your fingers if you need to use it ;) (completely untested)
	Implemented "Call real mode proc with far return" (0x0301, tested).

	* [msdos/int21.c]
	Fixed ioctlGenericBlkDevReq/0x60.

	* [relay32/dplayx.spec] [relay32/builtin32.c] [relay32/Makefile.in]
	Added built-in DPLAYX.DLL. 

	* [windows/win.c]
	Fixed GetWindowWord()/GWW_HWNDPARENT to return the window's owner
	if it has no parent (SDK).

Sat Apr 25 15:09:53 1998  M.T.Fortescue  <mark@mtfhpc.demon.co.uk>

	* [debugger/db_disasm.c]
	Fixed disassemble bug for no-display option and 'lock',
	'repne' and 'repe' prefixes.

	* [debugger/registers.c]
	Added textual flag description output on 'info regs'.

Sat Apr 25 14:18:26 1998  Matthew Becker <mbecker@glasscity.net>

	* [*/*.c]
	Added stubs and/or documentation for the following functions: 
	LookupPrivilegeValue, OpenService, ControlService, RegGetKeySecurity, 
	StartService, SetComputerName, DeleteService, CloseServiceHandle, 
	OpenProcessToken, OpenSCManager, DeregisterEventSource, 
	WaitForDebugEvent, WaitForInputIdle, RegisterEventSource,
	SetDebugErrorLevel, SetConsoleCursorPosition, ChoosePixelFormat,
	SetPixelFormat, GetPixelFormat, DescribePixelFormat, SwapBuffers,
	PolyBezier, AbortPath, DestroyAcceleratorTable, HeapWalk,
	DdeInitialize, DdeUninitialize, DdeConnectList, DdeDisconnectList,
	DdeCreateStringHandle, DdePostAdvise, DdeGetData, DdeNameService,
	DdeGetLastError, WNetGetDirectoryType, EnumPrinters, RegFlushKey,
	RegGetKeySecurity, DllGetClassObject, DllCanUnloadNow, CreateBitmap,
	CreateCompatibleBitmap, CreateBitmapIndirect, GetBitmapBits,
	SetBitmapBits, LoadImage, CopyImage, LoadBitmap, DrawIcon,
	CreateDiscardableBitmap, SetDIBits, GetCharABCWidths, LoadTypeLib,
	SetConsoleCtrlHandler, CreateConsoleScreenBuffer, ReadConsoleInput,
	GetConsoleCursorInfo, SetConsoleCursorInfo, SetConsoleWindowInfo,
	SetConsoleTextAttribute, SetConsoleScreenBufferSize,
	FillConsoleOutputCharacter, FillConsoleOutputAttribute,
	CreateMailslot, GetMailslotInfo, GetCompressedFileSize,
	GetProcessWindowStation, GetThreadDesktop, SetDebugErrorLevel,
	WaitForDebugEvent, SetComputerName, CreateMDIWindow.

Thu Apr 23 23:54:04 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [include/windows.h] [objects/enhmetafile.c] [relay32/gdi32.spec]
	Implement CopyEnhMetaFile, Get/SetEnhMetaFileBits, other fixes.

	* [include/windows.h] [objects/metafile.c] [relay32/gdi32.spec]
	32-bit metafile fixes, implement EnumMetaFile32, GetMetaFileBitsEx.

	* [objects/font.c] [graphics/x11drv/xfont.c] [graphics/x11drv/text.c]
	Some rotated text support for X11R6 displays.

	* [win32/newfns.c] [ole/ole2nls.c]
	Moved GetNumberFormat32A.

Wed Apr 22 17:38:20 1998  David Lee Lambert <lamber45@egr.msu.edu>

	* [ole/ole2nls.c] [misc/network.c]
	Changed some function documentation to the new style.

	* [misc/network.c] [include/windows.h] [if1632/user.spec]
	  [relay32/mpr.spec] [misc/mpr.c]
	Added stubs for some Win32 network functions;  renamed some 
	16-bit ones with 32-bit counterparts,  as well as
	WNetGetDirectoryType;  moved the stubs in misc/mpr.c (three of
	them!) to misc/network.c.

	* [ole/compobj.c] [ole/storage.c] [ole/ole2disp.c] 
	  [ole/ole2nls.c] [ole/folders.c] [ole/moniker.c] [ole/ole2.c]
	  [graphics/fontengine.c] [graphics/ddraw.c] [graphics/env.c]
	  [graphics/driver.c] [graphics/escape.c]
	Changed fprintf's to proper debug-macros.

	* [include/winnls.h]
	Added some flags (for internal use).

	* [ole/ole2nls.c] 
	Added the Unicode core function, and worked out a way to hide
	the commonality of the core.

	* [relay32/kernel32.spec]
	Added support for GetDate/Time32A/W.

Wed Apr 22 09:16:03 1998  Gordon Chaffee  <chaffee@cs.berkeley.edu>

	* [win32/code_page.c]
	Fixed problem with MultiByteToWideChar that was introduced in
	last release.  Made MultiByteToWideChar more compatible with Win32.

	* [graphics/x11drv/graphics.c]
	Fixed problem with drawing arcs.

Tue Apr 21 11:24:58 1998  Constantine Sapuntzakis  <csapuntz@tma-1.lcs.mit.edu>

	*  [ole/ole2nls.c]
	Move stuff from 0x409 case to Lang_En. 

	*  [relay32/user32.spec] [windows/winpos.c]
	Added stubs for GetWindowRgn32 and SetWindowRgn32. Makes Office
	Paperclip happy.

Tue Apr 21 11:16:16 1998  Constantine Sapuntzakis  <csapuntz@tma-1.lcs.mit.edu>

	*  [loader/pe_image.c]
	If image is relocated, TLS addresses need to be adjusted.

	* [debugger/*.c]
	Generalized tests for 32-bit segments.

Tue Apr 21 02:04:59 1998  James Juran  <jrj120@psu.edu>
	
	* [misc/*.c] [miscemu/*.c] [msdos/*.c] [if1632/*.c] 
	  [include/*.h] [loader/*.c] [memory/*.c] [multimedia/*.c] 
	  [objects/*.c]
	Almost all fprintf statements converted to appropriate 
	debug messages.

	* [README]
	Updated "GETTING MORE INFORMATION" section to include WineHQ.

	* [documentation/debugger]
	Fixed typo.

	* [windows/defwnd.c]
	Added function documentation.

Sun Apr 19 16:30:58 1998  Marcus Meissner <marcus@mud.de>

	* [Make.rules.in]
	Added lint target (using lclint).

	* [relay32/oleaut32.spec][relay32/Makefile.in][ole/typelib.c]
	  [ole/ole2disp.c]
	Added oleaut32 spec, added some SysString functions.

	* [if1632/signal.c]
	Added printing of faultaddress in Linux (using CR2 debug register).

	* [configure.in]
	Added <sys/types.h> for statfs checks.

	* [loader/*.c][debugger/break.c][debugger/hash.c]
	Started to split win32/win16 module handling, preparing support
	for other binary formats (like ELF).

Sat Apr 18 10:07:41 1998  Rein Klazes <rklazes@casema.net>

	* [misc/registry.c]
	Fixed a bug that made RegQueryValuexxx returning
	incorrect registry values.

Fri Apr 17 22:59:22 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [misc/lstr.c]
	FormatMessage32*: remove linefeed when nolinefeed set;
	check for target underflow.

Fri Apr 17 00:38:14 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [misc/crtdll.c]
	Implement xlat_file_ptr for CRT stdin/stdout/stderr address
	translation.

Wed Apr 15 20:43:56 1998  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [controls/menu.c]
	Added 'odaction' parameter to MENU_DrawMenuItem() and redirected
	WM_DRAWITEM messages to GetWindow(hwnd,GW_OWNER).

Tue Apr 14 16:17:55 1998  Berend Reitsma <berend@united-info.com>

	* [graphics/metafiledrv/init.c]	[graphics/painting.c] 
	  [graphics/win16drv/init.c] [graphics/x11drv/graphics.c]
	  [graphics/x11drv/init.c] [include/gdi.h] [include/x11drv.h]
	  [relay32/gdi32.spec]
	Added PolyPolyline routine.

	* [windows/winproc.c]
	Changed WINPROC_GetProc() to return proc instead of &(jmp proc).
1998-05-03 19:01:20 +00:00

619 lines
16 KiB
C

/*
* Program Manager
*
* Copyright 1996 Ulrich Schmid
*/
#include "windows.h"
#include "commdlg.h"
#include "progman.h"
static BOOL DIALOG_BrowsePrograms(HWND, LPSTR, INT);
static BOOL DIALOG_BrowseSymbols(HWND, LPSTR, INT);
static LRESULT DIALOG_NEW_DlgProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT DIALOG_COPY_MOVE_DlgProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT DIALOG_GROUP_DlgProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT DIALOG_PROGRAM_DlgProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT DIALOG_SYMBOL_DlgProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT DIALOG_EXECUTE_DlgProc(HWND, UINT, WPARAM, LPARAM);
/***********************************************************************
*
* DIALOG_New
*/
static struct
{
INT nDefault;
} New;
INT DIALOG_New(INT nDefault)
{
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_NEW_DlgProc, Globals.hInstance);
INT ret;
New.nDefault = nDefault;
ret = DialogBox(Globals.hInstance, STRING_NEW_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
return ret;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_NEW_DlgProc
*/
static LRESULT DIALOG_NEW_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, New.nDefault);
break;
case WM_COMMAND:
switch (wParam)
{
case PM_NEW_GROUP:
case PM_NEW_PROGRAM:
CheckRadioButton(hDlg, PM_NEW_GROUP, PM_NEW_PROGRAM, wParam);
return TRUE;
case IDOK:
EndDialog(hDlg, IsDlgButtonChecked(hDlg, PM_NEW_GROUP) ?
PM_NEW_GROUP : PM_NEW_PROGRAM);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_CopyMove
*/
static struct
{
LPCSTR lpszProgramName, lpszFromGroupName;
HLOCAL hToGroup;
} CopyMove;
HLOCAL DIALOG_CopyMove(LPCSTR lpszProgramName, LPCSTR lpszFromGroupName,
BOOL bMove)
{
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_COPY_MOVE_DlgProc, Globals.hInstance);
INT ret;
CopyMove.lpszProgramName = lpszProgramName;
CopyMove.lpszFromGroupName = lpszFromGroupName;
CopyMove.hToGroup = 0;
ret = DialogBox(Globals.hInstance,
bMove ? STRING_MOVE_Xx : STRING_COPY_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
return((ret == IDOK) ? CopyMove.hToGroup : 0);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_COPY_MOVE_DlgProc
*/
static LRESULT DIALOG_COPY_MOVE_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HLOCAL hGroup;
switch (msg)
{
case WM_INITDIALOG:
/* List all group names */
for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_ADDSTRING, 0,
(LPARAM) GROUP_GroupName(hGroup));
SetDlgItemText(hDlg, PM_PROGRAM, (LPSTR)CopyMove.lpszProgramName);
SetDlgItemText(hDlg, PM_FROM_GROUP, (LPSTR)CopyMove.lpszFromGroupName);
break;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
{
/* Get selected group */
INT nCurSel = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETCURSEL, 0, 0);
INT nLen = SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXTLEN, nCurSel, 0);
HLOCAL hBuffer = LocalAlloc(LMEM_FIXED, nLen + 1);
LPSTR buffer = LocalLock(hBuffer);
SendDlgItemMessage(hDlg, PM_TO_GROUP, CB_GETLBTEXT, nCurSel, (LPARAM)buffer);
for (hGroup = GROUP_FirstGroup(); hGroup; hGroup = GROUP_NextGroup(hGroup))
if (!lstrcmp(buffer, GROUP_GroupName(hGroup))) break;
LocalFree(hBuffer);
CopyMove.hToGroup = hGroup;
EndDialog(hDlg, IDOK);
return TRUE;
}
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_Delete
*/
BOOL DIALOG_Delete(UINT ids_text_s, LPCSTR lpszName)
{
return (IDYES == MAIN_MessageBoxIDS_s(ids_text_s, lpszName, IDS_DELETE,
MB_YESNO | MB_DEFBUTTON2));
}
/***********************************************************************
*
* DIALOG_GroupAttributes
*/
static struct
{
LPSTR lpszTitle, lpszGrpFile;
INT nSize;
} GroupAttributes;
BOOL DIALOG_GroupAttributes(LPSTR lpszTitle, LPSTR lpszGrpFile, INT nSize)
{
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_GROUP_DlgProc, Globals.hInstance);
INT ret;
GroupAttributes.nSize = nSize;
GroupAttributes.lpszTitle = lpszTitle;
GroupAttributes.lpszGrpFile = lpszGrpFile;
ret = DialogBox(Globals.hInstance, STRING_GROUP_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
return(ret == IDOK);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_GROUP_DlgProc
*/
static LRESULT DIALOG_GROUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle);
SetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile);
break;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
GetDlgItemText(hDlg, PM_DESCRIPTION, GroupAttributes.lpszTitle,
GroupAttributes.nSize);
GetDlgItemText(hDlg, PM_FILE, GroupAttributes.lpszGrpFile,
GroupAttributes.nSize);
EndDialog(hDlg, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_ProgramAttributes
*/
static struct
{
LPSTR lpszTitle, lpszCmdLine, lpszWorkDir, lpszIconFile, lpszTmpIconFile;
INT nSize;
INT *lpnCmdShow;
INT *lpnHotKey;
HWND hSelGroupWnd;
HICON *lphIcon, hTmpIcon;
INT *lpnIconIndex, nTmpIconIndex;
} ProgramAttributes;
BOOL DIALOG_ProgramAttributes(LPSTR lpszTitle, LPSTR lpszCmdLine,
LPSTR lpszWorkDir, LPSTR lpszIconFile,
HICON *lphIcon, INT *lpnIconIndex,
INT *lpnHotKey, INT *lpnCmdShow, INT nSize)
{
CHAR szTmpIconFile[MAX_PATHNAME_LEN];
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_PROGRAM_DlgProc, Globals.hInstance);
INT ret;
ProgramAttributes.nSize = nSize;
ProgramAttributes.lpszTitle = lpszTitle;
ProgramAttributes.lpszCmdLine = lpszCmdLine;
ProgramAttributes.lpszWorkDir = lpszWorkDir;
ProgramAttributes.lpszIconFile = lpszIconFile;
ProgramAttributes.lpnCmdShow = lpnCmdShow;
ProgramAttributes.lpnHotKey = lpnHotKey;
ProgramAttributes.lphIcon = lphIcon;
ProgramAttributes.lpnIconIndex = lpnIconIndex;
#if 0
ProgramAttributes.hTmpIcon = 0;
#else
ProgramAttributes.hTmpIcon = *lphIcon;
#endif
ProgramAttributes.nTmpIconIndex = *lpnIconIndex;
ProgramAttributes.lpszTmpIconFile = szTmpIconFile;
lstrcpyn(ProgramAttributes.lpszTmpIconFile, lpszIconFile, MAX_PATHNAME_LEN);
ret = DialogBox(Globals.hInstance, STRING_PROGRAM_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
return(ret == IDOK);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_PROGRAM_DlgProc
*/
static LRESULT DIALOG_PROGRAM_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
CHAR buffer[MAX_STRING_LEN];
switch (msg)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, PM_DESCRIPTION, ProgramAttributes.lpszTitle);
SetDlgItemText(hDlg, PM_COMMAND_LINE, ProgramAttributes.lpszCmdLine);
SetDlgItemText(hDlg, PM_DIRECTORY, ProgramAttributes.lpszWorkDir);
if (!*ProgramAttributes.lpnHotKey)
{
LoadString(Globals.hInstance, IDS_NO_HOT_KEY, buffer, sizeof(buffer));
SetDlgItemText(hDlg, PM_HOT_KEY, buffer);
}
CheckDlgButton(hDlg, PM_SYMBOL,
(*ProgramAttributes.lpnCmdShow == SW_SHOWMINIMIZED));
SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
(WPARAM) ProgramAttributes.hTmpIcon, 0);
break;
case WM_COMMAND:
switch (wParam)
{
case PM_SYMBOL:
CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
return TRUE;
case PM_BROWSE:
{
CHAR filename[MAX_PATHNAME_LEN];
if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
SetDlgItemText(hDlg, PM_COMMAND_LINE, filename);
return TRUE;
}
case PM_OTHER_SYMBOL:
{
DIALOG_Symbol(&ProgramAttributes.hTmpIcon,
ProgramAttributes.lpszTmpIconFile,
&ProgramAttributes.nTmpIconIndex,
MAX_PATHNAME_LEN);
SendDlgItemMessage(hDlg, PM_ICON, STM_SETICON,
(WPARAM) ProgramAttributes.hTmpIcon, 0);
return TRUE;
}
case IDOK:
GetDlgItemText(hDlg, PM_DESCRIPTION,
ProgramAttributes.lpszTitle,
ProgramAttributes.nSize);
GetDlgItemText(hDlg, PM_COMMAND_LINE,
ProgramAttributes.lpszCmdLine,
ProgramAttributes.nSize);
GetDlgItemText(hDlg, PM_DIRECTORY,
ProgramAttributes.lpszWorkDir,
ProgramAttributes.nSize);
if (ProgramAttributes.hTmpIcon)
{
#if 0
if (*ProgramAttributes.lphIcon)
DestroyIcon(*ProgramAttributes.lphIcon);
#endif
*ProgramAttributes.lphIcon = ProgramAttributes.hTmpIcon;
*ProgramAttributes.lpnIconIndex = ProgramAttributes.nTmpIconIndex;
lstrcpyn(ProgramAttributes.lpszIconFile,
ProgramAttributes.lpszTmpIconFile,
ProgramAttributes.nSize);
}
*ProgramAttributes.lpnCmdShow =
IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
SW_SHOWMINIMIZED : SW_SHOWNORMAL;
EndDialog(hDlg, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
return FALSE;
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_Symbol
*/
static struct
{
LPSTR lpszIconFile;
INT nSize;
HICON *lphIcon;
INT *lpnIconIndex;
} Symbol;
VOID DIALOG_Symbol(HICON *lphIcon, LPSTR lpszIconFile,
INT *lpnIconIndex, INT nSize)
{
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_SYMBOL_DlgProc, Globals.hInstance);
Symbol.nSize = nSize;
Symbol.lpszIconFile = lpszIconFile;
Symbol.lphIcon = lphIcon;
Symbol.lpnIconIndex = lpnIconIndex;
DialogBox(Globals.hInstance, STRING_SYMBOL_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_SYMBOL_DlgProc
*/
static LRESULT DIALOG_SYMBOL_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile);
SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETITEMHEIGHT, 0, (LPARAM) 32);
SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)*Symbol.lphIcon);
SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_ADDSTRING, 0, (LPARAM)Globals.hDefaultIcon);
SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_SETCURSEL, 0, 0);
return TRUE;
case WM_MEASUREITEM:
{
PMEASUREITEMSTRUCT measure = (PMEASUREITEMSTRUCT) lParam;
measure->itemWidth = 32;
measure->itemHeight = 32;
return TRUE;
}
case WM_DRAWITEM:
{
PDRAWITEMSTRUCT dis = (PDRAWITEMSTRUCT) lParam;
DrawIcon(dis->hDC, dis->rcItem.left, dis->rcItem.top, (HICON)dis->itemData);
return TRUE;
}
case WM_COMMAND:
switch (wParam)
{
case PM_BROWSE:
{
CHAR filename[MAX_PATHNAME_LEN];
if (DIALOG_BrowseSymbols(hDlg, filename, sizeof(filename)))
SetDlgItemText(hDlg, PM_ICON_FILE, filename);
return TRUE;
}
case PM_HELP:
MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
return TRUE;
case IDOK:
{
INT nCurSel = SendDlgItemMessage(hDlg, PM_SYMBOL_LIST, CB_GETCURSEL, 0, 0);
GetDlgItemText(hDlg, PM_ICON_FILE, Symbol.lpszIconFile, Symbol.nSize);
*Symbol.lphIcon = (HICON)SendDlgItemMessage(hDlg, PM_SYMBOL_LIST,
CB_GETITEMDATA,
(WPARAM) nCurSel, 0);
#if 0
*Symbol.lphIcon = CopyIcon(*Symbol.lphIcon);
#endif
EndDialog(hDlg, IDOK);
return TRUE;
}
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_Execute
*/
VOID DIALOG_Execute()
{
WNDPROC lpfnDlg = MakeProcInstance(DIALOG_EXECUTE_DlgProc, Globals.hInstance);
DialogBox(Globals.hInstance, STRING_EXECUTE_Xx,
Globals.hMainWnd, lpfnDlg);
FreeProcInstance(lpfnDlg);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* DIALOG_EXECUTE_DlgProc
*/
static LRESULT DIALOG_EXECUTE_DlgProc(HWND hDlg, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
switch (wParam)
{
case PM_SYMBOL:
CheckDlgButton(hDlg, PM_SYMBOL, !IsDlgButtonChecked(hDlg, PM_SYMBOL));
return TRUE;
case PM_BROWSE:
{
CHAR filename[MAX_PATHNAME_LEN];
if (DIALOG_BrowsePrograms(hDlg, filename, sizeof(filename)))
SetDlgItemText(hDlg, PM_COMMAND, filename);
return TRUE;
}
case PM_HELP:
MAIN_MessageBoxIDS(IDS_NOT_IMPLEMENTED, IDS_ERROR, MB_OK);
return TRUE;
case IDOK:
{
CHAR cmdline[MAX_PATHNAME_LEN];
GetDlgItemText(hDlg, PM_COMMAND, cmdline, sizeof(cmdline));
WinExec(cmdline, IsDlgButtonChecked(hDlg, PM_SYMBOL) ?
SW_SHOWMINIMIZED : SW_SHOWNORMAL);
if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
EndDialog(hDlg, IDOK);
return TRUE;
}
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
/***********************************************************************
*
* DIALOG_Browse
*/
static BOOL DIALOG_Browse(HWND hDlg, LPCSTR lpszzFilter,
LPSTR lpstrFile, INT nMaxFile)
{
OPENFILENAME openfilename;
/* FIXME is this correct ? */
openfilename.lStructSize = 0;
openfilename.hwndOwner = hDlg;
openfilename.hInstance = Globals.hInstance;
openfilename.lpstrFilter = (LPSTR)lpszzFilter;
openfilename.lpstrCustomFilter = 0;
openfilename.nMaxCustFilter = 0;
openfilename.nFilterIndex = 0;
openfilename.lpstrFile = lpstrFile;
openfilename.nMaxFile = sizeof(lpstrFile);
openfilename.lpstrFileTitle = 0;
openfilename.nMaxFileTitle = 0;
openfilename.lpstrInitialDir = 0;
openfilename.lpstrTitle = 0;
openfilename.Flags = 0;
openfilename.nFileOffset = 0;
openfilename.nFileExtension = 0;
openfilename.lpstrDefExt = 0;
openfilename.lCustData = 0;
openfilename.lpfnHook = 0;
openfilename.lpTemplateName = 0;
return GetOpenFileName(&openfilename);
}
/***********************************************************************
*
* DIALOG_AddFilterItem
*/
static VOID DIALOG_AddFilterItem(LPSTR *p, UINT ids, LPCSTR filter)
{
LoadString(Globals.hInstance, ids, *p, MAX_STRING_LEN);
*p += strlen(*p) + 1;
lstrcpy(*p, filter);
*p += strlen(*p) + 1;
**p = '\0';
}
/***********************************************************************
*
* DIALOG_BrowsePrograms
*/
static BOOL DIALOG_BrowsePrograms(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
{
CHAR szzFilter[2 * MAX_STRING_LEN + 100];
LPSTR p = szzFilter;
DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe;*.pif;*.com;*.bat");
DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
}
/***********************************************************************
*
* DIALOG_BrowseSymbols
*/
static BOOL DIALOG_BrowseSymbols(HWND hDlg, LPSTR lpszFile, INT nMaxFile)
{
CHAR szzFilter[5 * MAX_STRING_LEN + 100];
LPSTR p = szzFilter;
DIALOG_AddFilterItem(&p, IDS_SYMBOL_FILES, "*.ico;*.exe;*.dll");
DIALOG_AddFilterItem(&p, IDS_PROGRAMS, "*.exe");
DIALOG_AddFilterItem(&p, IDS_LIBRARIES_DLL, "*.dll");
DIALOG_AddFilterItem(&p, IDS_SYMBOLS_ICO, "*.ico");
DIALOG_AddFilterItem(&p, IDS_ALL_FILES, "*.*");
return(DIALOG_Browse(hDlg, szzFilter, lpszFile, nMaxFile));
}
/* Local Variables: */
/* c-file-style: "GNU" */
/* End: */