1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00
wine/windows/msgbox.c
Alexandre Julliard ff8331ea68 Release 950918
Sun Sep 17 16:47:49 1995  Alexandre Julliard  <julliard@sunsite.unc.edu>

	* [configure.in] [*/Makefile.in] [Make.rules.in]
	Cleaned up makefiles, added configuration option for Winelib,
	grouped common make rules in Make.rules.in.

	* [Configure]
	Renamed to 'Configure.old'; please use 'configure' instead.

	* [controls/menu.c]
	Fixed DestroyMenu() to avoid deleting the same menu twice.
	More fixes to WM_MENUSELECT, and added WM_INITMENU.

	* [if1632/relay.c]
	Fixed wrong register values displayed by RELAY_DebugCall32().

	* [memory/local.c]
	Fixed LocalLock() and LocalUnlock() to increment/decrement the
	lock count for moveable blocks.

	* [misc/commdlg.c] [misc/shell.c] [rc/winerc.c]
	Modified the generated C file so that the resource information
	(size, etc.) is also exported.
	Modified common dialogs to use the new informations.

	* [misc/main.c] [ANNOUNCE]
	Update the list of contributors. Please let me know if I forgot
	someone.

	* [rc/sysres.rc] [rc/sysres_En.rc]
	Moved English resources to sysres_En.rc.
	Changed ids from numeric to symbolic for dialogs.

	* [windows/dialog.c]
	Modified template parsing to be able to pass segmented pointers to
	CreateWindow().

	* [windows/win.c]
	CreateWindow() now takes segmented pointers for class and window
	names.
	Maxmimize or minimize the window upon creation if the WS_MAXIMIZE
	or WS_MINIMIZE bits are set.

Thu Sep 14 17:19:57 1995  Paul Wilhelm  <paul@paul.accessone.com>

	* [controls/scroll.c]
	Fixed scroll-bar bugs for non-client windows.

Thu Sep 14 14:04:14 MET DST 1995 Jochen Hoenicke <Jochen.Hoenicke@arbi.Informatik.Uni-Oldenburg.de>

	* [include/cursor.h] [windows/cursor.c]
	Cursor is not mirrored any more and the hotspot is set right.

Wed Sep 13 14:22:31 1995  Marcus Meissner  <msmeissn@faui01.informatik.uni-erlangen.de>

	* [ole.h]
	Misc small fixes.

Mon Sep  4 00:01:23 1995  Jon Tombs <jon@gte.esi.us.es>

	* [rc/sysres_Es.rc]
	First attempt at Spanish [Es] language support.

Sun Sep  3 13:22:33 1995     Martin von Loewis <loewis@informatik.hu-berlin.de>

	* [include/alias.h][windows/alias.c][include/relay32.h]
	New files

	* [controls/widgets.c]
	WIDGETS_Init: register alias window procedures

	* [if1632/callback.c]
	CallWndProc: Call alias functions if necessary

	* [if1632/gdi32.spec]
	GetStockObject, TextOutA: new relays

	* [misc/user32.c][if1632/user32.spec][misc/Makefile.in][misc/Imakefile]
	user32.c: new file
	BeginPaint,CreateWindowExA,DefWindowProcA,DispatchMessage,EndPaint,
	GetMessageA,RegisterClassA,ShowWindow,UpdateWindow: new relays

	* [if1632/winprocs32.spec][loader/pe_image.c][loader/module.c]
	PE_Win32CallToStart: new function
	MODULE_CreateInstance: removed static attribute
	LoadModule: Try loading PE image on error 21
	PE_LoadModule: new function
	PE_LoadImage: initialize pe_data with 0
	
	* [include/dlls.h][include/peexe.h]
	moved pe_data and w_files to peexe.h
	
	* [misc/shell.c]
	ShellAbout: Register AboutWndProc aliases

	* [miscemu/int21.c]
	handle 0x440A and 0xDC

	* [miscemu/int2f.c]
	handle 0x84

	* [objects/dib.c]
	CreateDIBitmap: complain if BITMAPINFOHEADER is of wrong size

	* [tools/build.c]
	include windows.h and relay32.h into generated Win32 relays,
	don't declare the implementation as int (*)();
	limit in WIN32_builtin was off by one

	* [windows/caret.c]
	CARET_Initialize: new function, call on strategic places

	* [windows/messagebox.c]
	MessageBox: register message box proc aliases

	* [if1632/advapi32.spec][if1632/comdlg32.spec]
	New files

	* [if1632/Makefile.in][if1632/Imakefile][if1632/relay32.c]
	added new spec files
	RELAY32_GetBuiltinDLL: perform lookup case insensitive
	RELAY32_GetEntryPoint: start name search at 0

	* [if1632/user.spec][if1632/kernel.spec][if1632/gdi.spec]
	Added stubs for new Win95 API

Sat Sep 2 1995  Martin Roy

	* [misc/commdlg.c]
	In WM_INITDIALOG, current filter must reflect lpofn->nFilterIndex.
  	When process IDOK button in FILEDLG_WMCommand(),
 	lpofn->nFilterIndex should be updated to current selection.

Thu Aug 31 15:00:00 1995 Ram'on Garc'ia <ramon@ie3.clubs.etsit.upm.es>

	* [loader/module.c] [loader/ne_image.c]
	Added support of self-loading modules.
1995-09-18 11:19:54 +00:00

219 lines
6.4 KiB
C

/*
* Message boxes
*
* Copyright 1995 Bernd Schmidt
*
*/
#include "windows.h"
#include "dlgs.h"
#include "global.h"
#include "selectors.h"
#include "alias.h"
#include "relay32.h"
#include "../rc/sysres.h"
#include "task.h"
typedef struct {
LPSTR title;
LPSTR text;
WORD type;
} MSGBOX, *LPMSGBOX;
LONG SystemMessageBoxProc(HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
LPMSGBOX lpmb;
RECT rect, textrect;
HWND hItem;
HDC hdc;
LONG lRet;
int i, buttons, bwidth, bheight, theight, wwidth, bpos;
int borheight, iheight, tiheight;
switch(message) {
case WM_INITDIALOG:
lpmb = (LPMSGBOX)lParam;
if (lpmb->title != NULL) {
SetWindowText(hwnd, lpmb->title);
}
SetWindowText(GetDlgItem(hwnd, 100), lpmb->text);
/* Hide not selected buttons */
switch(lpmb->type & MB_TYPEMASK) {
case MB_OK:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_OKCANCEL:
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_ABORTRETRYIGNORE:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 6), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 7), SW_HIDE);
break;
case MB_YESNO:
ShowWindow(GetDlgItem(hwnd, 2), SW_HIDE);
/* fall through */
case MB_YESNOCANCEL:
ShowWindow(GetDlgItem(hwnd, 1), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 3), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 4), SW_HIDE);
ShowWindow(GetDlgItem(hwnd, 5), SW_HIDE);
break;
}
/* Set the icon */
switch(lpmb->type & MB_ICONMASK) {
case MB_ICONEXCLAMATION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON, LoadIcon(0, IDI_EXCLAMATION), 0);
break;
case MB_ICONQUESTION:
SendDlgItemMessage(hwnd, stc1, STM_SETICON, LoadIcon(0, IDI_QUESTION), 0);
break;
case MB_ICONASTERISK:
SendDlgItemMessage(hwnd, stc1, STM_SETICON, LoadIcon(0, IDI_ASTERISK), 0);
break;
case MB_ICONHAND:
default:
SendDlgItemMessage(hwnd, stc1, STM_SETICON, LoadIcon(0, IDI_HAND), 0);
break;
}
/* Position everything */
GetWindowRect(hwnd, &rect);
borheight = rect.bottom - rect.top;
wwidth = rect.right - rect.left;
GetClientRect(hwnd, &rect);
borheight -= rect.bottom - rect.top;
/* Get the icon height */
GetWindowRect(GetDlgItem(hwnd, 1088), &rect);
iheight = rect.bottom - rect.top;
/* Get the number of visible buttons and their width */
GetWindowRect(GetDlgItem(hwnd, 2), &rect);
bheight = rect.bottom - rect.top;
bwidth = rect.left;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
bwidth -= rect.left;
for (buttons = 0, i = 1; i < 8; i++) {
hItem = GetDlgItem(hwnd, i);
if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE) {
buttons++;
}
}
/* Get the text size */
hItem = GetDlgItem(hwnd, 100);
GetWindowRect(hItem, &textrect);
MapWindowPoints(0, hwnd, (LPPOINT)&textrect, 2);
GetClientRect(hItem, &rect);
hdc = GetDC(hItem);
lRet = DrawText(hdc, lpmb->text, -1, &rect,
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
theight = rect.bottom - rect.top;
tiheight = 16 + max(iheight, theight);
ReleaseDC(hItem, hdc);
/* Position the text */
SetWindowPos(hItem, 0, textrect.left, (tiheight - theight) / 2,
rect.right - rect.left, theight,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Position the icon */
hItem = GetDlgItem(hwnd, 1088);
GetWindowRect(hItem, &rect);
MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Resize the window */
SetWindowPos(hwnd, 0, 0, 0, wwidth, 8 + tiheight + bheight + borheight,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
/* Position the buttons */
bpos = (wwidth - bwidth * buttons) / 2;
GetWindowRect(GetDlgItem(hwnd, 1), &rect);
for (buttons = i = 0; i < 7; i++) {
/* some arithmetic to get the right order for YesNoCancel windows */
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
if (GetWindowLong(hItem, GWL_STYLE) & WS_VISIBLE) {
if (buttons++ == ((lpmb->type & MB_DEFMASK) >> 8)) {
SetFocus(hItem);
SendMessage(hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
}
SetWindowPos(hItem, 0, bpos, tiheight, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
bpos += bwidth;
}
}
return 0;
break;
case WM_COMMAND:
switch (wParam) {
case IDOK:
case IDCANCEL:
case IDABORT:
case IDRETRY:
case IDIGNORE:
case IDYES:
case IDNO:
EndDialog(hwnd, wParam);
break;
}
break;
}
return 0;
}
/**************************************************************************
* MessageBox [USER.1]
*/
int MessageBox(HWND hWnd, LPSTR text, LPSTR title, WORD type)
{
HANDLE handle;
MSGBOX mbox;
int ret;
DWORD WineProc,Win16Proc,Win32Proc;
static int initialized = 0;
mbox.title = title;
mbox.text = text;
mbox.type = type;
if (!initialized)
{
WineProc=(DWORD)SystemMessageBoxProc;
Win16Proc=(DWORD)GetWndProcEntry16("SystemMessageBoxProc");
Win32Proc=(DWORD)RELAY32_GetEntryPoint("WINPROCS32","SystemMessageBoxProc",0);
ALIAS_RegisterAlias(WineProc,Win16Proc,Win32Proc);
initialized=1;
}
handle = GLOBAL_CreateBlock( GMEM_FIXED, sysres_DIALOG_MSGBOX.bytes,
sysres_DIALOG_MSGBOX.size, GetCurrentPDB(),
FALSE, FALSE, TRUE, NULL );
if (!handle) return 0;
ret = DialogBoxIndirectParam( GetWindowWord(hWnd, GWW_HINSTANCE),
handle, hWnd,
GetWndProcEntry16("SystemMessageBoxProc"),
(LONG)&mbox );
GLOBAL_FreeBlock( handle );
return ret;
}
/**************************************************************************
* FatalAppExit [USER.137]
*/
void FatalAppExit(WORD wAction, LPSTR str)
{
MessageBox(0, str, NULL, MB_SYSTEMMODAL | MB_OK);
TASK_KillCurrentTask(0);
}