mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:23:14 +00:00
some fixes on MessageBox code
svn path=/trunk/; revision=5942
This commit is contained in:
parent
449c82d834
commit
653c134ed1
3 changed files with 93 additions and 153 deletions
|
@ -85,24 +85,14 @@ DF_HATCH BITMAP "resources/df_hatch.bmp"
|
||||||
// Dialogs
|
// Dialogs
|
||||||
//
|
//
|
||||||
|
|
||||||
MSGBOX DIALOG DISCARDABLE 100, 80, 495, 77
|
MSGBOX DIALOG DISCARDABLE 100, 80, 180, 77
|
||||||
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||||
WS_SYSMENU
|
WS_SYSMENU
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
CAPTION "Error"
|
CAPTION "Error"
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON "", 1088, 9, 20, 16, 16, WS_CHILD | WS_VISIBLE
|
ICON "", 1088, 9, 20, 16, 16, WS_CHILD | WS_VISIBLE
|
||||||
LTEXT "", 100, 48, 16, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP
|
LTEXT "", 100, 48, 16, 124, 48, WS_CHILD | WS_VISIBLE
|
||||||
PUSHBUTTON "&OK", 1, 16, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Cancel", 2, 64, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Abort", 3, 112, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Retry", 4, 160, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Ignore", 5, 208, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Yes", 6, 256, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&No", 7, 304, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Help", 9, 351, 55, 40, 14, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "&Try Again", 10, 398, 54, 40, 14, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
PUSHBUTTON "Co&ntinue", 11, 445, 55, 40, 14, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP
|
|
||||||
END
|
END
|
||||||
|
|
||||||
SELWINDOW DIALOG DISCARDABLE 20, 20, 220, 140
|
SELWINDOW DIALOG DISCARDABLE 20, 20, 220, 140
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: dialog.c,v 1.16 2003/08/15 15:55:02 weiden Exp $
|
/* $Id: dialog.c,v 1.17 2003/08/30 18:38:08 weiden Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
* FILE: lib/user32/windows/dialog.c
|
* FILE: lib/user32/windows/dialog.c
|
||||||
|
@ -47,9 +47,9 @@
|
||||||
#define DF_END 0x0001
|
#define DF_END 0x0001
|
||||||
#define DF_OWNERENABLED 0x0002
|
#define DF_OWNERENABLED 0x0002
|
||||||
#define CW_USEDEFAULT16 ((short)0x8000)
|
#define CW_USEDEFAULT16 ((short)0x8000)
|
||||||
|
#define DWL_INIT (12)
|
||||||
#define GETDLGINFO(hwnd) ((DIALOGINFO*)GetPropA(hwnd, "ROS_DIALOG_INFO"))
|
#define GETDLGINFO(hwnd) (DIALOGINFO*)GetWindowLongW((hwnd), DWL_INIT)
|
||||||
#define SETDLGINFO(hwnd, info) (SetPropA(hwnd, "ROS_DIALOG_INFO", info))
|
#define SETDLGINFO(hwnd, info) SetWindowLongW((hwnd), DWL_INIT, (LONG)(info))
|
||||||
#define GET_WORD(ptr) (*(WORD *)(ptr))
|
#define GET_WORD(ptr) (*(WORD *)(ptr))
|
||||||
#define GET_DWORD(ptr) (*(DWORD *)(ptr))
|
#define GET_DWORD(ptr) (*(DWORD *)(ptr))
|
||||||
#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
|
#define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
|
||||||
|
@ -124,7 +124,7 @@ const struct builtin_class_descr DIALOG_builtin_class =
|
||||||
DIALOG_CLASS_ATOMW, /* name */
|
DIALOG_CLASS_ATOMW, /* name */
|
||||||
CS_GLOBALCLASS | CS_SAVEBITS | CS_DBLCLKS, /* style */
|
CS_GLOBALCLASS | CS_SAVEBITS | CS_DBLCLKS, /* style */
|
||||||
(WNDPROC) DefDlgProcW, /* procW */
|
(WNDPROC) DefDlgProcW, /* procW */
|
||||||
sizeof(DIALOGINFO *), /* extra */
|
DWL_INIT + sizeof(LONG), /* extra */
|
||||||
(LPCWSTR) IDC_ARROW, /* cursor */
|
(LPCWSTR) IDC_ARROW, /* cursor */
|
||||||
0 /* brush */
|
0 /* brush */
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: messagebox.c,v 1.16 2003/08/29 09:29:11 gvg Exp $
|
/* $Id: messagebox.c,v 1.17 2003/08/30 18:38:08 weiden Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
* FILE: lib/user32/windows/messagebox.c
|
* FILE: lib/user32/windows/messagebox.c
|
||||||
|
@ -70,15 +70,27 @@ typedef UINT *LPUINT;
|
||||||
#define MB_DEFMASK 0x00000F00
|
#define MB_DEFMASK 0x00000F00
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DWL_INIT (12)
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
static HWND MSGBOX_CreateButton(HWND hwnd, LONG ID, LPWSTR Caption)
|
||||||
|
{
|
||||||
|
HWND btn = CreateWindowExW(0, L"BUTTON", Caption, WS_CHILD | WS_TABSTOP | WS_VISIBLE,
|
||||||
|
0, 0, 10, 10, hwnd, 0, 0, NULL);
|
||||||
|
if(btn)
|
||||||
|
{
|
||||||
|
SetWindowLongW(btn, GWL_ID, ID);
|
||||||
|
}
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
|
||||||
static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
{
|
{
|
||||||
HFONT hFont = 0, hPrevFont = 0;
|
HFONT hFont = 0, hPrevFont = 0;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
HWND hItem;
|
HWND hItem;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
DWORD buttons;
|
|
||||||
int i;
|
int i;
|
||||||
int bspace, bw, bh, theight, tleft, wwidth, wheight, bpos;
|
int bspace, bw, bh, theight, tleft, wwidth, wheight, bpos;
|
||||||
int borheight, borwidth, iheight, ileft, iwidth, twidth, tiheight;
|
int borheight, borwidth, iheight, ileft, iwidth, twidth, tiheight;
|
||||||
|
@ -86,6 +98,8 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
LPCWSTR lpszText;
|
LPCWSTR lpszText;
|
||||||
WCHAR buf[256];
|
WCHAR buf[256];
|
||||||
NONCLIENTMETRICSW nclm;
|
NONCLIENTMETRICSW nclm;
|
||||||
|
int nButtons = 0;
|
||||||
|
HWND Buttons[4];
|
||||||
|
|
||||||
nclm.cbSize = sizeof(nclm);
|
nclm.cbSize = sizeof(nclm);
|
||||||
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0);
|
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0);
|
||||||
|
@ -124,63 +138,53 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
if (!LoadStringW(lpmb->hInstance, LOWORD((UINT)lpmb->lpszText), buf, 256)) /* FIXME: (UINT) ??? */
|
if (!LoadStringW(lpmb->hInstance, LOWORD((UINT)lpmb->lpszText), buf, 256)) /* FIXME: (UINT) ??? */
|
||||||
*buf = 0; /* FIXME ?? */
|
*buf = 0; /* FIXME ?? */
|
||||||
}
|
}
|
||||||
SetWindowTextW(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText);
|
|
||||||
|
|
||||||
/* Hide not selected buttons */
|
/* Create selected buttons */
|
||||||
switch(lpmb->dwStyle & MB_TYPEMASK)
|
switch(lpmb->dwStyle & MB_TYPEMASK)
|
||||||
{
|
{
|
||||||
case MB_OK:
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
|
|
||||||
/* fall through */
|
|
||||||
case MB_OKCANCEL:
|
case MB_OKCANCEL:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDOK, L"OK");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDCANCEL, L"Cancel");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
|
nButtons = 2;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDTRYAGAIN), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCONTINUE), SW_HIDE);
|
|
||||||
break;
|
break;
|
||||||
case MB_CANCELTRYCONTINUE:
|
case MB_CANCELTRYCONTINUE:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDCANCEL, L"Cancel");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDTRYAGAIN, L"Try Again");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
|
Buttons[2] = MSGBOX_CreateButton(hwnd, IDCONTINUE, L"Continue");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
|
nButtons = 3;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
|
|
||||||
break;
|
break;
|
||||||
case MB_ABORTRETRYIGNORE:
|
case MB_ABORTRETRYIGNORE:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDABORT, L"Abort");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDRETRY, L"Retry");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
|
Buttons[2] = MSGBOX_CreateButton(hwnd, IDIGNORE, L"Ignore");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
|
nButtons = 3;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDTRYAGAIN), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCONTINUE), SW_HIDE);
|
|
||||||
break;
|
break;
|
||||||
case MB_YESNO:
|
case MB_YESNO:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCANCEL), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDYES, L"Yes");
|
||||||
/* fall through */
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDNO, L"No");
|
||||||
|
nButtons = 2;
|
||||||
|
break;
|
||||||
case MB_YESNOCANCEL:
|
case MB_YESNOCANCEL:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDYES, L"Yes");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDNO, L"No");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDRETRY), SW_HIDE);
|
Buttons[2] = MSGBOX_CreateButton(hwnd, IDCANCEL, L"Cancel");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
|
nButtons = 3;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDTRYAGAIN), SW_HIDE);
|
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCONTINUE), SW_HIDE);
|
|
||||||
break;
|
break;
|
||||||
case MB_RETRYCANCEL:
|
case MB_RETRYCANCEL:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDOK), SW_HIDE);
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDRETRY, L"Retry");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDABORT), SW_HIDE);
|
Buttons[1] = MSGBOX_CreateButton(hwnd, IDCANCEL, L"Cancel");
|
||||||
ShowWindow(GetDlgItem(hwnd, IDIGNORE), SW_HIDE);
|
nButtons = 2;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDYES), SW_HIDE);
|
break;
|
||||||
ShowWindow(GetDlgItem(hwnd, IDNO), SW_HIDE);
|
case MB_OK:
|
||||||
ShowWindow(GetDlgItem(hwnd, IDTRYAGAIN), SW_HIDE);
|
/* fall through */
|
||||||
ShowWindow(GetDlgItem(hwnd, IDCONTINUE), SW_HIDE);
|
default:
|
||||||
|
Buttons[0] = MSGBOX_CreateButton(hwnd, IDOK, L"OK");
|
||||||
|
nButtons = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Hide Help button */
|
/* Create Help button */
|
||||||
if(!(lpmb->dwStyle & MB_HELP))
|
if(lpmb->dwStyle & MB_HELP)
|
||||||
ShowWindow(GetDlgItem(hwnd, IDHELP), SW_HIDE);
|
Buttons[nButtons++] = MSGBOX_CreateButton(hwnd, IDHELP, L"Help");
|
||||||
|
|
||||||
/* Set the icon */
|
/* Set the icon */
|
||||||
switch(lpmb->dwStyle & MB_ICONMASK)
|
switch(lpmb->dwStyle & MB_ICONMASK)
|
||||||
|
@ -223,12 +227,11 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
borheight = rect.bottom - rect.top;
|
borheight = rect.bottom - rect.top;
|
||||||
borwidth = rect.right - rect.left;
|
borwidth = rect.right - rect.left;
|
||||||
GetClientRect(hwnd, &rect);
|
GetClientRect(hwnd, &rect);
|
||||||
borheight -= rect.bottom - rect.top;
|
borheight -= rect.bottom;
|
||||||
borwidth -= rect.right - rect.left;
|
borwidth -= rect.right;
|
||||||
|
|
||||||
/* Get the icon height */
|
/* Get the icon height */
|
||||||
GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect);
|
GetWindowRect(GetDlgItem(hwnd, MSGBOX_IDICON), &rect);
|
||||||
MapWindowPoints(0, hwnd, (LPPOINT)&rect, 2);
|
|
||||||
if (!(lpmb->dwStyle & MB_ICONMASK))
|
if (!(lpmb->dwStyle & MB_ICONMASK))
|
||||||
{
|
{
|
||||||
rect.bottom = rect.top;
|
rect.bottom = rect.top;
|
||||||
|
@ -242,19 +245,13 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
if (hFont)
|
if (hFont)
|
||||||
hPrevFont = SelectObject(hdc, hFont);
|
hPrevFont = SelectObject(hdc, hFont);
|
||||||
|
|
||||||
/* Get the number of visible buttons and their size */
|
/* Calculate the button's sizes */
|
||||||
bh = bw = 1; /* Minimum button sizes */
|
bh = bw = 1; // Minimum button sizes
|
||||||
for (buttons = 0, i = 1; i < 12; i++)
|
for(i = 0; i <= nButtons; i++)
|
||||||
{
|
|
||||||
if (i == 8)
|
|
||||||
continue; /* skip id=8 because it doesn't exist, (MB_CLOSE) ?*/
|
|
||||||
hItem = GetDlgItem(hwnd, i);
|
|
||||||
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
{
|
||||||
WCHAR buttonText[1024];
|
WCHAR buttonText[1024];
|
||||||
int w, h;
|
int w, h;
|
||||||
buttons++;
|
if (GetWindowTextW(Buttons[i], buttonText, 1024))
|
||||||
if (GetWindowTextW(hItem, buttonText, 1024))
|
|
||||||
{
|
{
|
||||||
DrawTextW(hdc, buttonText, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT);
|
DrawTextW(hdc, buttonText, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT);
|
||||||
h = rect.bottom - rect.top;
|
h = rect.bottom - rect.top;
|
||||||
|
@ -265,7 +262,7 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
bw = w ;
|
bw = w ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
bw = max(bw, bh * 2);
|
bw = max(bw, bh * 2);
|
||||||
/* Button white space */
|
/* Button white space */
|
||||||
bh = bh * 2 - 4;
|
bh = bh * 2 - 4;
|
||||||
|
@ -275,13 +272,15 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
/* Get the text size */
|
/* Get the text size */
|
||||||
GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect);
|
GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect);
|
||||||
rect.top = rect.left = rect.bottom = 0;
|
rect.top = rect.left = rect.bottom = 0;
|
||||||
|
rect.right = (((GetSystemMetrics(SM_CXSCREEN) - borwidth) * 4) / 5);
|
||||||
DrawTextW( hdc, lpszText, -1, &rect,
|
DrawTextW( hdc, lpszText, -1, &rect,
|
||||||
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
|
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
|
||||||
|
|
||||||
/* Min text width corresponds to space for the buttons */
|
/* Min text width corresponds to space for the buttons */
|
||||||
tleft = ileft;
|
tleft = ileft;
|
||||||
if (iwidth)
|
if (iwidth)
|
||||||
tleft += ileft + iwidth;
|
tleft += ileft + iwidth;
|
||||||
twidth = max((LONG) ((bw + bspace) * buttons + bspace - tleft), rect.right);
|
twidth = max((LONG) (((bw + bspace) * nButtons) + bspace - tleft), rect.right);
|
||||||
theight = rect.bottom;
|
theight = rect.bottom;
|
||||||
|
|
||||||
if (hFont)
|
if (hFont)
|
||||||
|
@ -303,78 +302,28 @@ static HFONT MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMS lpmb)
|
||||||
/* Position the text */
|
/* Position the text */
|
||||||
SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDTEXT), 0, tleft, (tiheight - theight) / 2, twidth, theight,
|
SetWindowPos(GetDlgItem(hwnd, MSGBOX_IDTEXT), 0, tleft, (tiheight - theight) / 2, twidth, theight,
|
||||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
|
||||||
|
SetWindowTextW(GetDlgItem(hwnd, MSGBOX_IDTEXT), lpszText);
|
||||||
|
|
||||||
/* Position the buttons */
|
/* Position the buttons */
|
||||||
bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2;
|
bpos = (wwidth - ((bw + bspace) * nButtons) + bspace) / 2;
|
||||||
for (buttons = i = 0; i < 7; i++)
|
for(i = 0; i <= nButtons; i++)
|
||||||
{
|
{
|
||||||
/* some arithmetic to get the right order for YesNoCancel windows */
|
if (i == ((lpmb->dwStyle & MB_DEFMASK) >> 8))
|
||||||
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
|
|
||||||
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
{
|
||||||
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8))
|
SetFocus(Buttons[i]);
|
||||||
{
|
SendMessageW(Buttons[i], BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
|
||||||
SetFocus(hItem);
|
|
||||||
SendMessageW( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
|
|
||||||
sdefbtn = TRUE;
|
sdefbtn = TRUE;
|
||||||
}
|
}
|
||||||
SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
|
SetWindowPos(Buttons[i], 0, bpos, tiheight, bw, bh,
|
||||||
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
|
||||||
bpos += bw + bspace;
|
bpos += bw + bspace;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(lpmb->dwStyle & MB_CANCELTRYCONTINUE)
|
|
||||||
{
|
|
||||||
for (i = 10; i < 12; i++)
|
|
||||||
{
|
|
||||||
hItem = GetDlgItem(hwnd, i);
|
|
||||||
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
|
||||||
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8))
|
|
||||||
{
|
|
||||||
SetFocus(hItem);
|
|
||||||
SendMessageW( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
|
|
||||||
sdefbtn = TRUE;
|
|
||||||
}
|
|
||||||
SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
|
|
||||||
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
|
|
||||||
bpos += bw + bspace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpmb->dwStyle & MB_HELP)
|
|
||||||
{
|
|
||||||
hItem = GetDlgItem(hwnd, IDHELP);
|
|
||||||
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
|
||||||
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8))
|
|
||||||
{
|
|
||||||
SetFocus(hItem);
|
|
||||||
SendMessageW( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
|
|
||||||
sdefbtn = TRUE;
|
|
||||||
}
|
|
||||||
SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
|
|
||||||
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
|
|
||||||
bpos += bw + bspace; /* one extra space */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if there's no (valid) default selection, select first button */
|
/* if there's no (valid) default selection, select first button */
|
||||||
if(!sdefbtn)
|
if(!sdefbtn)
|
||||||
{
|
{
|
||||||
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
|
SetFocus(Buttons[0]);
|
||||||
for (buttons = i = 0; i < 7; i++)
|
SendMessageW(Buttons[0], BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
|
||||||
{
|
|
||||||
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
|
|
||||||
if (GetWindowLongW(hItem, GWL_STYLE) & WS_VISIBLE)
|
|
||||||
{
|
|
||||||
SetFocus(hItem);
|
|
||||||
SendMessageW( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lpmb->dwStyle & MB_RIGHT)
|
if(lpmb->dwStyle & MB_RIGHT)
|
||||||
|
@ -419,14 +368,15 @@ static INT_PTR CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
|
||||||
switch(message) {
|
switch(message) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
if(!GetPropA(hwnd, "ROS_MSGBOX"))
|
if(GetWindowLongA(hwnd, DWL_INIT))
|
||||||
{
|
{
|
||||||
LPMSGBOXPARAMS mbp = (LPMSGBOXPARAMS)lParam;
|
LPMSGBOXPARAMS mbp = (LPMSGBOXPARAMS)lParam;
|
||||||
|
SetWindowLongA(hwnd, DWL_INIT, (LONG)mbp);
|
||||||
SetWindowContextHelpId(hwnd, mbp->dwContextHelpId);
|
SetWindowContextHelpId(hwnd, mbp->dwContextHelpId);
|
||||||
hFont = MSGBOX_OnInit(hwnd, mbp);
|
hFont = MSGBOX_OnInit(hwnd, mbp);
|
||||||
SetPropA(hwnd, "ROS_MSGBOX", (HANDLE)hwnd);
|
|
||||||
SetPropA(hwnd, "ROS_MSGBOX_HFONT", (HANDLE)hFont);
|
SetPropA(hwnd, "ROS_MSGBOX_HFONT", (HANDLE)hFont);
|
||||||
SetPropA(hwnd, "ROS_MSGBOX_HELPCALLBACK", (HANDLE)mbp->lpfnMsgBoxCallback);
|
SetPropA(hwnd, "ROS_MSGBOX_HELPCALLBACK", (HANDLE)mbp->lpfnMsgBoxCallback);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue