ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2018
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
32 participants
304 discussions
Start a n
N
ew thread
01/01: [NTOSKRNL] Properly initialize the IO_STATUS_BLOCK
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65f97838084a5b1541f80…
commit 65f97838084a5b1541f80c5ab4236495ae9b3ce0 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Fri Aug 17 19:12:30 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Fri Aug 17 19:13:13 2018 +0200 [NTOSKRNL] Properly initialize the IO_STATUS_BLOCK --- ntoskrnl/fsrtl/fastio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/fsrtl/fastio.c b/ntoskrnl/fsrtl/fastio.c index d3ea273a12..c9ff2f0375 100644 --- a/ntoskrnl/fsrtl/fastio.c +++ b/ntoskrnl/fsrtl/fastio.c @@ -310,11 +310,13 @@ FsRtlCopyWrite(IN PFILE_OBJECT FileObject, return FALSE; } + /* Already init IO_STATUS_BLOCK */ + IoStatus->Status = STATUS_SUCCESS; + IoStatus->Information = Length; + /* No actual read */ if (!Length) { - IoStatus->Status = STATUS_SUCCESS; - IoStatus->Information = Length; return TRUE; }
6 years, 7 months
1
0
0
0
01/01: [SHELL32] Translation de-DE CORE-14916
by Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=abf9340f1be1ceb1780af…
commit abf9340f1be1ceb1780af68c50a2c49a350fa23d Author: Joachim Henze <Joachim.Henze(a)reactos.org> AuthorDate: Fri Aug 17 18:07:35 2018 +0200 Commit: Joachim Henze <Joachim.Henze(a)reactos.org> CommitDate: Fri Aug 17 18:07:35 2018 +0200 [SHELL32] Translation de-DE CORE-14916 fix control overlapping in IDD_FOLDER_OPTIONS_FILETYPES (broke in 0.4.10-dev-24-ed1c6bb0060d06f4c0167d9c2d732f4dc2b4cce4) and translate IDD_NEWEXTENSION, IDD_EDITTYPE, IDD_ACTION, IDD_FOLDER_CUSTOMIZE --- dll/win32/shell32/lang/de-DE.rc | 102 ++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/dll/win32/shell32/lang/de-DE.rc b/dll/win32/shell32/lang/de-DE.rc index 35089f905f..efc3634c4d 100644 --- a/dll/win32/shell32/lang/de-DE.rc +++ b/dll/win32/shell32/lang/de-DE.rc @@ -457,8 +457,8 @@ BEGIN PUSHBUTTON "&Löschen", IDC_FILETYPES_DELETE, 200, 140, 55, 14, WS_TABSTOP GROUPBOX "Details zum Dateityp '%s'", IDC_FILETYPES_DETAILS_GROUPBOX, 7, 170, 249, 70 LTEXT "Öffnen mit:", -1, 12, 180, 40, 10 - CONTROL "", IDC_FILETYPES_ICON, "STATIC", SS_BITMAP | SS_REALSIZEIMAGE, 85, 140, 10, 10 - LTEXT "Name", IDC_FILETYPES_APPNAME, 100, 140, 80, 10 + CONTROL "", IDC_FILETYPES_ICON, "STATIC", SS_BITMAP | SS_REALSIZEIMAGE, 85, 180, 10, 10 + LTEXT "Name", IDC_FILETYPES_APPNAME, 100, 180, 80, 10 PUSHBUTTON "Än&dern...", IDC_FILETYPES_CHANGE, 200, 180, 50, 14, WS_TABSTOP LTEXT "", IDC_FILETYPES_DESCRIPTION, 12, 195, 160, 30 PUSHBUTTON "&Erweitert", IDC_FILETYPES_ADVANCED, 200, 215, 50, 14, WS_TABSTOP @@ -643,74 +643,74 @@ Sind Sie sicher, dass Sie diese Datei öffnen möchten?", IDC_STATIC, 35, 5, 230 END IDD_NEWEXTENSION DIALOGEX 0, 0, 260, 75 -CAPTION "Create New Extension" +CAPTION "Eine neue Erweiterung erstellen" STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg" BEGIN - LTEXT "&File Extension:", -1, 10, 10, 85, 14 + LTEXT "&Dateierweiterung:", -1, 10, 10, 85, 14 EDITTEXT IDC_NEWEXT_EDIT, 105, 8, 60, 14 - PUSHBUTTON "<< Ad&vanced", IDC_NEWEXT_ADVANCED, 185, 8, 65, 15 - LTEXT "&Associated File Type:", IDC_NEWEXT_ASSOC, 10, 34, 85, 14 + PUSHBUTTON "<< Er&weitert", IDC_NEWEXT_ADVANCED, 185, 8, 65, 15 + LTEXT "&Verknüpfung mir Dateityp:", IDC_NEWEXT_ASSOC, 10, 34, 85, 14 COMBOBOX IDC_NEWEXT_COMBOBOX, 105, 32, 145, 120, CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | WS_VSCROLL | WS_GROUP | WS_TABSTOP DEFPUSHBUTTON "OK", IDOK, 125, 55, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 190, 55, 60, 14 + PUSHBUTTON "Abbrechen", IDCANCEL, 190, 55, 60, 14 END IDD_EDITTYPE DIALOG 0, 0, 225, 190 -CAPTION "Edit File Type" +CAPTION "Dateityp bearbeiten" STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg" BEGIN ICON "", IDC_EDITTYPE_ICON, 5, 8, 20, 20 EDITTEXT IDC_EDITTYPE_TEXT, 30, 10, 115, 14, ES_AUTOHSCROLL - PUSHBUTTON "Change &Icon...", IDC_EDITTYPE_CHANGE_ICON, 150, 10, 70, 14 - LTEXT "&Actions:", -1, 5, 37, 70, 10 + PUSHBUTTON "Anderes &Symbol...", IDC_EDITTYPE_CHANGE_ICON, 150, 10, 70, 14 + LTEXT "A&ktionen:", -1, 5, 37, 70, 10 LISTBOX IDC_EDITTYPE_LISTBOX, 5, 50, 140, 60, LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&New...", IDC_EDITTYPE_NEW, 150, 50, 70, 14 - PUSHBUTTON "&Edit...", IDC_EDITTYPE_EDIT_BUTTON, 150, 65, 70, 14 - PUSHBUTTON "&Remove", IDC_EDITTYPE_REMOVE, 150, 80, 70, 14 - PUSHBUTTON "&Set Default", IDC_EDITTYPE_SET_DEFAULT, 150, 95, 70, 14 - AUTOCHECKBOX "Confirm &open after download", IDC_EDITTYPE_CONFIRM_OPEN, 5, 115, 150, 14 - AUTOCHECKBOX "Al&ways show extension", IDC_EDITTYPE_SHOW_EXT, 5, 130, 150, 14 - AUTOCHECKBOX "&Browse in same window", IDC_EDITTYPE_SAME_WINDOW, 5, 145, 150, 14 + PUSHBUTTON "&Neu...", IDC_EDITTYPE_NEW, 150, 50, 70, 14 + PUSHBUTTON "&Bearbeiten...", IDC_EDITTYPE_EDIT_BUTTON, 150, 65, 70, 14 + PUSHBUTTON "&Entfernen", IDC_EDITTYPE_REMOVE, 150, 80, 70, 14 + PUSHBUTTON "&Als Standard", IDC_EDITTYPE_SET_DEFAULT, 150, 95, 70, 14 + AUTOCHECKBOX "Ö&ffnen nach dem Download bestätigen", IDC_EDITTYPE_CONFIRM_OPEN, 5, 115, 150, 14 + AUTOCHECKBOX "E&rweiterung immer anzeigen", IDC_EDITTYPE_SHOW_EXT, 5, 130, 150, 14 + AUTOCHECKBOX "Im selben Fenster &durchsuchen", IDC_EDITTYPE_SAME_WINDOW, 5, 145, 150, 14 DEFPUSHBUTTON "OK", IDOK, 95, 170, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 160, 170, 60, 14 + PUSHBUTTON "Abbrechen", IDCANCEL, 160, 170, 60, 14 END IDD_ACTION DIALOG 0, 0, 225, 95 -CAPTION "New Action" +CAPTION "Neue Aktion" STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg" BEGIN - LTEXT "&Action:", -1, 5, 7, 150, 10 + LTEXT "&Vorgang:", -1, 5, 7, 150, 10 EDITTEXT IDC_ACTION_ACTION, 5, 20, 150, 14, ES_AUTOHSCROLL - LTEXT "App&lication used to perform action:", -1, 5, 42, 150, 10 + LTEXT "An&wendung für diesen Vorgang:", -1, 5, 42, 150, 10 EDITTEXT IDC_ACTION_APP, 5, 55, 150, 14, ES_AUTOHSCROLL - PUSHBUTTON "B&rowse...", IDC_ACTION_BROWSE, 160, 60, 60, 14 - AUTOCHECKBOX "&Use DDE", IDC_ACTION_USE_DDE, 10, 75, 103, 14 + PUSHBUTTON "D&urchsuchen...", IDC_ACTION_BROWSE, 160, 60, 60, 14 + AUTOCHECKBOX "&DDE verwenden", IDC_ACTION_USE_DDE, 10, 75, 103, 14 DEFPUSHBUTTON "OK", IDOK, 160, 20, 60, 14 - PUSHBUTTON "Cancel", IDCANCEL, 160, 40, 60, 14 + PUSHBUTTON "Abbrechen", IDCANCEL, 160, 40, 60, 14 END IDD_FOLDER_CUSTOMIZE DIALOGEX 0, 0, 240, 250 -CAPTION "Customize" +CAPTION "Anpassen" STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION FONT 8, "MS Shell Dlg" BEGIN - GROUPBOX "What kind of folder do you want?", IDC_STATIC, 5, 5, 230, 65, WS_TABSTOP - LTEXT "Use this &folder type as a template:", IDC_STATIC, 15, 20, 210, 12 + GROUPBOX "Anpassen", IDC_STATIC, 5, 5, 230, 65, WS_TABSTOP + LTEXT "Diesen Ordner optimieren für:", IDC_STATIC, 15, 20, 210, 12 COMBOBOX IDC_FOLDERCUST_COMBOBOX, 15, 35, 210, 300, CBS_HASSTRINGS | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - AUTOCHECKBOX "Also apply this template to all &subfolders", IDC_FOLDERCUST_CHECKBOX, 15, 50, 210, 15 - GROUPBOX "Folder pictures", IDC_STATIC, 5, 75, 230, 90, WS_TABSTOP - LTEXT "For Thumbnails view, you can put a picture on this folder to remind you of the contents.", IDC_STATIC, 15, 87, 115, 33 - PUSHBUTTON "Choose &Picture...", IDC_FOLDERCUST_CHOOSE_PIC, 15, 125, 115, 15 - PUSHBUTTON "&Restore Default", IDC_FOLDERCUST_RESTORE_DEFAULTS, 15, 144, 115, 15 + AUTOCHECKBOX "&Vorlage für alle Unterordner übernehmen", IDC_FOLDERCUST_CHECKBOX, 15, 50, 210, 15 + GROUPBOX "Ordnerbilder", IDC_STATIC, 5, 75, 230, 90, WS_TABSTOP + LTEXT "Wählen Sie eine Datei aus, die auf diesem Ordnersymbol angezeigt wird.", IDC_STATIC, 15, 87, 115, 33 + PUSHBUTTON "&Datei auswählen...", IDC_FOLDERCUST_CHOOSE_PIC, 15, 125, 115, 15 + PUSHBUTTON "&Wiederherstellen", IDC_FOLDERCUST_RESTORE_DEFAULTS, 15, 144, 115, 15 LTEXT "Preview:", IDC_STATIC, 139, 85, 81, 11 CONTROL "", IDC_FOLDERCUST_PREVIEW_BITMAP, "STATIC", SS_BITMAP | WS_GROUP, 150, 100, 60, 60 - GROUPBOX "Folder icons", IDC_STATIC, 5, 170, 230, 65, WS_TABSTOP - LTEXT "For all views except Thumbnails, you can change the standard ""folder"" icon to another icon.", IDC_STATIC, 15, 180, 210, 25 + GROUPBOX "Ordnersymbole", IDC_STATIC, 5, 170, 230, 65, WS_TABSTOP + LTEXT "Sie können das Ordnersymbol ändern. Wenn Sie das Symbol ändern, wird keine Vorschau der Ordnerinhalte mehr angezeigt.", IDC_STATIC, 15, 180, 210, 25 ICON 0, IDC_FOLDERCUST_ICON, 175, 209, 32, 30 - PUSHBUTTON "Change &Icon...", IDC_FOLDERCUST_CHANGE_ICON, 15, 210, 75, 15 + PUSHBUTTON "Anderes &Symbol...", IDC_FOLDERCUST_CHANGE_ICON, 15, 210, 75, 15 END STRINGTABLE @@ -951,20 +951,20 @@ BEGIN IDS_ADVANCED_SHOW_COMP_COLOR "Verschlüsselte oder komprimierte NTFS-Dateien farbig anzeigen" IDS_ADVANCED_SHOW_INFO_TIP "Popupinformationen für Ordner- und Desktop-Elemente anzeigen" - IDS_NEWEXT_ADVANCED_LEFT "<< Ad&vanced" - IDS_NEWEXT_ADVANCED_RIGHT "Ad&vanced >>" - IDS_NEWEXT_NEW "<New>" - IDS_NEWEXT_SPECIFY_EXT "You must specify an extension." - IDS_NEWEXT_ALREADY_ASSOC "Extension %s is already associated with File Type %s. Do you want to un-associate %s with %s and create a new File Type for it?" - IDS_NEWEXT_EXT_IN_USE "Extension is in use" - - IDS_REMOVE_EXT "If you remove a registered file name extension, you will not be able to open files with this extension by double-clicking their icons.\n\nAre you sure you want to remove this extension?" - IDS_SPECIFY_ACTION "You must specify an action." - IDS_INVALID_PROGRAM "The specified program could not be found. Make sure the file name and path are correct." - IDS_REMOVE_ACTION "Are you sure you want to remove this action?" - IDS_ACTION_EXISTS "The action '%s' is already registered for this file type. Please enter a different name and try again." - IDS_EXE_FILTER "Programs\0*.exe\0All Files\0*.*\0" - IDS_EDITING_ACTION "Editing action for type: " - IDS_NO_ICONS "The file '%s' contains no icons.\n\nChoose an icon from the list or specify a different file." - IDS_FILE_NOT_FOUND "The file '%s' was not found." + IDS_NEWEXT_ADVANCED_LEFT "<< Er&weitert" + IDS_NEWEXT_ADVANCED_RIGHT "&Erweitert >>" + IDS_NEWEXT_NEW "<Neu>" + IDS_NEWEXT_SPECIFY_EXT "Es muss eine Erweiterung angegeben werden." + IDS_NEWEXT_ALREADY_ASSOC "Die Erweiterung %s ist bereits mit dem Dateityp %s verknüpft. Möchten Sie die Verknüpfung von %s mit %s entfernen und einen neuen Dateityp erstellen?" + IDS_NEWEXT_EXT_IN_USE "Erweiterung wird bereits verwendet" + + IDS_REMOVE_EXT "Nach dem Entfernen einer registrierten Dateinamenerweiterung können Dateien mit dieser Erweiterung nicht mehr durch Doppelklicken auf das Dateisymbol geöffnet werden.\n\nSoll die Erweiterung trotzdem entfernt werden?" + IDS_SPECIFY_ACTION "Geben Sie einen Vorgang an." + IDS_INVALID_PROGRAM "Das angegebene Programm wurde nicht gefunden. Stellen Sie sicher, dass die Dateinamen- und Pfadangabe richtig sind." + IDS_REMOVE_ACTION "Soll diese Aktion wirklich entfernt werden?" + IDS_ACTION_EXISTS "Die Aktion '%s' ist für diesen Dateityp bereits registriert. Geben Sie einen anderen Namen ein und versuchen Sie es dann erneut." + IDS_EXE_FILTER "Programme\0*.exe\0All Files\0*.*\0" + IDS_EDITING_ACTION "Vorgang bearbeiten für Typ: " + IDS_NO_ICONS "Die Datei '%s' enthält keine Symbole.\n\nWählen Sie ein Symbol aus der Liste oder wählen Sie eine andere Datei." + IDS_FILE_NOT_FOUND "Die Datei '%s' wurde nicht gefunden." END
6 years, 7 months
1
0
0
0
11/11: [USER32] Update file description.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b4673a3caa3f55231e5a…
commit 9b4673a3caa3f55231e5a7a5ee0791b62aacca2b Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Aug 16 22:08:08 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:25 2018 +0200 [USER32] Update file description. --- win32ss/user/user32/windows/dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32ss/user/user32/windows/dialog.c b/win32ss/user/user32/windows/dialog.c index 3cf8371a54..0fc31a71fe 100644 --- a/win32ss/user/user32/windows/dialog.c +++ b/win32ss/user/user32/windows/dialog.c @@ -19,7 +19,7 @@ /* * PROJECT: ReactOS user32.dll * FILE: win32ss/user/user32/windows/dialog.c - * PURPOSE: Input + * PURPOSE: Dialog Manager * PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net) * Thomas Weidenmueller (w3seek(a)users.sourceforge.net) * Steven Edwards (Steven_Ed4153(a)yahoo.com)
6 years, 7 months
1
0
0
0
10/11: [USER32] Implement SoftModalMessageBox() based on the original MessageBoxTimeoutIndirectW().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2be262bfb10551e4b8829…
commit 2be262bfb10551e4b8829936fb68156583993f5e Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Aug 16 22:04:48 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:24 2018 +0200 [USER32] Implement SoftModalMessageBox() based on the original MessageBoxTimeoutIndirectW(). Additional changes: - Adapt the message-box dialog procedure to correctly take into account the presence or absence of a CANCEL button and take appropriate actions. - Cache the strings retrieved by MB_GetString() (add FIXME notices too). --- win32ss/user/user32/user32.spec | 2 +- win32ss/user/user32/windows/messagebox.c | 436 +++++++++++++++++++++---------- 2 files changed, 293 insertions(+), 145 deletions(-) diff --git a/win32ss/user/user32/user32.spec b/win32ss/user/user32/user32.spec index 79c0693ac9..2f3ec10bac 100644 --- a/win32ss/user/user32/user32.spec +++ b/win32ss/user/user32/user32.spec @@ -675,7 +675,7 @@ 666 stdcall ShowStartGlass(long) 667 stdcall ShowWindow(long long) NtUserShowWindow 668 stdcall ShowWindowAsync(long long) NtUserShowWindowAsync -669 stdcall SoftModalMessageBox(long) +669 stdcall SoftModalMessageBox(ptr) 670 stdcall SubtractRect(ptr ptr ptr) 671 stdcall SwapMouseButton(long) 672 stdcall SwitchDesktop(long) NtUserSwitchDesktop diff --git a/win32ss/user/user32/windows/messagebox.c b/win32ss/user/user32/windows/messagebox.c index 9ac339a97e..8dc135fa39 100644 --- a/win32ss/user/user32/windows/messagebox.c +++ b/win32ss/user/user32/windows/messagebox.c @@ -22,6 +22,7 @@ * PURPOSE: Message Boxes * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net) * Thomas Weidenmueller (w3seek(a)users.sourceforge.net) + * Hermes Belusca-Maito * UPDATE HISTORY: * 2003/07/28 Added some NT features * 2003/07/27 Code ported from wine @@ -29,6 +30,7 @@ */ #include <user32.h> +#include <ntstrsafe.h> WINE_DEFAULT_DEBUG_CHANNEL(user32); @@ -100,6 +102,43 @@ static const MSGBTNINFO MsgBtnInfo[] = /* INTERNAL FUNCTIONS ********************************************************/ +static UINT +LoadAllocStringW( + IN HINSTANCE hInstance OPTIONAL, + IN UINT uID, + OUT PWSTR* pString, + IN PCWSTR pDefaultString OPTIONAL) +{ + UINT Length; + PCWSTR pStr; + + /* Try to load the string from the resource */ + Length = LoadStringW(hInstance, uID, (LPWSTR)&pStr, 0); + if (Length == 0) + { + /* If the resource string was not found, use the fallback default one */ + + if (!pDefaultString) + { + /* None was specified, return NULL */ + *pString = NULL; + return 0; + } + + pStr = pDefaultString; + Length = wcslen(pStr); + } + + /* Allocate a new buffer, adding a NULL-terminator */ + *pString = RtlAllocateHeap(RtlGetProcessHeap(), 0, (Length + 1) * sizeof(WCHAR)); + if (!*pString) + return 0; + + /* Copy the string, NULL-terminated */ + RtlStringCchCopyNW(*pString, Length + 1, pStr, Length); + return Length; +} + static VOID MessageBoxTextToClipboard(HWND DialogWindow) { HWND hwndText; @@ -208,15 +247,14 @@ static INT_PTR CALLBACK MessageBoxProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - int Alert; PMSGBOXDATA mbd; - HELPINFO hi; - HWND hwndOwner; switch (message) { case WM_INITDIALOG: { + int Alert; + mbd = (PMSGBOXDATA)lParam; SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)mbd); @@ -234,7 +272,7 @@ static INT_PTR CALLBACK MessageBoxProc( SendDlgItemMessageW(hwnd, MSGBOX_IDICON, STM_SETICON, (WPARAM)(HICON)mbd->mbp.lpszIcon, 0); Alert = ALERT_SYSTEM_WARNING; } - else // Setup the rest of the alerts. + else /* Setup the rest of the alerts */ { switch (mbd->mbp.dwStyle & MB_ICONMASK) { @@ -249,32 +287,66 @@ static INT_PTR CALLBACK MessageBoxProc( break; default: Alert = ALERT_SYSTEM_INFORMATIONAL; - /* fall through */ + /* Fall through */ } } - /* Send out the alert notifications. */ + /* Send out the alert notifications */ NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_ALERT, Alert); - switch (mbd->mbp.dwStyle & MB_TYPEMASK) + /* Disable the Close menu button if no Cancel button is specified */ + if (mbd->uCancelId == 0) { - case MB_ABORTRETRYIGNORE: - case MB_YESNO: - RemoveMenu(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND); - break; + HMENU hSysMenu = GetSystemMenu(hwnd, FALSE); + if (hSysMenu) + DeleteMenu(hSysMenu, SC_CLOSE, MF_BYCOMMAND); } - ASSERT(mbd->uDefButton < mbd->dwButtons); - SetFocus(GetDlgItem(hwnd, mbd->pidButton[mbd->uDefButton])); + + /* Set the focus to the default button */ + if (mbd->dwButtons > 0) + { + ASSERT(mbd->uDefButton < mbd->dwButtons); + SetFocus(GetDlgItem(hwnd, mbd->pidButton[mbd->uDefButton])); + } + + /* Set up the window timer */ if (mbd->dwTimeout && (mbd->dwTimeout != (UINT)-1)) SetTimer(hwnd, 0, mbd->dwTimeout, NULL); } - return 0; + return FALSE; } case WM_COMMAND: - switch (LOWORD(wParam)) + { + UINT i; + INT_PTR iCtrlId = LOWORD(wParam); + + switch (iCtrlId) { + /* Handle the default message-box buttons */ case IDOK: case IDCANCEL: + /* + * The dialog manager always sends IDCANCEL when the user + * presses ESCape. We check here whether the message box + * has a CANCEL button, or whether we should fall back to + * the OK button, by using the correct uCancelId. + */ + if (iCtrlId == IDCANCEL) + { + mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); + if (!mbd) + return FALSE; /* Ignore */ + + /* Check whether we can cancel the message box */ + if (mbd->uCancelId == 0) + return TRUE; // FALSE; /* No, ignore */ + /* Quit with the correct return value */ + iCtrlId = mbd->uCancelId; + } + if (!GetDlgItem(hwnd, iCtrlId)) + return FALSE; /* Ignore */ + + /* Fall through */ case IDABORT: case IDRETRY: case IDIGNORE: @@ -282,69 +354,93 @@ static INT_PTR CALLBACK MessageBoxProc( case IDNO: case IDTRYAGAIN: case IDCONTINUE: - EndDialog(hwnd, wParam); - return 0; + EndDialog(hwnd, iCtrlId); + return TRUE; + + case IDCLOSE: + return FALSE; /* Ignore */ + case IDHELP: - /* send WM_HELP message to messagebox window */ + { + /* Send WM_HELP message to the message-box window */ + HELPINFO hi; hi.cbSize = sizeof(hi); hi.iContextType = HELPINFO_WINDOW; - hi.iCtrlId = LOWORD(wParam); + hi.iCtrlId = iCtrlId; hi.hItemHandle = (HANDLE)lParam; hi.dwContextId = 0; GetCursorPos(&hi.MousePos); SendMessageW(hwnd, WM_HELP, 0, (LPARAM)&hi); - return 0; + return TRUE; + } + + default: + break; } - return 0; + + /* Check for any other user-defined buttons */ + mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); + if (!mbd) + return FALSE; + + for (i = 0; i < mbd->dwButtons; ++i) + { + if (iCtrlId == mbd->pidButton[i]) + { + EndDialog(hwnd, iCtrlId); + return TRUE; + } + } + + return FALSE; + } case WM_COPY: MessageBoxTextToClipboard(hwnd); - return 0; + return TRUE; case WM_HELP: { + LPHELPINFO phi = (LPHELPINFO)lParam; mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); if (!mbd) - return 0; - memcpy(&hi, (void *)lParam, sizeof(hi)); - hi.dwContextId = GetWindowContextHelpId(hwnd); + return FALSE; + phi->dwContextId = GetWindowContextHelpId(hwnd); if (mbd->mbp.lpfnMsgBoxCallback) { - mbd->mbp.lpfnMsgBoxCallback(&hi); + mbd->mbp.lpfnMsgBoxCallback(phi); } else { - hwndOwner = GetWindow(hwnd, GW_OWNER); + HWND hwndOwner = GetWindow(hwnd, GW_OWNER); if (hwndOwner) - SendMessageW(hwndOwner, WM_HELP, 0, (LPARAM)&hi); + SendMessageW(hwndOwner, WM_HELP, 0, lParam); } - return 0; + return TRUE; } case WM_CLOSE: { mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); if (!mbd) - return 0; - switch (mbd->mbp.dwStyle & MB_TYPEMASK) - { - case MB_ABORTRETRYIGNORE: - case MB_YESNO: - return 1; - } - EndDialog(hwnd, IDCANCEL); - return 1; + return FALSE; + + /* Check whether we can cancel the message box */ + if (mbd->uCancelId == 0) + return TRUE; /* No, ignore */ + /* Quit with the correct return value */ + EndDialog(hwnd, mbd->uCancelId); + return TRUE; } case WM_TIMER: if (wParam == 0) - { EndDialog(hwnd, IDTIMEOUT); - } - return 0; + return FALSE; } - return 0; + + return FALSE; } static int @@ -352,40 +448,33 @@ MessageBoxTimeoutIndirectW( CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout) { int ret = 0; + UINT i; + LPWSTR defCaption = NULL; MSGBOXDATA mbd; MSGBTNINFO Buttons; LPCWSTR ButtonText[MSGBOXEX_MAXBTNS]; - DLGTEMPLATE *tpl; - DLGITEMTEMPLATE *iico, *itxt, *ibtn; - NONCLIENTMETRICSW nclm; - LPVOID buf; - BYTE *dest; - LPCWSTR caption, text; - HFONT hFont, hOldFont; - HICON hIcon; - HWND hDCWnd; - HDC hDC; - SIZE units; - int bufsize, caplen, textlen, i, btnleft, btntop; - size_t ButtonLen; - RECT btnrect, txtrect, rc; - SIZE btnsize; - POINT iconPos; SIZE iconSize; - ZeroMemory(&mbd, sizeof(mbd)); memcpy(&mbd.mbp, lpMsgBoxParams, sizeof(mbd.mbp)); - lpMsgBoxParams = &mbd.mbp; - - mbd.wLanguageId = (WORD)lpMsgBoxParams->dwLanguageId; // FIXME! + mbd.wLanguageId = (WORD)lpMsgBoxParams->dwLanguageId; mbd.dwTimeout = dwTimeout; + if (!mbd.mbp.lpszCaption) + { + /* No caption, use the default one */ + LoadAllocStringW(User32Instance, + IDS_ERROR, + &defCaption, + L"Error"); + mbd.mbp.lpszCaption = (defCaption ? defCaption : L"Error"); + } + /* Create the selected buttons; unknown types will fall back to MB_OK */ i = (lpMsgBoxParams->dwStyle & MB_TYPEMASK); if (i >= ARRAYSIZE(MsgBtnInfo)) i = MB_OK; - /* Get buttons IDs */ + /* Get the buttons IDs */ Buttons = MsgBtnInfo[i]; /* Add the Help button */ @@ -398,6 +487,23 @@ MessageBoxTimeoutIndirectW( ASSERT(Buttons.btnCnt <= MSGBOXEX_MAXBTNS); + /* Retrieve the pointers to the button labels and find the Cancel button */ + mbd.uCancelId = (i == MB_OK ? IDOK : 0); + for (i = 0; i < Buttons.btnCnt; ++i) + { + // FIXME: Use the strings in the correct language. + // MB_GetString gives the string in default system language. + ButtonText[i] = MB_GetString(Buttons.btnIds[i] - IDS_OK); /* or: Buttons.btnIdx[i] - IDOK */ +#if 0 + LoadAllocStringW(User32Instance, + Buttons.btnIds[i], + &ButtonText[i], + L""); +#endif + if (Buttons.btnIdx[i] == IDCANCEL) + mbd.uCancelId = IDCANCEL; + } + mbd.pidButton = Buttons.btnIdx; mbd.ppszButtonText = ButtonText; mbd.dwButtons = Buttons.btnCnt; @@ -406,48 +512,95 @@ MessageBoxTimeoutIndirectW( /* Make the first button the default button if none other is */ if (mbd.uDefButton >= mbd.dwButtons) mbd.uDefButton = 0; - // mbd.uCancelId; + /* Call the helper function */ + ret = SoftModalMessageBox(&mbd); - /* Load the caption */ - if (!lpMsgBoxParams->lpszCaption) +#if 0 + for (i = 0; i < mbd.dwButtons; i++) { - /* No caption, use the default one */ - caplen = LoadStringW(User32Instance, IDS_ERROR, (LPWSTR)&caption, 0); + if (ButtonText[i] && *ButtonText[i]) + RtlFreeHeap(RtlGetProcessHeap(), 0, ButtonText[i]); } - else if (IS_INTRESOURCE(lpMsgBoxParams->lpszCaption)) +#endif + + if (defCaption) + RtlFreeHeap(RtlGetProcessHeap(), 0, defCaption); + + return ret; +} + +int +WINAPI +SoftModalMessageBox(IN LPMSGBOXDATA lpMsgBoxData) +{ + int ret = 0; + MSGBOXDATA mbd; + LPMSGBOXPARAMSW lpMsgBoxParams = &mbd.mbp; + DLGTEMPLATE *tpl; + DLGITEMTEMPLATE *iico, *itxt, *ibtn; + NONCLIENTMETRICSW nclm; + LPVOID buf; + BYTE *dest; + LPWSTR caption, text; + HFONT hFont, hOldFont; + HICON hIcon; + HWND hDCWnd; + HDC hDC; + SIZE units; + int bufsize, caplen, textlen, i, btnleft, btntop; + size_t ButtonLen; + RECT btnrect, txtrect, rc; + SIZE btnsize; + POINT iconPos; SIZE iconSize; + + /* Capture the MsgBoxData */ + memcpy(&mbd, lpMsgBoxData, sizeof(mbd)); + + /* Load the caption */ + caption = NULL; + if (lpMsgBoxParams->lpszCaption && IS_INTRESOURCE(lpMsgBoxParams->lpszCaption)) { /* User-defined resource string */ - caplen = LoadStringW(lpMsgBoxParams->hInstance, - PtrToUlong(lpMsgBoxParams->lpszCaption), - (LPWSTR)&caption, 0); + caplen = LoadAllocStringW(lpMsgBoxParams->hInstance, + PtrToUlong(lpMsgBoxParams->lpszCaption), + &caption, + NULL); + lpMsgBoxParams->lpszCaption = caption; } - else + else if (lpMsgBoxParams->lpszCaption) { /* UNICODE string pointer */ - caption = lpMsgBoxParams->lpszCaption; - caplen = wcslen(caption); + caplen = wcslen(lpMsgBoxParams->lpszCaption); } - - /* Load the text */ - if (!lpMsgBoxParams->lpszText) + if (!lpMsgBoxParams->lpszCaption) { - /* No text, use blank */ - text = L""; - textlen = 0; + /* No caption, use blank */ + lpMsgBoxParams->lpszCaption = L""; + caplen = 0; } - else if (IS_INTRESOURCE(lpMsgBoxParams->lpszText)) + + /* Load the text */ + text = NULL; + if (lpMsgBoxParams->lpszText && IS_INTRESOURCE(lpMsgBoxParams->lpszText)) { /* User-defined resource string */ - textlen = LoadStringW(lpMsgBoxParams->hInstance, - PtrToUlong(lpMsgBoxParams->lpszText), - (LPWSTR)&text, 0); + textlen = LoadAllocStringW(lpMsgBoxParams->hInstance, + PtrToUlong(lpMsgBoxParams->lpszText), + &text, + NULL); + lpMsgBoxParams->lpszText = text; } - else + else if (lpMsgBoxParams->lpszText) { /* UNICODE string pointer */ - text = lpMsgBoxParams->lpszText; - textlen = wcslen(text); + textlen = wcslen(lpMsgBoxParams->lpszText); + } + if (!lpMsgBoxParams->lpszText) + { + /* No text, use blank */ + lpMsgBoxParams->lpszText = L""; + textlen = 0; } /* Load the icon */ @@ -483,7 +636,7 @@ MessageBoxTimeoutIndirectW( break; } /* Reuse the internal pointer! */ - ((MSGBOXPARAMSW*)lpMsgBoxParams)->lpszIcon = (LPCWSTR)hIcon; + lpMsgBoxParams->lpszIcon = (LPCWSTR)hIcon; /* Basic space */ bufsize = sizeof(DLGTEMPLATE) + @@ -509,31 +662,17 @@ MessageBoxTimeoutIndirectW( /* Space for the buttons */ for (i = 0; i < mbd.dwButtons; i++) { - /* Get the default text of the buttons */ - if (Buttons.btnIds[i]) - { - LPCWSTR pStr; - ButtonLen = LoadStringW(User32Instance, - Buttons.btnIds[i], - (LPWSTR)&pStr, 0); - mbd.ppszButtonText[i] = RtlAllocateHeap(GetProcessHeap(), 0, (ButtonLen + 1) * sizeof(WCHAR)); - if (mbd.ppszButtonText[i]) - { - memcpy((LPWSTR)mbd.ppszButtonText[i], pStr, ButtonLen * sizeof(WCHAR)); - ((LPWSTR)mbd.ppszButtonText[i])[ButtonLen] = 0; - } - else - { - mbd.ppszButtonText[i] = L""; - ButtonLen = 0; - } - } - else + if (!mbd.ppszButtonText[i] || !*mbd.ppszButtonText[i]) { /* No text, use blank */ mbd.ppszButtonText[i] = L""; ButtonLen = 0; } + else + { + /* UNICODE string pointer */ + ButtonLen = wcslen(mbd.ppszButtonText[i]); + } bufsize = ALIGN_UP(bufsize, DWORD); bufsize += sizeof(DLGITEMTEMPLATE) + @@ -542,7 +681,7 @@ MessageBoxTimeoutIndirectW( } /* Allocate the dialog template */ - buf = RtlAllocateHeap(GetProcessHeap(), 0, bufsize); + buf = RtlAllocateHeap(RtlGetProcessHeap(), 0, bufsize); if (!buf) goto Quit; @@ -554,7 +693,7 @@ MessageBoxTimeoutIndirectW( hFont = CreateFontIndirectW(&nclm.lfMessageFont); if (!hFont) { - ERR("Cannot retrieve nclm.lfMessageFont!\n"); + ERR("Cannot retrieve nclm.lfMessageFont! (error %lu)\n", GetLastError()); goto Quit; } @@ -568,7 +707,7 @@ MessageBoxTimeoutIndirectW( } if (!hDC) { - ERR("GetDCEx() failed, bail out!\n"); + ERR("GetDCEx() failed, bail out! (error %lu)\n", GetLastError()); goto Quit; } hOldFont = SelectObject(hDC, hFont); @@ -577,7 +716,7 @@ MessageBoxTimeoutIndirectW( if (!units.cx) { DWORD defUnits; - ERR("GdiGetCharDimensions() failed, falling back to default values!\n"); + ERR("GdiGetCharDimensions() failed, falling back to default values (error %lu)\n", GetLastError()); defUnits = GetDialogBaseUnits(); units.cx = LOWORD(defUnits); units.cy = HIWORD(defUnits); @@ -590,7 +729,7 @@ MessageBoxTimeoutIndirectW( txtrect.top = txtrect.left = txtrect.bottom = 0; if (textlen != 0) { - DrawTextW(hDC, text, textlen, &txtrect, + DrawTextW(hDC, lpMsgBoxParams->lpszText, textlen, &txtrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); } else @@ -682,7 +821,6 @@ MessageBoxTimeoutIndirectW( } - /* Initialize the dialog template */ tpl = (DLGTEMPLATE *)buf; @@ -701,7 +839,7 @@ MessageBoxTimeoutIndirectW( *(DWORD*)dest = 0; /* no menu and use default window class */ dest += 2 * sizeof(WORD); - memcpy(dest, caption, caplen * sizeof(WCHAR)); + memcpy(dest, lpMsgBoxParams->lpszCaption, caplen * sizeof(WCHAR)); dest += caplen * sizeof(WCHAR); *(WCHAR*)dest = L'\0'; dest += sizeof(WCHAR); @@ -755,7 +893,7 @@ MessageBoxTimeoutIndirectW( dest += sizeof(WORD); *(WORD*)dest = 0x0082; /* static control */ dest += sizeof(WORD); - memcpy(dest, text, textlen * sizeof(WCHAR)); + memcpy(dest, lpMsgBoxParams->lpszText, textlen * sizeof(WCHAR)); dest += textlen * sizeof(WCHAR); *(WCHAR*)dest = 0; dest += sizeof(WCHAR); @@ -808,10 +946,11 @@ MessageBoxTimeoutIndirectW( btnleft += btnsize.cx + MSGBOXEX_BUTTONSPACING; } - /* Calculate the size and position of the messagebox window */ + /* Calculate the size and position of the message-box window */ btnleft = max(btnleft - MSGBOXEX_BUTTONSPACING, rc.left + txtrect.right); btnleft += MSGBOXEX_MARGIN; - btntop += btnsize.cy + MSGBOXEX_MARGIN; + if (mbd.dwButtons > 0) + btntop += btnsize.cy + MSGBOXEX_MARGIN; /* Set the size and position of the static message */ itxt->x = RESCALE_X(rc.left, units); @@ -823,19 +962,20 @@ MessageBoxTimeoutIndirectW( tpl->cx = RESCALE_X(btnleft, units); tpl->cy = RESCALE_Y(btntop, units); - /* Finally show the messagebox */ + /* Finally show the message-box */ ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, lpMsgBoxParams->hwndOwner, MessageBoxProc, (LPARAM)&mbd); Quit: - RtlFreeHeap(GetProcessHeap(), 0, buf); + if (buf) + RtlFreeHeap(RtlGetProcessHeap(), 0, buf); - for (i = 0; i < mbd.dwButtons; i++) - { - if (mbd.ppszButtonText[i] && *(mbd.ppszButtonText[i])) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR)mbd.ppszButtonText[i]); - } + if (text) + RtlFreeHeap(RtlGetProcessHeap(), 0, text); + + if (caption) + RtlFreeHeap(RtlGetProcessHeap(), 0, caption); return ret; } @@ -1098,24 +1238,13 @@ MessageBoxTimeoutW( } -/* - * @unimplemented - */ -DWORD -WINAPI -SoftModalMessageBox(DWORD Unknown0) -{ - UNIMPLEMENTED; - return 0; -} - - /* * @implemented */ BOOL WINAPI -MessageBeep(IN UINT uType) +MessageBeep( + IN UINT uType) { return NtUserxMessageBeep(uType); } @@ -1130,9 +1259,30 @@ MessageBeep(IN UINT uType) */ LPCWSTR WINAPI -MB_GetString(IN UINT wBtn) +MB_GetString( + IN UINT wBtn) { - LPCWSTR btnStr = NULL; + static BOOL bCached = FALSE; + static MBSTRING MBStrings[MAX_MB_STRINGS]; // FIXME: Use gpsi->MBStrings when this is loaded by Win32k! + + // + // FIXME - TODO: The gpsi->MBStrings[] array should be loaded by win32k! + // + ASSERT(IDCONTINUE <= MAX_MB_STRINGS); + if (!bCached) + { + UINT i; + for (i = 0; i < MAX_MB_STRINGS; ++i) + { + /*gpsi->*/MBStrings[i].uID = IDOK + i; + /*gpsi->*/MBStrings[i].uStr = IDS_OK + i; // See user32/include/resource.h + LoadStringW(User32Instance, + /*gpsi->*/MBStrings[i].uStr, + /*gpsi->*/MBStrings[i].szName, + ARRAYSIZE(/*gpsi->*/MBStrings[i].szName)); + } + bCached = TRUE; + } /* * The allowable IDs are between "IDOK - 1" (0) and "IDCONTINUE - 1" (10) inclusive. @@ -1141,9 +1291,7 @@ MB_GetString(IN UINT wBtn) if (wBtn > IDCONTINUE - 1) return NULL; - wBtn += 800; // See user32/include/resource.h - LoadStringW(User32Instance, wBtn, (LPWSTR)&btnStr, 0); - return btnStr; + return /*gpsi->*/MBStrings[wBtn].szName; } /* EOF */
6 years, 7 months
1
0
0
0
09/11: [ROSTESTS] Add an interactive test for the user32.dll API SoftModalMessageBox().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5fedabbf0aefb015841b2…
commit 5fedabbf0aefb015841b2329a8d64d099c3a6c7b Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Aug 16 22:01:52 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:23 2018 +0200 [ROSTESTS] Add an interactive test for the user32.dll API SoftModalMessageBox(). --- modules/rostests/win32/user32/CMakeLists.txt | 1 + .../win32/user32/softmodalmsgbox/CMakeLists.txt | 5 + .../win32/user32/softmodalmsgbox/resource.h | 2 + .../win32/user32/softmodalmsgbox/softmodalmsgbox.c | 122 +++++++++++++++++++++ .../user32/softmodalmsgbox/softmodalmsgbox.rc | 11 ++ 5 files changed, 141 insertions(+) diff --git a/modules/rostests/win32/user32/CMakeLists.txt b/modules/rostests/win32/user32/CMakeLists.txt index d1d83974bd..205afbc403 100644 --- a/modules/rostests/win32/user32/CMakeLists.txt +++ b/modules/rostests/win32/user32/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(biditext) add_subdirectory(paintdesktop) +add_subdirectory(softmodalmsgbox) add_subdirectory(sysicon) add_subdirectory(winstation) diff --git a/modules/rostests/win32/user32/softmodalmsgbox/CMakeLists.txt b/modules/rostests/win32/user32/softmodalmsgbox/CMakeLists.txt new file mode 100644 index 0000000000..310a01e518 --- /dev/null +++ b/modules/rostests/win32/user32/softmodalmsgbox/CMakeLists.txt @@ -0,0 +1,5 @@ + +add_executable(softmodalmsgbox softmodalmsgbox.c softmodalmsgbox.rc) +set_module_type(softmodalmsgbox win32cui UNICODE) +add_importlibs(softmodalmsgbox user32 msvcrt kernel32) +add_rostests_file(TARGET softmodalmsgbox SUBDIR suppl) diff --git a/modules/rostests/win32/user32/softmodalmsgbox/resource.h b/modules/rostests/win32/user32/softmodalmsgbox/resource.h new file mode 100644 index 0000000000..6e6ee36e09 --- /dev/null +++ b/modules/rostests/win32/user32/softmodalmsgbox/resource.h @@ -0,0 +1,2 @@ +#define IDS_RES_CAPTION 101 +#define IDS_RES_MESSAGE 102 diff --git a/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.c b/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.c new file mode 100644 index 0000000000..40913e6142 --- /dev/null +++ b/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.c @@ -0,0 +1,122 @@ +/* + * PROJECT: ReactOS Tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Tests the undocumented user32.dll API SoftModalMessageBox(). + * COPYRIGHT: Copyright 2018 Hermes Belusca-Maito + */ + +#include <stdio.h> +#include <stdlib.h> +#include <conio.h> + +#include <windef.h> +#include <winbase.h> +#include <winuser.h> + +#include "resource.h" + +/* Adjust according to your platform! -- ReactOS is currently compatible with Windows Server 2003 */ +#undef _WIN32_WINNT +#define _WIN32_WINNT _WIN32_WINNT_WS03 // _WIN32_WINNT_WIN2K // _WIN32_WINNT_WS03 // _WIN32_WINNT_WIN7 + +typedef struct _MSGBOXDATA +{ + MSGBOXPARAMSW mbp; // Size: 0x28 (x86), 0x50 (x64) + HWND hwndOwner; // Will be converted to PWND +#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ + DWORD dwPadding; +#endif + WORD wLanguageId; + INT* pidButton; // Array of button IDs + LPCWSTR* ppszButtonText; // Array of button text strings + DWORD dwButtons; // Number of buttons + UINT uDefButton; // Default button ID + UINT uCancelId; // Button ID corresponding to Cancel action +#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) /* (NTDDI_VERSION >= NTDDI_WINXP) */ + DWORD dwTimeout; // Message box timeout +#endif + DWORD dwReserved0; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ + DWORD dwReserved[4]; +#endif +} MSGBOXDATA, *PMSGBOXDATA, *LPMSGBOXDATA; + + +#if defined(_WIN64) + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x98); +#elif (_WIN32_WINNT <= _WIN32_WINNT_WS03) /* (NTDDI_VERSION == NTDDI_WS03) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x88); +#endif + +#else + +#if (_WIN32_WINNT <= _WIN32_WINNT_WIN2K) /* (NTDDI_VERSION <= NTDDI_WIN2KSP4) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x48); +#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x60); +#else // (_WIN32_WINNT == _WIN32_WINNT_WINXP || _WIN32_WINNT == _WIN32_WINNT_WS03) /* (NTDDI_VERSION == NTDDI_WS03) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x4C); +#endif + +#endif + + +typedef int (WINAPI *SOFTMODALMESSAGEBOX)(LPMSGBOXDATA lpMsgBoxData); +// int WINAPI SoftModalMessageBox(IN LPMSGBOXDATA lpMsgBoxData); +SOFTMODALMESSAGEBOX SoftModalMessageBox = NULL; + +// +// Example taken from
http://rsdn.org/forum/winapi/3273168.1
+// See also
http://www.vbforums.com/showthread.php?840593-Message-Box-with-Four-Buttons
+// +int wmain(int argc, WCHAR* argv[]) +{ + MSGBOXDATA data; + int res = 0; + + INT pids[] = + { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 /*, 2*/ + }; + /* NOTE: Buttons do NOT support resource IDs specifications! */ + LPCWSTR ppText[] = + { + L"Button 1", L"Button 2", L"Button 3", L"Button 4", L"Button 5", L"Button 6", L"Button 7", L"Button 8", L"Button 9", L"Button 10", L"Button 11", L"Button 12", L"Button 13" + }; + + ZeroMemory(&data, sizeof(data)); + data.mbp.cbSize = sizeof(data.mbp); + data.mbp.hwndOwner = FindWindowW(L"Shell_TrayWnd", NULL); + data.mbp.hInstance = GetModuleHandleW(NULL); + data.mbp.lpszText = L"This is a message box made using the undocumented SoftModalMessageBox() API."; + data.mbp.lpszCaption = MAKEINTRESOURCEW(IDS_RES_CAPTION); // L"SoftModalMessageBox"; + data.mbp.lpfnMsgBoxCallback = NULL; // SoftModalMessageBoxCallback; + data.mbp.dwStyle = MB_ICONINFORMATION | MB_RETRYCANCEL; + + data.wLanguageId = 0; + data.pidButton = pids; + data.ppszButtonText = ppText; + data.dwButtons = _countof(pids); + data.uDefButton = 2; + data.uCancelId = 0; +#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) /* (NTDDI_VERSION >= NTDDI_WINXP) */ + data.dwTimeout = 3 * 1000; +#endif + + SoftModalMessageBox = (SOFTMODALMESSAGEBOX)GetProcAddress(GetModuleHandleW(L"user32.dll"), "SoftModalMessageBox"); + if (!SoftModalMessageBox) + { + printf("SoftModalMessageBoxW not found in user32.dll\n"); + } + else + { + res = SoftModalMessageBox(&data); + printf("Returned value = %i\n\n", res); + } + + printf("Press any key to quit...\n"); + _getch(); + return 0; +} diff --git a/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.rc b/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.rc new file mode 100644 index 0000000000..e04c4eaee9 --- /dev/null +++ b/modules/rostests/win32/user32/softmodalmsgbox/softmodalmsgbox.rc @@ -0,0 +1,11 @@ + +#include <windef.h> +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_RES_CAPTION "Resource Caption" + IDS_RES_MESSAGE "Resource Message" +END
6 years, 7 months
1
0
0
0
08/11: [USER32] Code refactoring for MessageBoxTimeoutIndirectW(), in preparation for SoftModalMessageBox() implementation.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4f7318b7594ec97165d3f…
commit 4f7318b7594ec97165d3f62c6a4eaf82af43b987 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Aug 12 18:16:29 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:22 2018 +0200 [USER32] Code refactoring for MessageBoxTimeoutIndirectW(), in preparation for SoftModalMessageBox() implementation. - Remove usage of ButtonLen and ibtn-pointer arrays, to make the code more generic and less dependent on the (maximal) number of buttons in the message boxes. - Move around the code that computes the positions and sizes of the window controls. --- win32ss/user/user32/windows/messagebox.c | 384 +++++++++++++++++-------------- 1 file changed, 215 insertions(+), 169 deletions(-) diff --git a/win32ss/user/user32/windows/messagebox.c b/win32ss/user/user32/windows/messagebox.c index 6fb379869e..9ac339a97e 100644 --- a/win32ss/user/user32/windows/messagebox.c +++ b/win32ss/user/user32/windows/messagebox.c @@ -97,6 +97,7 @@ static const MSGBTNINFO MsgBtnInfo[] = DECLARE_MB_3(CANCEL, TRYAGAIN, CONTINUE) }; + /* INTERNAL FUNCTIONS ********************************************************/ static VOID MessageBoxTextToClipboard(HWND DialogWindow) @@ -350,25 +351,26 @@ static int MessageBoxTimeoutIndirectW( CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout) { + int ret = 0; MSGBOXDATA mbd; + MSGBTNINFO Buttons; + LPCWSTR ButtonText[MSGBOXEX_MAXBTNS]; DLGTEMPLATE *tpl; - DLGITEMTEMPLATE *iico, *itxt; + DLGITEMTEMPLATE *iico, *itxt, *ibtn; NONCLIENTMETRICSW nclm; LPVOID buf; BYTE *dest; LPCWSTR caption, text; HFONT hFont, hOldFont; - HICON Icon; + HICON hIcon; HWND hDCWnd; HDC hDC; SIZE units; - int bufsize, ret, caplen, textlen, i, btnleft, btntop, lmargin; - MSGBTNINFO Buttons; - LPCWSTR ButtonText[MSGBOXEX_MAXBTNS]; - int ButtonLen[MSGBOXEX_MAXBTNS]; - DLGITEMTEMPLATE *ibtn[MSGBOXEX_MAXBTNS]; + int bufsize, caplen, textlen, i, btnleft, btntop; + size_t ButtonLen; RECT btnrect, txtrect, rc; SIZE btnsize; + POINT iconPos; SIZE iconSize; ZeroMemory(&mbd, sizeof(mbd)); @@ -394,6 +396,8 @@ MessageBoxTimeoutIndirectW( Buttons.btnCnt++; } + ASSERT(Buttons.btnCnt <= MSGBOXEX_MAXBTNS); + mbd.pidButton = Buttons.btnIdx; mbd.ppszButtonText = ButtonText; mbd.dwButtons = Buttons.btnCnt; @@ -405,6 +409,7 @@ MessageBoxTimeoutIndirectW( // mbd.uCancelId; + /* Load the caption */ if (!lpMsgBoxParams->lpszCaption) { /* No caption, use the default one */ @@ -421,13 +426,14 @@ MessageBoxTimeoutIndirectW( { /* UNICODE string pointer */ caption = lpMsgBoxParams->lpszCaption; - caplen = strlenW(caption); + caplen = wcslen(caption); } + /* Load the text */ if (!lpMsgBoxParams->lpszText) { /* No text, use blank */ - text = L""; + text = L""; textlen = 0; } else if (IS_INTRESOURCE(lpMsgBoxParams->lpszText)) @@ -440,30 +446,31 @@ MessageBoxTimeoutIndirectW( else { /* UNICODE string pointer */ - text = lpMsgBoxParams->lpszText; - textlen = strlenW(text); + text = lpMsgBoxParams->lpszText; + textlen = wcslen(text); } + /* Load the icon */ switch (lpMsgBoxParams->dwStyle & MB_ICONMASK) { case MB_ICONEXCLAMATION: // case MB_ICONWARNING: - Icon = LoadIconW(0, IDI_EXCLAMATIONW); + hIcon = LoadIconW(NULL, IDI_EXCLAMATIONW); MessageBeep(MB_ICONEXCLAMATION); break; case MB_ICONQUESTION: - Icon = LoadIconW(0, IDI_QUESTIONW); + hIcon = LoadIconW(NULL, IDI_QUESTIONW); MessageBeep(MB_ICONQUESTION); break; case MB_ICONASTERISK: // case MB_ICONINFORMATION: - Icon = LoadIconW(0, IDI_ASTERISKW); + hIcon = LoadIconW(NULL, IDI_ASTERISKW); MessageBeep(MB_ICONASTERISK); break; case MB_ICONHAND: // case MB_ICONSTOP: case MB_ICONERROR: - Icon = LoadIconW(0, IDI_HANDW); + hIcon = LoadIconW(NULL, IDI_HANDW); MessageBeep(MB_ICONHAND); break; case MB_USERICON: - Icon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon); + hIcon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon); MessageBeep(MB_OK); break; default: @@ -471,13 +478,12 @@ MessageBoxTimeoutIndirectW( * By default, Windows 95/98/NT does not associate an icon * to message boxes. So ReactOS should do the same. */ - Icon = NULL; + hIcon = NULL; MessageBeep(MB_OK); break; } - /* Reuse the internal pointer! */ - ((MSGBOXPARAMSW*)lpMsgBoxParams)->lpszIcon = (LPCWSTR)Icon; + ((MSGBOXPARAMSW*)lpMsgBoxParams)->lpszIcon = (LPCWSTR)hIcon; /* Basic space */ bufsize = sizeof(DLGTEMPLATE) + @@ -485,8 +491,8 @@ MessageBoxTimeoutIndirectW( (caplen + 1) * sizeof(WCHAR) + /* title */ sizeof(WORD); /* font height */ - /* Space for icon */ - if (Icon) + /* Space for the icon */ + if (hIcon) { bufsize = ALIGN_UP(bufsize, DWORD); bufsize += sizeof(DLGITEMTEMPLATE) + @@ -494,41 +500,55 @@ MessageBoxTimeoutIndirectW( sizeof(WCHAR); } - /* Space for text */ + /* Space for the text */ bufsize = ALIGN_UP(bufsize, DWORD); bufsize += sizeof(DLGITEMTEMPLATE) + 3 * sizeof(WORD) + (textlen + 1) * sizeof(WCHAR); + /* Space for the buttons */ for (i = 0; i < mbd.dwButtons; i++) { /* Get the default text of the buttons */ if (Buttons.btnIds[i]) { - ButtonLen[i] = LoadStringW(User32Instance, - Buttons.btnIds[i], - (LPWSTR)&mbd.ppszButtonText[i], 0); + LPCWSTR pStr; + ButtonLen = LoadStringW(User32Instance, + Buttons.btnIds[i], + (LPWSTR)&pStr, 0); + mbd.ppszButtonText[i] = RtlAllocateHeap(GetProcessHeap(), 0, (ButtonLen + 1) * sizeof(WCHAR)); + if (mbd.ppszButtonText[i]) + { + memcpy((LPWSTR)mbd.ppszButtonText[i], pStr, ButtonLen * sizeof(WCHAR)); + ((LPWSTR)mbd.ppszButtonText[i])[ButtonLen] = 0; + } + else + { + mbd.ppszButtonText[i] = L""; + ButtonLen = 0; + } } else { /* No text, use blank */ mbd.ppszButtonText[i] = L""; - ButtonLen[i] = 0; + ButtonLen = 0; } - /* Space for buttons */ bufsize = ALIGN_UP(bufsize, DWORD); bufsize += sizeof(DLGITEMTEMPLATE) + 3 * sizeof(WORD) + - (ButtonLen[i] + 1) * sizeof(WCHAR); + (ButtonLen + 1) * sizeof(WCHAR); } + /* Allocate the dialog template */ buf = RtlAllocateHeap(GetProcessHeap(), 0, bufsize); if (!buf) - return 0; + goto Quit; iico = itxt = NULL; + nclm.cbSize = sizeof(nclm); SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0); hFont = CreateFontIndirectW(&nclm.lfMessageFont); @@ -538,6 +558,132 @@ MessageBoxTimeoutIndirectW( goto Quit; } + hDCWnd = NULL; + hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); + if (!hDC) + { + /* Retry with the DC of the owner window */ + hDCWnd = lpMsgBoxParams->hwndOwner; + hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); + } + if (!hDC) + { + ERR("GetDCEx() failed, bail out!\n"); + goto Quit; + } + hOldFont = SelectObject(hDC, hFont); + + units.cx = GdiGetCharDimensions(hDC, NULL, &units.cy); + if (!units.cx) + { + DWORD defUnits; + ERR("GdiGetCharDimensions() failed, falling back to default values!\n"); + defUnits = GetDialogBaseUnits(); + units.cx = LOWORD(defUnits); + units.cy = HIWORD(defUnits); + } + + /* Calculate the caption rectangle */ + txtrect.right = MulDiv(GetSystemMetrics(SM_CXSCREEN), 4, 5); + if (hIcon) + txtrect.right -= GetSystemMetrics(SM_CXICON) + MSGBOXEX_SPACING; + txtrect.top = txtrect.left = txtrect.bottom = 0; + if (textlen != 0) + { + DrawTextW(hDC, text, textlen, &txtrect, + DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); + } + else + { + txtrect.right = txtrect.left + 1; + txtrect.bottom = txtrect.top + 1; + } + txtrect.right++; + + /* Calculate the maximum buttons size */ + btnsize.cx = BTN_CX; + btnsize.cy = BTN_CY; + btnrect.left = btnrect.top = 0; + for (i = 0; i < mbd.dwButtons; i++) + { + // btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed?? + DrawTextW(hDC, mbd.ppszButtonText[i], wcslen(mbd.ppszButtonText[i]), + &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT); + btnsize.cx = max(btnsize.cx, btnrect.right); + btnsize.cy = max(btnsize.cy, btnrect.bottom); + } + + if (hOldFont) + SelectObject(hDC, hOldFont); + + ReleaseDC(hDCWnd, hDC); + + if (hFont) + DeleteObject(hFont); + + + /* Calculate position and size of controls */ + + + /* Calculate position and size of the icon */ + rc.left = rc.bottom = rc.right = 0; + btntop = 0; + if (hIcon) + { + rc.right = GetSystemMetrics(SM_CXICON); + rc.bottom = GetSystemMetrics(SM_CYICON); +#ifdef MSGBOX_ICONVCENTER + rc.top = MSGBOXEX_MARGIN + ((max(txtrect.bottom, rc.bottom) - rc.bottom) / 2); + rc.top = max(MSGBOXEX_SPACING, rc.top); +#else + rc.top = MSGBOXEX_MARGIN; +#endif + btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; + if (btnleft > txtrect.right + rc.right + MSGBOXEX_SPACING) + { +#ifdef MSGBOX_TEXTHCENTER + rc.left = MSGBOXEX_MARGIN + ((btnleft - txtrect.right - rc.right - MSGBOXEX_SPACING) / 2); +#else + rc.left = MSGBOXEX_MARGIN; +#endif + btnleft = MSGBOXEX_MARGIN; + } + else + { + rc.left = MSGBOXEX_MARGIN; + btnleft = MSGBOXEX_MARGIN + ((txtrect.right + rc.right + MSGBOXEX_SPACING - btnleft) / 2); + } + + iconPos.x = RESCALE_X(rc.left, units); + iconPos.y = RESCALE_Y(rc.top, units); + iconSize.cx = RESCALE_X(rc.right, units); + iconSize.cy = RESCALE_Y(rc.bottom, units); + + btntop = rc.top + rc.bottom + MSGBOXEX_SPACING; + rc.left += rc.right + MSGBOXEX_SPACING; + } + else + { + btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; + if (btnleft > txtrect.right) + { +#ifdef MSGBOX_TEXTHCENTER + rc.left = MSGBOXEX_MARGIN + ((btnleft - txtrect.right) / 2); +#else + rc.left = MSGBOXEX_MARGIN; +#endif + btnleft = MSGBOXEX_MARGIN; + } + else + { + rc.left = MSGBOXEX_MARGIN; + btnleft = MSGBOXEX_MARGIN + ((txtrect.right - btnleft) / 2); + } + } + + + + /* Initialize the dialog template */ tpl = (DLGTEMPLATE *)buf; tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | @@ -549,7 +695,7 @@ MessageBoxTimeoutIndirectW( tpl->dwExtendedStyle |= WS_EX_RIGHT; tpl->x = 100; tpl->y = 100; - tpl->cdit = mbd.dwButtons + (Icon ? 1 : 0) + 1; + tpl->cdit = mbd.dwButtons + (hIcon ? 1 : 0) + 1; /* Buttons, icon and text */ dest = (BYTE *)(tpl + 1); @@ -567,8 +713,8 @@ MessageBoxTimeoutIndirectW( *(WORD*)dest = 0x7FFF; dest += sizeof(WORD); - /* Create icon */ - if (Icon) + /* Create the icon */ + if (hIcon) { dest = ALIGN_UP_POINTER(dest, DWORD); iico = (DLGITEMTEMPLATE *)dest; @@ -576,6 +722,11 @@ MessageBoxTimeoutIndirectW( iico->dwExtendedStyle = 0; iico->id = MSGBOX_IDICON; + iico->x = iconPos.x; + iico->y = iconPos.y; + iico->cx = iconSize.cx; + iico->cy = iconSize.cy; + dest += sizeof(DLGITEMTEMPLATE); *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); @@ -611,176 +762,64 @@ MessageBoxTimeoutIndirectW( *(WORD*)dest = 0; dest += sizeof(WORD); - hDCWnd = NULL; - hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); - if (!hDC) - { - /* Retry with the DC of the owner window */ - hDCWnd = lpMsgBoxParams->hwndOwner; - hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); - } - if (!hDC) - { - ERR("GetDCEx() failed, bail out!\n"); - goto Quit; - } - hOldFont = SelectObject(hDC, hFont); - units.cx = GdiGetCharDimensions(hDC, NULL, &units.cy); - if (!units.cx) - { - DWORD defUnits; - ERR("GdiGetCharDimensions() failed, falling back to default values!\n"); - defUnits = GetDialogBaseUnits(); - units.cx = LOWORD(defUnits); - units.cy = HIWORD(defUnits); - } + /* Calculate position of the text */ + rc.top = MSGBOXEX_MARGIN + ((rc.bottom - txtrect.bottom) / 2); + rc.top = max(rc.top, MSGBOXEX_MARGIN); - /* Create buttons */ - btnsize.cx = BTN_CX; - btnsize.cy = BTN_CY; - btnrect.left = btnrect.top = 0; /* Make the first button the default button if none other is */ if (mbd.uDefButton >= mbd.dwButtons) mbd.uDefButton = 0; + /* Create and calculate the position of the buttons */ + btntop = max(rc.top + txtrect.bottom + MSGBOXEX_SPACING, btntop); for (i = 0; i < mbd.dwButtons; i++) { + ButtonLen = wcslen(mbd.ppszButtonText[i]); + dest = ALIGN_UP_POINTER(dest, DWORD); - ibtn[i] = (DLGITEMTEMPLATE *)dest; + ibtn = (DLGITEMTEMPLATE *)dest; - ibtn[i]->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP; + ibtn->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP; if (i == mbd.uDefButton) - ibtn[i]->style |= BS_DEFPUSHBUTTON; + ibtn->style |= BS_DEFPUSHBUTTON; else - ibtn[i]->style |= BS_PUSHBUTTON; + ibtn->style |= BS_PUSHBUTTON; - ibtn[i]->dwExtendedStyle = 0; - ibtn[i]->id = mbd.pidButton[i]; + ibtn->dwExtendedStyle = 0; + ibtn->id = mbd.pidButton[i]; dest += sizeof(DLGITEMTEMPLATE); *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WORD*)dest = 0x0080; /* button control */ dest += sizeof(WORD); - memcpy(dest, mbd.ppszButtonText[i], ButtonLen[i] * sizeof(WCHAR)); - dest += ButtonLen[i] * sizeof(WCHAR); + memcpy(dest, mbd.ppszButtonText[i], ButtonLen * sizeof(WCHAR)); + dest += ButtonLen * sizeof(WCHAR); *(WORD*)dest = 0; dest += sizeof(WORD); *(WORD*)dest = 0; dest += sizeof(WORD); - // btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed?? - DrawTextW(hDC, mbd.ppszButtonText[i], ButtonLen[i], &btnrect, - DT_LEFT | DT_SINGLELINE | DT_CALCRECT); - btnsize.cx = max(btnsize.cx, btnrect.right); - btnsize.cy = max(btnsize.cy, btnrect.bottom); - } - - /* calculate position and size of controls */ - txtrect.right = GetSystemMetrics(SM_CXSCREEN) / 5 * 4; - if (Icon) - txtrect.right -= GetSystemMetrics(SM_CXICON) + MSGBOXEX_SPACING; - txtrect.top = txtrect.left = txtrect.bottom = 0; - if (textlen != 0) - { - DrawTextW(hDC, text, textlen, &txtrect, - DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); - } - else - { - txtrect.right = txtrect.left + 1; - txtrect.bottom = txtrect.top + 1; - } - txtrect.right++; - - if (hOldFont) - SelectObject(hDC, hOldFont); - - ReleaseDC(hDCWnd, hDC); - - if (hFont) - DeleteObject(hFont); - - /* calculate position and size of the icon */ - rc.left = rc.bottom = rc.right = 0; - btntop = 0; - - if (iico) - { - rc.right = GetSystemMetrics(SM_CXICON); - rc.bottom = GetSystemMetrics(SM_CYICON); -#ifdef MSGBOX_ICONVCENTER - rc.top = MSGBOXEX_MARGIN + (max(txtrect.bottom, rc.bottom) / 2) - (GetSystemMetrics(SM_CYICON) / 2); - rc.top = max(MSGBOXEX_SPACING, rc.top); -#else - rc.top = MSGBOXEX_MARGIN; -#endif - btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; - if (btnleft > txtrect.right + rc.right + MSGBOXEX_SPACING) - { -#ifdef MSGBOX_TEXTHCENTER - lmargin = MSGBOXEX_MARGIN + ((btnleft - txtrect.right - rc.right - MSGBOXEX_SPACING) / 2); -#else - lmargin = MSGBOXEX_MARGIN; -#endif - btnleft = MSGBOXEX_MARGIN; - } - else - { - lmargin = MSGBOXEX_MARGIN; - btnleft = MSGBOXEX_MARGIN + ((txtrect.right + rc.right + MSGBOXEX_SPACING) / 2) - (btnleft / 2); - } - rc.left = lmargin; - iico->x = RESCALE_X(rc.left, units); - iico->y = RESCALE_Y(rc.top, units); - iico->cx = RESCALE_X(rc.right, units); - iico->cy = RESCALE_Y(rc.bottom, units); - btntop = rc.top + rc.bottom + MSGBOXEX_SPACING; - rc.left += rc.right + MSGBOXEX_SPACING; - } - else - { - btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; - if (btnleft > txtrect.right) - { -#ifdef MSGBOX_TEXTHCENTER - lmargin = MSGBOXEX_MARGIN + ((btnleft - txtrect.right) / 2); -#else - lmargin = MSGBOXEX_MARGIN; -#endif - btnleft = MSGBOXEX_MARGIN; - } - else - { - lmargin = MSGBOXEX_MARGIN; - btnleft = MSGBOXEX_MARGIN + (txtrect.right / 2) - (btnleft / 2); - } - rc.left = lmargin; - } - /* calculate position of the text */ - rc.top = MSGBOXEX_MARGIN + (rc.bottom / 2) - (txtrect.bottom / 2); - rc.top = max(rc.top, MSGBOXEX_MARGIN); - /* calculate position of the buttons */ - btntop = max(rc.top + txtrect.bottom + MSGBOXEX_SPACING, btntop); - for (i = 0; i < mbd.dwButtons; i++) - { - ibtn[i]->x = RESCALE_X(btnleft, units); - ibtn[i]->y = RESCALE_Y(btntop, units); - ibtn[i]->cx = RESCALE_X(btnsize.cx, units); - ibtn[i]->cy = RESCALE_Y(btnsize.cy, units); + ibtn->x = RESCALE_X(btnleft, units); + ibtn->y = RESCALE_Y(btntop, units); + ibtn->cx = RESCALE_X(btnsize.cx, units); + ibtn->cy = RESCALE_Y(btnsize.cy, units); btnleft += btnsize.cx + MSGBOXEX_BUTTONSPACING; } - /* calculate size and position of the messagebox window */ + + /* Calculate the size and position of the messagebox window */ btnleft = max(btnleft - MSGBOXEX_BUTTONSPACING, rc.left + txtrect.right); btnleft += MSGBOXEX_MARGIN; btntop += btnsize.cy + MSGBOXEX_MARGIN; - /* set size and position of the message static */ + + /* Set the size and position of the static message */ itxt->x = RESCALE_X(rc.left, units); itxt->y = RESCALE_Y(rc.top, units); itxt->cx = RESCALE_X(btnleft - rc.left - MSGBOXEX_MARGIN, units); itxt->cy = RESCALE_Y(txtrect.bottom, units); - /* set size of the window */ + + /* Set the size of the window */ tpl->cx = RESCALE_X(btnleft, units); tpl->cy = RESCALE_Y(btntop, units); @@ -791,6 +830,13 @@ MessageBoxTimeoutIndirectW( Quit: RtlFreeHeap(GetProcessHeap(), 0, buf); + + for (i = 0; i < mbd.dwButtons; i++) + { + if (mbd.ppszButtonText[i] && *(mbd.ppszButtonText[i])) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR)mbd.ppszButtonText[i]); + } + return ret; }
6 years, 7 months
1
0
0
0
07/11: [USER32] Get rid of the old MSGBOXINFO structure and use the new internal MSGBOXDATA structure instead.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e3fee2db82c404f536b76…
commit e3fee2db82c404f536b769d5e756c821858f8dde Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Fri Aug 10 21:38:09 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:21 2018 +0200 [USER32] Get rid of the old MSGBOXINFO structure and use the new internal MSGBOXDATA structure instead. --- win32ss/user/user32/windows/messagebox.c | 191 ++++++++++++++----------------- 1 file changed, 87 insertions(+), 104 deletions(-) diff --git a/win32ss/user/user32/windows/messagebox.c b/win32ss/user/user32/windows/messagebox.c index 72a443d25f..6fb379869e 100644 --- a/win32ss/user/user32/windows/messagebox.c +++ b/win32ss/user/user32/windows/messagebox.c @@ -73,9 +73,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32); typedef struct _MSGBTNINFO { - LONG btnCnt; - LONG btnIdx[MSGBOXEX_MAXBTNS]; - UINT btnIds[MSGBOXEX_MAXBTNS]; + DWORD btnCnt; + INT btnIdx[MSGBOXEX_MAXBTNS]; + UINT btnIds[MSGBOXEX_MAXBTNS]; } MSGBTNINFO, *PMSGBTNINFO; /* Default MessageBox buttons */ @@ -97,24 +97,12 @@ static const MSGBTNINFO MsgBtnInfo[] = DECLARE_MB_3(CANCEL, TRYAGAIN, CONTINUE) }; -typedef struct _MSGBOXINFO -{ - MSGBOXPARAMSW; // Wine passes this too. - // ReactOS - HICON Icon; - int DefBtn; - int nButtons; - LONG *Btns; - UINT Timeout; -} MSGBOXINFO, *PMSGBOXINFO; - - /* INTERNAL FUNCTIONS ********************************************************/ static VOID MessageBoxTextToClipboard(HWND DialogWindow) { HWND hwndText; - PMSGBOXINFO mbi; + PMSGBOXDATA mbd; int cchTotal, cchTitle, cchText, cchButton, i, n, cchBuffer; LPWSTR pszBuffer, pszBufferPos, pMessageBoxText, pszTitle, pszText, pszButton; WCHAR szButton[MSGBOXEX_MAXBTNSTR]; @@ -122,12 +110,12 @@ static VOID MessageBoxTextToClipboard(HWND DialogWindow) static const WCHAR szLine[] = L"---------------------------\r\n"; - mbi = (PMSGBOXINFO)GetPropW(DialogWindow, L"ROS_MSGBOX"); + mbd = (PMSGBOXDATA)GetPropW(DialogWindow, L"ROS_MSGBOX"); hwndText = GetDlgItem(DialogWindow, MSGBOX_IDTEXT); cchTitle = GetWindowTextLengthW(DialogWindow) + 1; cchText = GetWindowTextLengthW(hwndText) + 1; - if (!mbi) + if (!mbd) return; pMessageBoxText = (LPWSTR)RtlAllocateHeap(GetProcessHeap(), 0, (cchTitle + cchText) * sizeof(WCHAR)); @@ -151,7 +139,7 @@ static VOID MessageBoxTextToClipboard(HWND DialogWindow) /* * Calculate the total buffer size. */ - cchTotal = 6 + cchTitle + cchText + (lstrlenW(szLine) * 4) + (mbi->nButtons * MSGBOXEX_MAXBTNSTR + 3); + cchTotal = 6 + cchTitle + cchText + (lstrlenW(szLine) * 4) + (mbd->dwButtons * MSGBOXEX_MAXBTNSTR + 3); hGlobal = GlobalAlloc(GHND, cchTotal * sizeof(WCHAR)); @@ -175,9 +163,9 @@ static VOID MessageBoxTextToClipboard(HWND DialogWindow) cchBuffer = wsprintfW(pszBuffer, L"%s%s\r\n%s%s\r\n%s", szLine, pszTitle, szLine, pszText, szLine); pszBufferPos = pszBuffer + cchBuffer; - for (i = 0; i < mbi->nButtons; i++) + for (i = 0; i < mbd->dwButtons; i++) { - GetDlgItemTextW(DialogWindow, mbi->Btns[i], szButton, MSGBOXEX_MAXBTNSTR); + GetDlgItemTextW(DialogWindow, mbd->pidButton[i], szButton, MSGBOXEX_MAXBTNSTR); cchButton = strlenW(szButton); pszButton = szButton; @@ -220,7 +208,7 @@ static INT_PTR CALLBACK MessageBoxProc( WPARAM wParam, LPARAM lParam) { int Alert; - PMSGBOXINFO mbi; + PMSGBOXDATA mbd; HELPINFO hi; HWND hwndOwner; @@ -228,26 +216,26 @@ static INT_PTR CALLBACK MessageBoxProc( { case WM_INITDIALOG: { - mbi = (PMSGBOXINFO)lParam; + mbd = (PMSGBOXDATA)lParam; - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)mbi); + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)mbd); NtUserxSetMessageBox(hwnd); if (!GetPropW(hwnd, L"ROS_MSGBOX")) { SetPropW(hwnd, L"ROS_MSGBOX", (HANDLE)lParam); - if (mbi->dwContextHelpId) - SetWindowContextHelpId(hwnd, mbi->dwContextHelpId); + if (mbd->mbp.dwContextHelpId) + SetWindowContextHelpId(hwnd, mbd->mbp.dwContextHelpId); - if (mbi->Icon) + if (mbd->mbp.lpszIcon) { - SendDlgItemMessageW(hwnd, MSGBOX_IDICON, STM_SETICON, (WPARAM)mbi->Icon, 0); + SendDlgItemMessageW(hwnd, MSGBOX_IDICON, STM_SETICON, (WPARAM)(HICON)mbd->mbp.lpszIcon, 0); Alert = ALERT_SYSTEM_WARNING; } else // Setup the rest of the alerts. { - switch (mbi->dwStyle & MB_ICONMASK) + switch (mbd->mbp.dwStyle & MB_ICONMASK) { case MB_ICONWARNING: Alert = ALERT_SYSTEM_WARNING; @@ -266,16 +254,17 @@ static INT_PTR CALLBACK MessageBoxProc( /* Send out the alert notifications. */ NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_ALERT, Alert); - switch (mbi->dwStyle & MB_TYPEMASK) + switch (mbd->mbp.dwStyle & MB_TYPEMASK) { case MB_ABORTRETRYIGNORE: case MB_YESNO: RemoveMenu(GetSystemMenu(hwnd, FALSE), SC_CLOSE, MF_BYCOMMAND); break; } - SetFocus(GetDlgItem(hwnd, mbi->DefBtn)); - if (mbi->Timeout && (mbi->Timeout != (UINT)-1)) - SetTimer(hwnd, 0, mbi->Timeout, NULL); + ASSERT(mbd->uDefButton < mbd->dwButtons); + SetFocus(GetDlgItem(hwnd, mbd->pidButton[mbd->uDefButton])); + if (mbd->dwTimeout && (mbd->dwTimeout != (UINT)-1)) + SetTimer(hwnd, 0, mbd->dwTimeout, NULL); } return 0; } @@ -313,15 +302,15 @@ static INT_PTR CALLBACK MessageBoxProc( case WM_HELP: { - mbi = (PMSGBOXINFO)GetPropW(hwnd, L"ROS_MSGBOX"); - if (!mbi) + mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); + if (!mbd) return 0; memcpy(&hi, (void *)lParam, sizeof(hi)); hi.dwContextId = GetWindowContextHelpId(hwnd); - if (mbi->lpfnMsgBoxCallback) + if (mbd->mbp.lpfnMsgBoxCallback) { - mbi->lpfnMsgBoxCallback(&hi); + mbd->mbp.lpfnMsgBoxCallback(&hi); } else { @@ -334,10 +323,10 @@ static INT_PTR CALLBACK MessageBoxProc( case WM_CLOSE: { - mbi = (PMSGBOXINFO)GetPropW(hwnd, L"ROS_MSGBOX"); - if (!mbi) + mbd = (PMSGBOXDATA)GetPropW(hwnd, L"ROS_MSGBOX"); + if (!mbd) return 0; - switch (mbi->dwStyle & MB_TYPEMASK) + switch (mbd->mbp.dwStyle & MB_TYPEMASK) { case MB_ABORTRETRYIGNORE: case MB_YESNO: @@ -361,6 +350,7 @@ static int MessageBoxTimeoutIndirectW( CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout) { + MSGBOXDATA mbd; DLGTEMPLATE *tpl; DLGITEMTEMPLATE *iico, *itxt; NONCLIENTMETRICSW nclm; @@ -379,8 +369,41 @@ MessageBoxTimeoutIndirectW( DLGITEMTEMPLATE *ibtn[MSGBOXEX_MAXBTNS]; RECT btnrect, txtrect, rc; SIZE btnsize; - MSGBOXINFO mbi; - BOOL defbtn = FALSE; + + + ZeroMemory(&mbd, sizeof(mbd)); + memcpy(&mbd.mbp, lpMsgBoxParams, sizeof(mbd.mbp)); + lpMsgBoxParams = &mbd.mbp; + + mbd.wLanguageId = (WORD)lpMsgBoxParams->dwLanguageId; // FIXME! + mbd.dwTimeout = dwTimeout; + + /* Create the selected buttons; unknown types will fall back to MB_OK */ + i = (lpMsgBoxParams->dwStyle & MB_TYPEMASK); + if (i >= ARRAYSIZE(MsgBtnInfo)) + i = MB_OK; + + /* Get buttons IDs */ + Buttons = MsgBtnInfo[i]; + + /* Add the Help button */ + if (lpMsgBoxParams->dwStyle & MB_HELP) + { + Buttons.btnIdx[Buttons.btnCnt] = IDHELP; + Buttons.btnIds[Buttons.btnCnt] = IDS_HELP; + Buttons.btnCnt++; + } + + mbd.pidButton = Buttons.btnIdx; + mbd.ppszButtonText = ButtonText; + mbd.dwButtons = Buttons.btnCnt; + + mbd.uDefButton = ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8); + /* Make the first button the default button if none other is */ + if (mbd.uDefButton >= mbd.dwButtons) + mbd.uDefButton = 0; + // mbd.uCancelId; + if (!lpMsgBoxParams->lpszCaption) { @@ -421,22 +444,6 @@ MessageBoxTimeoutIndirectW( textlen = strlenW(text); } - /* Create the selected buttons; unknown types will fall back to MB_OK */ - i = (lpMsgBoxParams->dwStyle & MB_TYPEMASK); - if (i >= ARRAYSIZE(MsgBtnInfo)) - i = MB_OK; - - /* Get buttons IDs */ - Buttons = MsgBtnInfo[i]; - - /* Add the Help button */ - if (lpMsgBoxParams->dwStyle & MB_HELP) - { - Buttons.btnIdx[Buttons.btnCnt] = IDHELP; - Buttons.btnIds[Buttons.btnCnt] = IDS_HELP; - Buttons.btnCnt++; - } - switch (lpMsgBoxParams->dwStyle & MB_ICONMASK) { case MB_ICONEXCLAMATION: // case MB_ICONWARNING: @@ -469,6 +476,9 @@ MessageBoxTimeoutIndirectW( break; } + /* Reuse the internal pointer! */ + ((MSGBOXPARAMSW*)lpMsgBoxParams)->lpszIcon = (LPCWSTR)Icon; + /* Basic space */ bufsize = sizeof(DLGTEMPLATE) + 2 * sizeof(WORD) + /* menu and class */ @@ -490,19 +500,19 @@ MessageBoxTimeoutIndirectW( 3 * sizeof(WORD) + (textlen + 1) * sizeof(WCHAR); - for (i = 0; i < Buttons.btnCnt; i++) + for (i = 0; i < mbd.dwButtons; i++) { /* Get the default text of the buttons */ if (Buttons.btnIds[i]) { ButtonLen[i] = LoadStringW(User32Instance, Buttons.btnIds[i], - (LPWSTR)&ButtonText[i], 0); + (LPWSTR)&mbd.ppszButtonText[i], 0); } else { /* No text, use blank */ - ButtonText[i] = L""; + mbd.ppszButtonText[i] = L""; ButtonLen[i] = 0; } @@ -539,12 +549,11 @@ MessageBoxTimeoutIndirectW( tpl->dwExtendedStyle |= WS_EX_RIGHT; tpl->x = 100; tpl->y = 100; - tpl->cdit = Buttons.btnCnt + (Icon ? 1 : 0) + 1; + tpl->cdit = mbd.dwButtons + (Icon ? 1 : 0) + 1; dest = (BYTE *)(tpl + 1); - *(WORD*)dest = 0; /* no menu */ - *(((WORD*)dest) + 1) = 0; /* use default window class */ + *(DWORD*)dest = 0; /* no menu and use default window class */ dest += 2 * sizeof(WORD); memcpy(dest, caption, caplen * sizeof(WCHAR)); dest += caplen * sizeof(WCHAR); @@ -632,30 +641,29 @@ MessageBoxTimeoutIndirectW( btnsize.cy = BTN_CY; btnrect.left = btnrect.top = 0; - for (i = 0; i < Buttons.btnCnt; i++) + /* Make the first button the default button if none other is */ + if (mbd.uDefButton >= mbd.dwButtons) + mbd.uDefButton = 0; + + for (i = 0; i < mbd.dwButtons; i++) { dest = ALIGN_UP_POINTER(dest, DWORD); ibtn[i] = (DLGITEMTEMPLATE *)dest; ibtn[i]->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP; - if (!defbtn && (i == ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8))) - { + if (i == mbd.uDefButton) ibtn[i]->style |= BS_DEFPUSHBUTTON; - mbi.DefBtn = Buttons.btnIdx[i]; - defbtn = TRUE; - } else - { ibtn[i]->style |= BS_PUSHBUTTON; - } + ibtn[i]->dwExtendedStyle = 0; - ibtn[i]->id = Buttons.btnIdx[i]; + ibtn[i]->id = mbd.pidButton[i]; dest += sizeof(DLGITEMTEMPLATE); *(WORD*)dest = 0xFFFF; dest += sizeof(WORD); *(WORD*)dest = 0x0080; /* button control */ dest += sizeof(WORD); - memcpy(dest, ButtonText[i], ButtonLen[i] * sizeof(WCHAR)); + memcpy(dest, mbd.ppszButtonText[i], ButtonLen[i] * sizeof(WCHAR)); dest += ButtonLen[i] * sizeof(WCHAR); *(WORD*)dest = 0; dest += sizeof(WORD); @@ -663,20 +671,12 @@ MessageBoxTimeoutIndirectW( dest += sizeof(WORD); // btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed?? - DrawTextW(hDC, ButtonText[i], ButtonLen[i], &btnrect, + DrawTextW(hDC, mbd.ppszButtonText[i], ButtonLen[i], &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT); btnsize.cx = max(btnsize.cx, btnrect.right); btnsize.cy = max(btnsize.cy, btnrect.bottom); } - /* make first button the default button if no other is */ - if (!defbtn) - { - ibtn[0]->style &= ~BS_PUSHBUTTON; - ibtn[0]->style |= BS_DEFPUSHBUTTON; - mbi.DefBtn = Buttons.btnIdx[0]; - } - /* calculate position and size of controls */ txtrect.right = GetSystemMetrics(SM_CXSCREEN) / 5 * 4; if (Icon) @@ -716,7 +716,7 @@ MessageBoxTimeoutIndirectW( #else rc.top = MSGBOXEX_MARGIN; #endif - btnleft = (Buttons.btnCnt * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; + btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; if (btnleft > txtrect.right + rc.right + MSGBOXEX_SPACING) { #ifdef MSGBOX_TEXTHCENTER @@ -741,7 +741,7 @@ MessageBoxTimeoutIndirectW( } else { - btnleft = (Buttons.btnCnt * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; + btnleft = (mbd.dwButtons * (btnsize.cx + MSGBOXEX_BUTTONSPACING)) - MSGBOXEX_BUTTONSPACING; if (btnleft > txtrect.right) { #ifdef MSGBOX_TEXTHCENTER @@ -763,7 +763,7 @@ MessageBoxTimeoutIndirectW( rc.top = max(rc.top, MSGBOXEX_MARGIN); /* calculate position of the buttons */ btntop = max(rc.top + txtrect.bottom + MSGBOXEX_SPACING, btntop); - for (i = 0; i < Buttons.btnCnt; i++) + for (i = 0; i < mbd.dwButtons; i++) { ibtn[i]->x = RESCALE_X(btnleft, units); ibtn[i]->y = RESCALE_Y(btntop, units); @@ -785,26 +785,9 @@ MessageBoxTimeoutIndirectW( tpl->cy = RESCALE_Y(btntop, units); /* Finally show the messagebox */ - mbi.Icon = Icon; - mbi.dwContextHelpId = lpMsgBoxParams->dwContextHelpId; - mbi.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback; - mbi.dwStyle = lpMsgBoxParams->dwStyle; - mbi.nButtons = Buttons.btnCnt; - mbi.Btns = Buttons.btnIdx; - mbi.Timeout = dwTimeout; - - /* Pass on to Justin Case so he can peek the message? */ - mbi.cbSize = lpMsgBoxParams->cbSize; - mbi.hwndOwner = lpMsgBoxParams->hwndOwner; - mbi.hInstance = lpMsgBoxParams->hInstance; - mbi.lpszText = lpMsgBoxParams->lpszText; - mbi.lpszCaption = lpMsgBoxParams->lpszCaption; - mbi.lpszIcon = lpMsgBoxParams->lpszIcon; - mbi.dwLanguageId = lpMsgBoxParams->dwLanguageId; - ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, lpMsgBoxParams->hwndOwner, - MessageBoxProc, (LPARAM)&mbi); + MessageBoxProc, (LPARAM)&mbd); Quit: RtlFreeHeap(GetProcessHeap(), 0, buf);
6 years, 7 months
1
0
0
0
06/11: [USER32] Code formatting only.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b55cf703407b45ac2523a…
commit b55cf703407b45ac2523a092ee69c489444290c5 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Fri Aug 10 21:29:45 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:21 2018 +0200 [USER32] Code formatting only. --- win32ss/user/user32/windows/messagebox.c | 143 +++++++++++++++++-------------- 1 file changed, 79 insertions(+), 64 deletions(-) diff --git a/win32ss/user/user32/windows/messagebox.c b/win32ss/user/user32/windows/messagebox.c index db812b1134..72a443d25f 100644 --- a/win32ss/user/user32/windows/messagebox.c +++ b/win32ss/user/user32/windows/messagebox.c @@ -17,10 +17,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* - * * PROJECT: ReactOS user32.dll * FILE: win32ss/user/user32/windows/messagebox.c - * PURPOSE: Input + * PURPOSE: Message Boxes * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net) * Thomas Weidenmueller (w3seek(a)users.sourceforge.net) * UPDATE HISTORY: @@ -109,6 +108,7 @@ typedef struct _MSGBOXINFO UINT Timeout; } MSGBOXINFO, *PMSGBOXINFO; + /* INTERNAL FUNCTIONS ********************************************************/ static VOID MessageBoxTextToClipboard(HWND DialogWindow) @@ -222,7 +222,7 @@ static INT_PTR CALLBACK MessageBoxProc( int Alert; PMSGBOXINFO mbi; HELPINFO hi; - HWND owner; + HWND hwndOwner; switch (message) { @@ -296,7 +296,7 @@ static INT_PTR CALLBACK MessageBoxProc( return 0; case IDHELP: /* send WM_HELP message to messagebox window */ - hi.cbSize = sizeof(HELPINFO); + hi.cbSize = sizeof(hi); hi.iContextType = HELPINFO_WINDOW; hi.iCtrlId = LOWORD(wParam); hi.hItemHandle = (HANDLE)lParam; @@ -320,12 +320,14 @@ static INT_PTR CALLBACK MessageBoxProc( hi.dwContextId = GetWindowContextHelpId(hwnd); if (mbi->lpfnMsgBoxCallback) + { mbi->lpfnMsgBoxCallback(&hi); + } else { - owner = GetWindow(hwnd, GW_OWNER); - if (owner) - SendMessageW(GetWindow(hwnd, GW_OWNER), WM_HELP, 0, (LPARAM)&hi); + hwndOwner = GetWindow(hwnd, GW_OWNER); + if (hwndOwner) + SendMessageW(hwndOwner, WM_HELP, 0, (LPARAM)&hi); } return 0; } @@ -348,7 +350,7 @@ static INT_PTR CALLBACK MessageBoxProc( case WM_TIMER: if (wParam == 0) { - EndDialog(hwnd, 32000); + EndDialog(hwnd, IDTIMEOUT); } return 0; } @@ -357,7 +359,7 @@ static INT_PTR CALLBACK MessageBoxProc( static int MessageBoxTimeoutIndirectW( - CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT Timeout) + CONST MSGBOXPARAMSW *lpMsgBoxParams, UINT dwTimeout) { DLGTEMPLATE *tpl; DLGITEMTEMPLATE *iico, *itxt; @@ -388,7 +390,9 @@ MessageBoxTimeoutIndirectW( else if (IS_INTRESOURCE(lpMsgBoxParams->lpszCaption)) { /* User-defined resource string */ - caplen = LoadStringW(lpMsgBoxParams->hInstance, PtrToUlong(lpMsgBoxParams->lpszCaption), (LPWSTR)&caption, 0); + caplen = LoadStringW(lpMsgBoxParams->hInstance, + PtrToUlong(lpMsgBoxParams->lpszCaption), + (LPWSTR)&caption, 0); } else { @@ -406,7 +410,9 @@ MessageBoxTimeoutIndirectW( else if (IS_INTRESOURCE(lpMsgBoxParams->lpszText)) { /* User-defined resource string */ - textlen = LoadStringW(lpMsgBoxParams->hInstance, PtrToUlong(lpMsgBoxParams->lpszText), (LPWSTR)&text, 0); + textlen = LoadStringW(lpMsgBoxParams->hInstance, + PtrToUlong(lpMsgBoxParams->lpszText), + (LPWSTR)&text, 0); } else { @@ -433,33 +439,34 @@ MessageBoxTimeoutIndirectW( switch (lpMsgBoxParams->dwStyle & MB_ICONMASK) { - case MB_ICONEXCLAMATION: - Icon = LoadIconW(0, IDI_EXCLAMATIONW); - MessageBeep(MB_ICONEXCLAMATION); - break; - case MB_ICONQUESTION: - Icon = LoadIconW(0, IDI_QUESTIONW); - MessageBeep(MB_ICONQUESTION); - break; - case MB_ICONASTERISK: - Icon = LoadIconW(0, IDI_ASTERISKW); - MessageBeep(MB_ICONASTERISK); - break; - case MB_ICONHAND: - Icon = LoadIconW(0, IDI_HANDW); - MessageBeep(MB_ICONHAND); - break; - case MB_USERICON: - Icon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon); - MessageBeep(MB_OK); - break; - default: - /* By default, Windows 95/98/NT does not associate an icon to message boxes. - * So ReactOS should do the same. - */ - Icon = (HICON)0; - MessageBeep(MB_OK); - break; + case MB_ICONEXCLAMATION: // case MB_ICONWARNING: + Icon = LoadIconW(0, IDI_EXCLAMATIONW); + MessageBeep(MB_ICONEXCLAMATION); + break; + case MB_ICONQUESTION: + Icon = LoadIconW(0, IDI_QUESTIONW); + MessageBeep(MB_ICONQUESTION); + break; + case MB_ICONASTERISK: // case MB_ICONINFORMATION: + Icon = LoadIconW(0, IDI_ASTERISKW); + MessageBeep(MB_ICONASTERISK); + break; + case MB_ICONHAND: // case MB_ICONSTOP: case MB_ICONERROR: + Icon = LoadIconW(0, IDI_HANDW); + MessageBeep(MB_ICONHAND); + break; + case MB_USERICON: + Icon = LoadIconW(lpMsgBoxParams->hInstance, lpMsgBoxParams->lpszIcon); + MessageBeep(MB_OK); + break; + default: + /* + * By default, Windows 95/98/NT does not associate an icon + * to message boxes. So ReactOS should do the same. + */ + Icon = NULL; + MessageBeep(MB_OK); + break; } /* Basic space */ @@ -469,16 +476,16 @@ MessageBoxTimeoutIndirectW( sizeof(WORD); /* font height */ /* Space for icon */ - if (NULL != Icon) + if (Icon) { - bufsize = (bufsize + 3) & ~3; - bufsize += sizeof(DLGITEMTEMPLATE) + - 4 * sizeof(WORD) + - sizeof(WCHAR); + bufsize = ALIGN_UP(bufsize, DWORD); + bufsize += sizeof(DLGITEMTEMPLATE) + + 4 * sizeof(WORD) + + sizeof(WCHAR); } /* Space for text */ - bufsize = (bufsize + 3) & ~3; + bufsize = ALIGN_UP(bufsize, DWORD); bufsize += sizeof(DLGITEMTEMPLATE) + 3 * sizeof(WORD) + (textlen + 1) * sizeof(WCHAR); @@ -488,19 +495,22 @@ MessageBoxTimeoutIndirectW( /* Get the default text of the buttons */ if (Buttons.btnIds[i]) { - ButtonLen[i] = LoadStringW(User32Instance, Buttons.btnIds[i], (LPWSTR)&ButtonText[i], 0); + ButtonLen[i] = LoadStringW(User32Instance, + Buttons.btnIds[i], + (LPWSTR)&ButtonText[i], 0); } else { + /* No text, use blank */ ButtonText[i] = L""; - ButtonLen[i] = 0; + ButtonLen[i] = 0; } - /* Space for buttons */ - bufsize = (bufsize + 3) & ~3; - bufsize += sizeof(DLGITEMTEMPLATE) + - 3 * sizeof(WORD) + - (ButtonLen[i] + 1) * sizeof(WCHAR); + /* Space for buttons */ + bufsize = ALIGN_UP(bufsize, DWORD); + bufsize += sizeof(DLGITEMTEMPLATE) + + 3 * sizeof(WORD) + + (ButtonLen[i] + 1) * sizeof(WCHAR); } buf = RtlAllocateHeap(GetProcessHeap(), 0, bufsize); @@ -520,7 +530,8 @@ MessageBoxTimeoutIndirectW( tpl = (DLGTEMPLATE *)buf; - tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | DS_CENTER | DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG; + tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | + DS_CENTER | DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG; tpl->dwExtendedStyle = WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT; if (lpMsgBoxParams->dwStyle & MB_TOPMOST) tpl->dwExtendedStyle |= WS_EX_TOPMOST; @@ -528,7 +539,7 @@ MessageBoxTimeoutIndirectW( tpl->dwExtendedStyle |= WS_EX_RIGHT; tpl->x = 100; tpl->y = 100; - tpl->cdit = Buttons.btnCnt + ((Icon != (HICON)0) ? 1 : 0) + 1; + tpl->cdit = Buttons.btnCnt + (Icon ? 1 : 0) + 1; dest = (BYTE *)(tpl + 1); @@ -550,7 +561,7 @@ MessageBoxTimeoutIndirectW( /* Create icon */ if (Icon) { - dest = (BYTE*)(((ULONG_PTR)dest + 3) & ~3); + dest = ALIGN_UP_POINTER(dest, DWORD); iico = (DLGITEMTEMPLATE *)dest; iico->style = WS_CHILD | WS_VISIBLE | SS_ICON; iico->dwExtendedStyle = 0; @@ -569,8 +580,8 @@ MessageBoxTimeoutIndirectW( dest += sizeof(WORD); } - /* create static for text */ - dest = (BYTE*)(((UINT_PTR)dest + 3) & ~3); + /* Create static for text */ + dest = ALIGN_UP_POINTER(dest, DWORD); itxt = (DLGITEMTEMPLATE *)dest; itxt->style = WS_CHILD | WS_VISIBLE | SS_NOPREFIX; if (lpMsgBoxParams->dwStyle & MB_RIGHT) @@ -616,15 +627,16 @@ MessageBoxTimeoutIndirectW( units.cy = HIWORD(defUnits); } - /* create buttons */ + /* Create buttons */ btnsize.cx = BTN_CX; btnsize.cy = BTN_CY; btnrect.left = btnrect.top = 0; for (i = 0; i < Buttons.btnCnt; i++) { - dest = (BYTE*)(((UINT_PTR)dest + 3) & ~3); + dest = ALIGN_UP_POINTER(dest, DWORD); ibtn[i] = (DLGITEMTEMPLATE *)dest; + ibtn[i]->style = WS_CHILD | WS_VISIBLE | WS_TABSTOP; if (!defbtn && (i == ((lpMsgBoxParams->dwStyle & MB_DEFMASK) >> 8))) { @@ -651,7 +663,8 @@ MessageBoxTimeoutIndirectW( dest += sizeof(WORD); // btnrect.right = btnrect.bottom = 0; // FIXME: Is it needed?? - DrawTextW(hDC, ButtonText[i], ButtonLen[i], &btnrect, DT_LEFT | DT_SINGLELINE | DT_CALCRECT); + DrawTextW(hDC, ButtonText[i], ButtonLen[i], &btnrect, + DT_LEFT | DT_SINGLELINE | DT_CALCRECT); btnsize.cx = max(btnsize.cx, btnrect.right); btnsize.cy = max(btnsize.cy, btnrect.bottom); } @@ -671,7 +684,8 @@ MessageBoxTimeoutIndirectW( txtrect.top = txtrect.left = txtrect.bottom = 0; if (textlen != 0) { - DrawTextW(hDC, text, textlen, &txtrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); + DrawTextW(hDC, text, textlen, &txtrect, + DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); } else { @@ -770,14 +784,14 @@ MessageBoxTimeoutIndirectW( tpl->cx = RESCALE_X(btnleft, units); tpl->cy = RESCALE_Y(btntop, units); - /* finally show the messagebox */ + /* Finally show the messagebox */ mbi.Icon = Icon; mbi.dwContextHelpId = lpMsgBoxParams->dwContextHelpId; mbi.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback; mbi.dwStyle = lpMsgBoxParams->dwStyle; mbi.nButtons = Buttons.btnCnt; mbi.Btns = Buttons.btnIdx; - mbi.Timeout = Timeout; + mbi.Timeout = dwTimeout; /* Pass on to Justin Case so he can peek the message? */ mbi.cbSize = lpMsgBoxParams->cbSize; @@ -788,7 +802,8 @@ MessageBoxTimeoutIndirectW( mbi.lpszIcon = lpMsgBoxParams->lpszIcon; mbi.dwLanguageId = lpMsgBoxParams->dwLanguageId; - ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, lpMsgBoxParams->hwndOwner, + ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, + lpMsgBoxParams->hwndOwner, MessageBoxProc, (LPARAM)&mbi); Quit: @@ -796,8 +811,8 @@ Quit: return ret; } -/* FUNCTIONS *****************************************************************/ +/* FUNCTIONS *****************************************************************/ /* * @implemented
6 years, 7 months
1
0
0
0
05/11: [USER32] Specify the font to be used for the message-box in its dialog template, using DS_SETFONT and a font point size of 0x7FFF, instead of passing a font handle and setting the font of each control manually.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cb77cc707fa8c75296740…
commit cb77cc707fa8c7529674011a7c96116e7a542251 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Fri Aug 10 18:20:53 2018 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:20 2018 +0200 [USER32] Specify the font to be used for the message-box in its dialog template, using DS_SETFONT and a font point size of 0x7FFF, instead of passing a font handle and setting the font of each control manually. Also improve the flags used in the DrawTextW() call for calculating the size to be taken by the message-box text. --- win32ss/user/user32/windows/messagebox.c | 84 ++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/win32ss/user/user32/windows/messagebox.c b/win32ss/user/user32/windows/messagebox.c index 96c39b791c..db812b1134 100644 --- a/win32ss/user/user32/windows/messagebox.c +++ b/win32ss/user/user32/windows/messagebox.c @@ -57,8 +57,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32); #define MSGBOXEX_MAXBTNS (4) /* Rescale logical coordinates */ -#define RESCALE_X(_x, _unit) (((_x) * 4 + LOWORD(_unit) - 1) / LOWORD(_unit)) -#define RESCALE_Y(_y, _unit) (((_y) * 8 + HIWORD(_unit) - 1) / HIWORD(_unit)) +#define RESCALE_X(_x, _units) (((_x) * 4 + (_units).cx - 1) / (_units).cx) +#define RESCALE_Y(_y, _units) (((_y) * 8 + (_units).cy - 1) / (_units).cy) /* MessageBox button helpers */ @@ -103,7 +103,6 @@ typedef struct _MSGBOXINFO MSGBOXPARAMSW; // Wine passes this too. // ReactOS HICON Icon; - HFONT Font; int DefBtn; int nButtons; LONG *Btns; @@ -220,7 +219,7 @@ static INT_PTR CALLBACK MessageBoxProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - int i, Alert; + int Alert; PMSGBOXINFO mbi; HELPINFO hi; HWND owner; @@ -267,12 +266,6 @@ static INT_PTR CALLBACK MessageBoxProc( /* Send out the alert notifications. */ NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_ALERT, Alert); - /* set control fonts */ - SendDlgItemMessageW(hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)mbi->Font, 0); - for (i = 0; i < mbi->nButtons; i++) - { - SendDlgItemMessageW(hwnd, mbi->Btns[i], WM_SETFONT, (WPARAM)mbi->Font, 0); - } switch (mbi->dwStyle & MB_TYPEMASK) { case MB_ABORTRETRYIGNORE: @@ -372,9 +365,11 @@ MessageBoxTimeoutIndirectW( LPVOID buf; BYTE *dest; LPCWSTR caption, text; - HFONT hFont; + HFONT hFont, hOldFont; HICON Icon; + HWND hDCWnd; HDC hDC; + SIZE units; int bufsize, ret, caplen, textlen, i, btnleft, btntop, lmargin; MSGBTNINFO Buttons; LPCWSTR ButtonText[MSGBOXEX_MAXBTNS]; @@ -384,7 +379,6 @@ MessageBoxTimeoutIndirectW( SIZE btnsize; MSGBOXINFO mbi; BOOL defbtn = FALSE; - DWORD units = GetDialogBaseUnits(); if (!lpMsgBoxParams->lpszCaption) { @@ -470,8 +464,9 @@ MessageBoxTimeoutIndirectW( /* Basic space */ bufsize = sizeof(DLGTEMPLATE) + - 2 * sizeof(WORD) + /* menu and class */ - (caplen + 1) * sizeof(WCHAR); /* title */ + 2 * sizeof(WORD) + /* menu and class */ + (caplen + 1) * sizeof(WCHAR) + /* title */ + sizeof(WORD); /* font height */ /* Space for icon */ if (NULL != Icon) @@ -510,18 +505,22 @@ MessageBoxTimeoutIndirectW( buf = RtlAllocateHeap(GetProcessHeap(), 0, bufsize); if (!buf) - { return 0; - } + iico = itxt = NULL; nclm.cbSize = sizeof(nclm); - SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0); + SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0); hFont = CreateFontIndirectW(&nclm.lfMessageFont); + if (!hFont) + { + ERR("Cannot retrieve nclm.lfMessageFont!\n"); + goto Quit; + } tpl = (DLGTEMPLATE *)buf; - tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | DS_CENTER | DS_MODALFRAME | DS_NOIDLEMSG; + tpl->style = WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_SYSMENU | DS_CENTER | DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG; tpl->dwExtendedStyle = WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT; if (lpMsgBoxParams->dwStyle & MB_TOPMOST) tpl->dwExtendedStyle |= WS_EX_TOPMOST; @@ -541,6 +540,13 @@ MessageBoxTimeoutIndirectW( *(WCHAR*)dest = L'\0'; dest += sizeof(WCHAR); + /* + * A font point size (height) of 0x7FFF means that we use + * the message box font (NONCLIENTMETRICSW.lfMessageFont). + */ + *(WORD*)dest = 0x7FFF; + dest += sizeof(WORD); + /* Create icon */ if (Icon) { @@ -585,8 +591,30 @@ MessageBoxTimeoutIndirectW( *(WORD*)dest = 0; dest += sizeof(WORD); - hDC = CreateCompatibleDC(0); - SelectObject(hDC, hFont); + hDCWnd = NULL; + hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); + if (!hDC) + { + /* Retry with the DC of the owner window */ + hDCWnd = lpMsgBoxParams->hwndOwner; + hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE); + } + if (!hDC) + { + ERR("GetDCEx() failed, bail out!\n"); + goto Quit; + } + hOldFont = SelectObject(hDC, hFont); + + units.cx = GdiGetCharDimensions(hDC, NULL, &units.cy); + if (!units.cx) + { + DWORD defUnits; + ERR("GdiGetCharDimensions() failed, falling back to default values!\n"); + defUnits = GetDialogBaseUnits(); + units.cx = LOWORD(defUnits); + units.cy = HIWORD(defUnits); + } /* create buttons */ btnsize.cx = BTN_CX; @@ -643,7 +671,7 @@ MessageBoxTimeoutIndirectW( txtrect.top = txtrect.left = txtrect.bottom = 0; if (textlen != 0) { - DrawTextW(hDC, text, textlen, &txtrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_CALCRECT); + DrawTextW(hDC, text, textlen, &txtrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_EXTERNALLEADING | DT_EDITCONTROL | DT_CALCRECT); } else { @@ -652,8 +680,13 @@ MessageBoxTimeoutIndirectW( } txtrect.right++; - if (hDC) - DeleteDC(hDC); + if (hOldFont) + SelectObject(hDC, hOldFont); + + ReleaseDC(hDCWnd, hDC); + + if (hFont) + DeleteObject(hFont); /* calculate position and size of the icon */ rc.left = rc.bottom = rc.right = 0; @@ -739,7 +772,6 @@ MessageBoxTimeoutIndirectW( /* finally show the messagebox */ mbi.Icon = Icon; - mbi.Font = hFont; mbi.dwContextHelpId = lpMsgBoxParams->dwContextHelpId; mbi.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback; mbi.dwStyle = lpMsgBoxParams->dwStyle; @@ -759,9 +791,7 @@ MessageBoxTimeoutIndirectW( ret = DialogBoxIndirectParamW(lpMsgBoxParams->hInstance, tpl, lpMsgBoxParams->hwndOwner, MessageBoxProc, (LPARAM)&mbi); - if (hFont) - DeleteObject(hFont); - +Quit: RtlFreeHeap(GetProcessHeap(), 0, buf); return ret; }
6 years, 7 months
1
0
0
0
04/11: [SDK][UNDOCUSER] Add undocumented user32.dll SoftModalMessageBox() definition and its structure MSGBOXDATA.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed1de7184c2992932a638…
commit ed1de7184c2992932a63842bf042d2e08a4d0000 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Tue Feb 20 23:07:11 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Fri Aug 17 17:12:20 2018 +0200 [SDK][UNDOCUSER] Add undocumented user32.dll SoftModalMessageBox() definition and its structure MSGBOXDATA. Documented on
http://www.vbforums.com/showthread.php?840593-Message-Box-with-Four-Buttons
and augmented from my own testings. In addition, add also MessageBoxTimeoutA/W() and MB_GetString(). --- sdk/include/reactos/undocuser.h | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/sdk/include/reactos/undocuser.h b/sdk/include/reactos/undocuser.h index f130e6b1a9..7001e985f0 100644 --- a/sdk/include/reactos/undocuser.h +++ b/sdk/include/reactos/undocuser.h @@ -216,6 +216,83 @@ typedef struct _BALLOON_HARD_ERROR_DATA ULONG_PTR MessageOffset; } BALLOON_HARD_ERROR_DATA, *PBALLOON_HARD_ERROR_DATA; +// +// Undocumented SoftModalMessageBox() API, which constitutes +// the basis of all implementations of the MessageBox*() APIs. +// +typedef struct _MSGBOXDATA +{ + MSGBOXPARAMSW mbp; // Size: 0x28 (on x86), 0x50 (on x64) + HWND hwndOwner; +#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ + DWORD dwPadding; +#endif + WORD wLanguageId; + INT* pidButton; // Array of button IDs + LPCWSTR* ppszButtonText; // Array of button text strings + DWORD dwButtons; // Number of buttons + UINT uDefButton; // Default button ID + UINT uCancelId; // Button ID for Cancel action +#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP) /* (NTDDI_VERSION >= NTDDI_WINXP) */ + DWORD dwTimeout; // Message box timeout +#endif + DWORD dwReserved0; +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ + DWORD dwReserved[4]; +#endif +} MSGBOXDATA, *PMSGBOXDATA, *LPMSGBOXDATA; + +#if defined(_WIN64) + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x98); +#elif (_WIN32_WINNT <= _WIN32_WINNT_WS03) /* (NTDDI_VERSION <= NTDDI_WS03) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x88); +#endif + +#else + +#if (_WIN32_WINNT <= _WIN32_WINNT_WIN2K) /* (NTDDI_VERSION <= NTDDI_WIN2KSP4) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x48); +#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN7) /* (NTDDI_VERSION >= NTDDI_WIN7) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x60); +#else // (_WIN32_WINNT == _WIN32_WINNT_WINXP || _WIN32_WINNT == _WIN32_WINNT_WS03) /* (NTDDI_VERSION == NTDDI_WS03) */ +C_ASSERT(sizeof(MSGBOXDATA) == 0x4C); +#endif + +#endif /* defined(_WIN64) */ + +int WINAPI SoftModalMessageBox(IN LPMSGBOXDATA lpMsgBoxData); + +int +WINAPI +MessageBoxTimeoutA( + IN HWND hWnd, + IN LPCSTR lpText, + IN LPCSTR lpCaption, + IN UINT uType, + IN WORD wLanguageId, + IN DWORD dwTimeout); + +int +WINAPI +MessageBoxTimeoutW( + IN HWND hWnd, + IN LPCWSTR lpText, + IN LPCWSTR lpCaption, + IN UINT uType, + IN WORD wLanguageId, + IN DWORD dwTimeout); + +#ifdef UNICODE +#define MessageBoxTimeout MessageBoxTimeoutW +#else +#define MessageBoxTimeout MessageBoxTimeoutA +#endif + +LPCWSTR WINAPI MB_GetString(IN UINT wBtn); + + // // User api hook //
6 years, 7 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
31
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Results per page:
10
25
50
100
200