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
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
September 2023
----- 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
23 participants
113 discussions
Start a n
N
ew thread
[reactos] 01/01: [WINHTTP_WINETEST] Skip wine_dbgstr_wn() call when returned text length is zero (#5656)
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9ce81f648517263cbc5a8…
commit 9ce81f648517263cbc5a83883354c8589a3474c6 Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Wed Sep 6 16:02:48 2023 -0500 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Sep 7 00:02:48 2023 +0300 [WINHTTP_WINETEST] Skip wine_dbgstr_wn() call when returned text length is zero (#5656) On receiving a zero length response, do not try to print returned text using wine_dbgstr_wn(). Instead check the returned string for zero length and skip the print in that case. ROSTESTS-377 --- modules/rostests/winetests/winhttp/winhttp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/rostests/winetests/winhttp/winhttp.c b/modules/rostests/winetests/winhttp/winhttp.c index 776ee53e379..5655432f73b 100644 --- a/modules/rostests/winetests/winhttp/winhttp.c +++ b/modules/rostests/winetests/winhttp/winhttp.c @@ -4276,7 +4276,12 @@ static void test_IWinHttpRequest(int port) hr = IWinHttpRequest_get_ResponseText( req, &response ); ok( hr == S_OK, "got %08x\n", hr ); +#ifdef __REACTOS__ + ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", + wine_dbgstr_wn(response, min(SysStringLen(response), 32)) ); +#else ok( !memcmp(response, data_start, sizeof(data_start)), "got %s\n", wine_dbgstr_wn(response, 32) ); +#endif SysFreeString( response ); IWinHttpRequest_Release( req );
1 year, 3 months
1
0
0
0
[reactos] 01/01: [NTOSKRNL] Mute some good-path log-spam, no functional change
by Joachim Henze
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=195c491880c6e6e9cd7d4…
commit 195c491880c6e6e9cd7d4669c1242da1f3836bda Author: Joachim Henze <Joachim.Henze(a)reactos.org> AuthorDate: Wed Sep 6 14:53:53 2023 +0200 Commit: Joachim Henze <Joachim.Henze(a)reactos.org> CommitDate: Wed Sep 6 14:53:53 2023 +0200 [NTOSKRNL] Mute some good-path log-spam, no functional change Now that the Memory Management is a bit more under control again, and branching releases/0.4.15 is near, do mute some frequent log-spam that got introduced during 0.4.15-dev'ing regarding lazy-flushes and MM balancing. It frequently logged even while being idle. Slightly improve the headers of the two touched files. No rocket-science. --- ntoskrnl/config/cmlazy.c | 11 +++++------ ntoskrnl/mm/balance.c | 14 ++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ntoskrnl/config/cmlazy.c b/ntoskrnl/config/cmlazy.c index 13b74570b00..ed03247a8c7 100644 --- a/ntoskrnl/config/cmlazy.c +++ b/ntoskrnl/config/cmlazy.c @@ -1,15 +1,14 @@ /* - * PROJECT: ReactOS Kernel - * LICENSE: GPL - See COPYING in the top level directory - * FILE: ntoskrnl/config/cmlazy.c - * PURPOSE: Configuration Manager - Internal Registry APIs - * PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org) + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Configuration Manager - Internal Registry APIs + * PROGRAMMERS: Alex Ionescu <alex.ionescu(a)reactos.org> */ /* INCLUDES *******************************************************************/ #include "ntoskrnl.h" -//#define NDEBUG +#define NDEBUG #include "debug.h" /* GLOBALS ********************************************************************/ diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c index f33189dc247..3b11aeab2c8 100644 --- a/ntoskrnl/mm/balance.c +++ b/ntoskrnl/mm/balance.c @@ -1,11 +1,9 @@ /* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/mm/balance.c - * PURPOSE: kernel memory management functions - * - * PROGRAMMERS: David Welch (welch(a)cwcom.net) - * Cameron Gutman (cameron.gutman(a)reactos.org) + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: kernel memory management functions + * PROGRAMMERS: David Welch <welch(a)cwcom.net> + * Cameron Gutman <cameron.gutman(a)reactos.org> */ /* INCLUDES *****************************************************************/ @@ -144,7 +142,7 @@ MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages) (*NrFreedPages) = 0; - DPRINT1("MM BALANCER: %s\n", Priority ? "Paging out!" : "Removing access bit!"); + DPRINT("MM BALANCER: %s\n", Priority ? "Paging out!" : "Removing access bit!"); FirstPage = MmGetLRUFirstUserPage(); CurrentPage = FirstPage;
1 year, 3 months
1
0
0
0
[reactos] 01/01: [TIMEDATE] Fix the way the current time-zone is found in the list. (#5649)
by Hermès BÉLUSCA - MAÏTO
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d9cd76017336c2bc9d535…
commit d9cd76017336c2bc9d535807f56e5e80f7ac0d87 Author: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> AuthorDate: Wed Sep 6 14:15:33 2023 +0200 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Sep 6 14:15:33 2023 +0200 [TIMEDATE] Fix the way the current time-zone is found in the list. (#5649) fies regression CORE-18666 'Wrong timezone saved/displayed' which was introduced by 0.4.14-dev-1522-g aa69236646f01a476377ec76ae7b762e061cd300 --- dll/cpl/timedate/timezone.c | 65 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/dll/cpl/timedate/timezone.c b/dll/cpl/timedate/timezone.c index dcc8fab661a..8d1d94191fa 100644 --- a/dll/cpl/timedate/timezone.c +++ b/dll/cpl/timedate/timezone.c @@ -168,36 +168,51 @@ ShowTimeZoneList(HWND hwnd) { TIME_ZONE_INFORMATION TimeZoneInfo; PTIMEZONE_ENTRY Entry; - BOOL bDoAdvancedTest; - DWORD dwIndex; - DWORD i; + DWORD dwCount; + DWORD dwIndex = 0; + BOOL bFound = FALSE; - GetTimeZoneInformation(&TimeZoneInfo); - bDoAdvancedTest = (!*TimeZoneInfo.StandardName); + if (GetTimeZoneInformation(&TimeZoneInfo) == TIME_ZONE_ID_INVALID) + { + /* Failed to retrieve current time-zone info, reset it */ + ZeroMemory(&TimeZoneInfo, sizeof(TimeZoneInfo)); + } - dwIndex = 0; - i = 0; - Entry = TimeZoneListHead; - while (Entry != NULL) + for (Entry = TimeZoneListHead; Entry != NULL; Entry = Entry->Next) { - SendMessageW(hwnd, - CB_ADDSTRING, - 0, - (LPARAM)Entry->Description); - - if ( (!bDoAdvancedTest && *Entry->StandardName && - wcscmp(Entry->StandardName, TimeZoneInfo.StandardName) == 0) || - ( (Entry->TimezoneInfo.Bias == TimeZoneInfo.Bias) && - (Entry->TimezoneInfo.StandardBias == TimeZoneInfo.StandardBias) && - (Entry->TimezoneInfo.DaylightBias == TimeZoneInfo.DaylightBias) && - (memcmp(&Entry->TimezoneInfo.StandardDate, &TimeZoneInfo.StandardDate, sizeof(SYSTEMTIME)) == 0) && - (memcmp(&Entry->TimezoneInfo.DaylightDate, &TimeZoneInfo.DaylightDate, sizeof(SYSTEMTIME)) == 0) ) ) + dwCount = SendMessageW(hwnd, + CB_ADDSTRING, + 0, + (LPARAM)Entry->Description); + if (dwCount == CB_ERR || dwCount == CB_ERRSPACE) + continue; + + /* If the time-zone was found in the list, skip the tests */ + if (bFound) + continue; + + if (*TimeZoneInfo.StandardName && *Entry->StandardName) { - dwIndex = i; + /* Compare by name */ + if (wcscmp(Entry->StandardName, TimeZoneInfo.StandardName) == 0) + { + dwIndex = dwCount; + bFound = TRUE; + } + } + else + { + /* Compare by date and bias */ + if ((Entry->TimezoneInfo.Bias == TimeZoneInfo.Bias) && + (Entry->TimezoneInfo.StandardBias == TimeZoneInfo.StandardBias) && + (Entry->TimezoneInfo.DaylightBias == TimeZoneInfo.DaylightBias) && + (memcmp(&Entry->TimezoneInfo.StandardDate, &TimeZoneInfo.StandardDate, sizeof(SYSTEMTIME)) == 0) && + (memcmp(&Entry->TimezoneInfo.DaylightDate, &TimeZoneInfo.DaylightDate, sizeof(SYSTEMTIME)) == 0)) + { + dwIndex = dwCount; + bFound = TRUE; + } } - - i++; - Entry = Entry->Next; } SendMessageW(hwnd,
1 year, 3 months
1
0
0
0
[reactos] 01/01: [NTOS:CC][NTOS:MM] Add back CcRosTrimCache and add Delay for MM to work. (#5630)
by Doug Lyons
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2b14056600bae80532f7a…
commit 2b14056600bae80532f7ab9320fdc0853a55e30a Author: Doug Lyons <douglyons(a)douglyons.com> AuthorDate: Wed Sep 6 06:34:25 2023 -0500 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Sep 6 13:34:25 2023 +0200 [NTOS:CC][NTOS:MM] Add back CcRosTrimCache and add Delay for MM to work. (#5630) MM/CC Add back CcRosTrimCache as suggested by Thomas Faber which was removed in 0.4.15-dev-1717-g d8cdb89fb03006595dc40ac23db5267b8d9d9c09 and call it once in a while also during read-operations. fixes JIRA issue: CORE-17624 'Cannot copy files > RAMsize anymore using TotalCommander' 1st testbot results on top of 0.4.15-dev-6526-g8d35887 VBox:
https://reactos.org/testman/compare.php?ids=89111,89120
(additional random reboot in winhttp:winhttp) KVM:
https://reactos.org/testman/compare.php?ids=89110,89119
We do assume that reboot to be unrelated. 2nd testbot results on top of 0.4.15-dev-6526-g8d35887 VBox:
https://reactos.org/testman/compare.php?ids=89111,89232
KVM:
https://reactos.org/testman/compare.php?ids=89110,89233
--- ntoskrnl/cc/view.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ ntoskrnl/mm/balance.c | 23 ++++++++++ 2 files changed, 141 insertions(+) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index 0e6917ea18a..efa4c8523d4 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -449,6 +449,124 @@ CcRosFlushDirtyPages ( return STATUS_SUCCESS; } +VOID +CcRosTrimCache( + _In_ ULONG Target, + _Out_ PULONG NrFreed) +/* + * FUNCTION: Try to free some memory from the file cache. + * ARGUMENTS: + * Target - The number of pages to be freed. + * NrFreed - Points to a variable where the number of pages + * actually freed is returned. + */ +{ + PLIST_ENTRY current_entry; + PROS_VACB current; + ULONG PagesFreed; + KIRQL oldIrql; + LIST_ENTRY FreeList; + PFN_NUMBER Page; + ULONG i; + BOOLEAN FlushedPages = FALSE; + + DPRINT("CcRosTrimCache(Target %lu)\n", Target); + + InitializeListHead(&FreeList); + + *NrFreed = 0; + +retry: + oldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock); + + current_entry = VacbLruListHead.Flink; + while (current_entry != &VacbLruListHead) + { + ULONG Refs; + + current = CONTAINING_RECORD(current_entry, + ROS_VACB, + VacbLruListEntry); + current_entry = current_entry->Flink; + + KeAcquireSpinLockAtDpcLevel(¤t->SharedCacheMap->CacheMapLock); + + /* Reference the VACB */ + CcRosVacbIncRefCount(current); + + /* Check if it's mapped and not dirty */ + if (InterlockedCompareExchange((PLONG)¤t->MappedCount, 0, 0) > 0 && !current->Dirty) + { + /* Page out the VACB */ + for (i = 0; i < VACB_MAPPING_GRANULARITY / PAGE_SIZE; i++) + { + Page = (PFN_NUMBER)(MmGetPhysicalAddress((PUCHAR)current->BaseAddress + (i * PAGE_SIZE)).QuadPart >> PAGE_SHIFT); + + MmPageOutPhysicalAddress(Page); + } + } + + /* Dereference the VACB */ + Refs = CcRosVacbDecRefCount(current); + + /* Check if we can free this entry now */ + if (Refs < 2) + { + ASSERT(!current->Dirty); + ASSERT(!current->MappedCount); + ASSERT(Refs == 1); + + RemoveEntryList(¤t->CacheMapVacbListEntry); + RemoveEntryList(¤t->VacbLruListEntry); + InitializeListHead(¤t->VacbLruListEntry); + InsertHeadList(&FreeList, ¤t->CacheMapVacbListEntry); + + /* Calculate how many pages we freed for Mm */ + PagesFreed = min(VACB_MAPPING_GRANULARITY / PAGE_SIZE, Target); + Target -= PagesFreed; + (*NrFreed) += PagesFreed; + } + + KeReleaseSpinLockFromDpcLevel(¤t->SharedCacheMap->CacheMapLock); + } + + KeReleaseQueuedSpinLock(LockQueueMasterLock, oldIrql); + + /* Try flushing pages if we haven't met our target */ + if ((Target > 0) && !FlushedPages) + { + /* Flush dirty pages to disk */ + CcRosFlushDirtyPages(Target, &PagesFreed, FALSE, FALSE); + FlushedPages = TRUE; + + /* We can only swap as many pages as we flushed */ + if (PagesFreed < Target) Target = PagesFreed; + + /* Check if we flushed anything */ + if (PagesFreed != 0) + { + /* Try again after flushing dirty pages */ + DPRINT("Flushed %lu dirty cache pages to disk\n", PagesFreed); + goto retry; + } + } + + while (!IsListEmpty(&FreeList)) + { + ULONG Refs; + + current_entry = RemoveHeadList(&FreeList); + current = CONTAINING_RECORD(current_entry, + ROS_VACB, + CacheMapVacbListEntry); + InitializeListHead(¤t->CacheMapVacbListEntry); + Refs = CcRosVacbDecRefCount(current); + ASSERT(Refs == 0); + } + + DPRINT("Evicted %lu cache pages\n", (*NrFreed)); +} + NTSTATUS CcRosReleaseVacb ( PROS_SHARED_CACHE_MAP SharedCacheMap, diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c index ab71d0f195b..f33189dc247 100644 --- a/ntoskrnl/mm/balance.c +++ b/ntoskrnl/mm/balance.c @@ -316,6 +316,15 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, PPFN_NUMBER AllocatedPage) { PFN_NUMBER Page; + static INT i = 0; + static LARGE_INTEGER TinyTime = {{-1L, -1L}}; + + /* Delay some requests for the Memory Manager to recover pages */ + if (i++ >= 100) + { + KeDelayExecutionThread(KernelMode, FALSE, &TinyTime); + i = 0; + } /* * Actually allocate the page. @@ -335,6 +344,10 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, return(STATUS_SUCCESS); } +VOID +CcRosTrimCache( + _In_ ULONG Target, + _Out_ PULONG NrFreed); VOID NTAPI MiBalancerThread(PVOID Unused) @@ -361,6 +374,8 @@ MiBalancerThread(PVOID Unused) if (Status == STATUS_WAIT_0 || Status == STATUS_WAIT_1) { ULONG InitialTarget = 0; + ULONG Target; + ULONG NrFreedPages; do { @@ -372,6 +387,14 @@ MiBalancerThread(PVOID Unused) InitialTarget = MiTrimMemoryConsumer(i, InitialTarget); } + /* Trim cache */ + Target = max(InitialTarget, abs(MiMinimumAvailablePages - MmAvailablePages)); + if (Target) + { + CcRosTrimCache(Target, &NrFreedPages); + InitialTarget -= min(NrFreedPages, InitialTarget); + } + /* No pages left to swap! */ if (InitialTarget != 0 && InitialTarget == OldTarget)
1 year, 3 months
1
0
0
0
[reactos] 01/01: [NOTEPAD] Do type cast to kill C4244 warnings (#5655)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=289dec6c391401b504e44…
commit 289dec6c391401b504e4494a3c7548d3b59af697 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Wed Sep 6 19:26:23 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Sep 6 19:26:23 2023 +0900 [NOTEPAD] Do type cast to kill C4244 warnings (#5655) - Do type cast to int from SendMessage return value. - Fix usage of EM_GETSEL and EM_LINEINDEX messages. CORE-18837 --- base/applications/notepad/dialog.c | 11 +++++++++-- base/applications/notepad/main.c | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index 846a9abac57..111d0428a1d 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -865,6 +865,10 @@ VOID DIALOG_GoTo(VOID) else ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0); + /* EM_LINEINDEX can return -1 on failure */ + if (ich < 0) + ich = 0; + /* Move the caret */ SendMessage(Globals.hEdit, EM_SETSEL, ich, ich); SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0); @@ -872,13 +876,16 @@ VOID DIALOG_GoTo(VOID) VOID DIALOG_StatusBarUpdateCaretPos(VOID) { - int line, col; + int line, ich, col; TCHAR buff[MAX_PATH]; DWORD dwStart, dwSize; SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize); line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0); - col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0); + ich = (int)SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0); + + /* EM_LINEINDEX can return -1 on failure */ + col = ((ich < 0) ? 0 : (dwStart - ich)); StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1); SendMessage(Globals.hStatusBar, SB_SETTEXT, SBPART_CURPOS, (LPARAM)buff); diff --git a/base/applications/notepad/main.c b/base/applications/notepad/main.c index a6477bfefd6..599ad5c60df 100644 --- a/base/applications/notepad/main.c +++ b/base/applications/notepad/main.c @@ -270,6 +270,7 @@ static VOID NOTEPAD_InitData(HINSTANCE hInstance) */ static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index) { + DWORD dwStart, dwEnd; int enable; UNREFERENCED_PARAMETER(index); @@ -280,8 +281,8 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index) SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, CMD_PASTE, IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED); - enable = (int) SendMessage(Globals.hEdit, EM_GETSEL, 0, 0); - enable = (HIWORD(enable) == LOWORD(enable)) ? MF_GRAYED : MF_ENABLED; + SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); + enable = ((dwStart == dwEnd) ? MF_GRAYED : MF_ENABLED); EnableMenuItem(menu, CMD_CUT, enable); EnableMenuItem(menu, CMD_COPY, enable); EnableMenuItem(menu, CMD_DELETE, enable);
1 year, 3 months
1
0
0
0
[reactos] 01/01: [MSVCRT] Officially implement _localtime32{, _s} (#5652)
by William Kent
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=94e0c54c7dfc73aa03a6e…
commit 94e0c54c7dfc73aa03a6e80be37e6a3fd25ec2e7 Author: William Kent <wjk011(a)gmail.com> AuthorDate: Wed Sep 6 06:04:05 2023 -0400 Commit: GitHub <noreply(a)github.com> CommitDate: Wed Sep 6 12:04:05 2023 +0200 [MSVCRT] Officially implement _localtime32{,_s} (#5652) required by the guest additions of an app called "UTM", which is a QEMU fork --- dll/apisets/api-ms-win-crt-time-l1-1-0.spec | 8 ++++---- dll/win32/msvcrt/msvcrt.spec | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dll/apisets/api-ms-win-crt-time-l1-1-0.spec b/dll/apisets/api-ms-win-crt-time-l1-1-0.spec index db0fe40f724..6b571be4c03 100644 --- a/dll/apisets/api-ms-win-crt-time-l1-1-0.spec +++ b/dll/apisets/api-ms-win-crt-time-l1-1-0.spec @@ -34,10 +34,10 @@ @ stub _gmtime32_s @ stdcall _gmtime64() msvcrt._gmtime64 @ stub _gmtime64_s -@ stub _localtime32 -@ stub _localtime32_s -@ stdcall _localtime64() msvcrt._localtime64 -@ stub _localtime64_s +@ cdecl -version=0x600+ _localtime32() msvcrt._localtime32 +@ cdecl -version=0x600+ _localtime32_s() msvcrt._localtime32_s +@ cdecl _localtime64() msvcrt._localtime64 +@ cdecl -version=0x600+ _localtime64_s() msvcrt._localtime64_s @ stub _mkgmtime32 @ stdcall _mkgmtime64() msvcrt._mkgmtime64 @ stub _mktime32 diff --git a/dll/win32/msvcrt/msvcrt.spec b/dll/win32/msvcrt/msvcrt.spec index 0d5ab41eeee..e80a290e2fd 100644 --- a/dll/win32/msvcrt/msvcrt.spec +++ b/dll/win32/msvcrt/msvcrt.spec @@ -710,8 +710,8 @@ @ cdecl -arch=x86_64 _local_unwind(ptr ptr) @ cdecl -arch=i386 _local_unwind2(ptr long) @ cdecl -arch=i386 -version=0x600+ _local_unwind4(ptr ptr long) -@ stub -version=0x600+ _localtime32 -@ stub -version=0x600+ _localtime32_s +@ cdecl -version=0x600+ _localtime32(ptr) +@ cdecl -version=0x600+ _localtime32_s(ptr ptr) @ cdecl _localtime64(ptr) @ cdecl -version=0x600+ _localtime64_s(ptr ptr) @ cdecl _lock(long)
1 year, 3 months
1
0
0
0
[reactos] 01/01: [NOTEPAD] Use StringCchPrintf instead (#5654)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3f921d1119b295de31ee0…
commit 3f921d1119b295de31ee095dceaa62d6ce54ae69 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Sep 5 22:36:18 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Sep 5 22:36:18 2023 +0900 [NOTEPAD] Use StringCchPrintf instead (#5654) Use preferred string functions. CORE-18837 --- base/applications/notepad/dialog.c | 4 ++-- base/applications/notepad/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index 78dbd467f37..846a9abac57 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -164,7 +164,7 @@ int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFl /* Load and format szMessage */ LoadString(Globals.hInstance, formatId, szResource, _countof(szResource)); - _sntprintf(szMessage, _countof(szMessage), szResource, szString); + StringCchPrintf(szMessage, _countof(szMessage), szResource, szString); /* Load szCaption */ if ((dwFlags & MB_ICONMASK) == MB_ICONEXCLAMATION) @@ -880,7 +880,7 @@ VOID DIALOG_StatusBarUpdateCaretPos(VOID) line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0); col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0); - _stprintf(buff, Globals.szStatusBarLineCol, line + 1, col + 1); + StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1); SendMessage(Globals.hStatusBar, SB_SETTEXT, SBPART_CURPOS, (LPARAM)buff); } diff --git a/base/applications/notepad/main.c b/base/applications/notepad/main.c index c232bfbf3e7..a6477bfefd6 100644 --- a/base/applications/notepad/main.c +++ b/base/applications/notepad/main.c @@ -202,7 +202,7 @@ BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert) if (bShowAlert) { LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, _countof(szResource)); - _sntprintf(szText, _countof(szText), szResource, pFindReplace->lpstrFindWhat); + StringCchPrintf(szText, _countof(szText), szResource, pFindReplace->lpstrFindWhat); LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource)); MessageBox(Globals.hFindReplaceDlg, szText, szResource, MB_OK); }
1 year, 3 months
1
0
0
0
[reactos] 01/01: [ATL] atlimage.h: Replace throw() with noexcept
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb6561bbc703a883c0a59…
commit eb6561bbc703a883c0a59abf3407992fc2fb3e1f Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Sep 5 09:12:01 2023 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Sep 5 09:12:01 2023 +0900 [ATL] atlimage.h: Replace throw() with noexcept throw() is deprecated in C++17. CORE-19008 --- sdk/lib/atl/atlimage.h | 148 ++++++++++++++++++++++++------------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/sdk/lib/atl/atlimage.h b/sdk/lib/atl/atlimage.h index c77c4dbc67b..a8546b085c0 100644 --- a/sdk/lib/atl/atlimage.h +++ b/sdk/lib/atl/atlimage.h @@ -37,7 +37,7 @@ public: DIBOR_TOPDOWN // top-down DIB }; - CImage() throw() + CImage() noexcept { m_hBitmap = NULL; m_hOldBitmap = NULL; @@ -52,13 +52,13 @@ public: s_gdiplus.IncreaseCImageCount(); } - virtual ~CImage() throw() + virtual ~CImage() noexcept { Destroy(); s_gdiplus.DecreaseCImageCount(); } - operator HBITMAP() throw() + operator HBITMAP() noexcept { return m_hBitmap; } @@ -68,12 +68,12 @@ public: s_gdiplus.ReleaseGDIPlus(); } - void Attach(HBITMAP hBitmap, DIBOrientation eOrientation = DIBOR_DEFAULT) throw() + void Attach(HBITMAP hBitmap, DIBOrientation eOrientation = DIBOR_DEFAULT) noexcept { AttachInternal(hBitmap, eOrientation, -1); } - HBITMAP Detach() throw() + HBITMAP Detach() noexcept { m_eOrientation = DIBOR_DEFAULT; m_bHasAlphaChannel = false; @@ -85,7 +85,7 @@ public: return hBitmap; } - HDC GetDC() const throw() + HDC GetDC() const noexcept { ATLASSERT(m_nDCRefCount >= 0); if (::InterlockedIncrement(&m_nDCRefCount) == 1) @@ -103,7 +103,7 @@ public: return m_hDC; } - void ReleaseDC() const throw() + void ReleaseDC() const noexcept { ATLASSERT(m_nDCRefCount > 0); @@ -170,7 +170,7 @@ public: BOOL BitBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, - int xSrc, int ySrc, DWORD dwROP = SRCCOPY) const throw() + int xSrc, int ySrc, DWORD dwROP = SRCCOPY) const noexcept { GetDC(); BOOL ret = ::BitBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight, @@ -179,18 +179,18 @@ public: return ret; } BOOL BitBlt(HDC hDestDC, int xDest, int yDest, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return BitBlt(hDestDC, xDest, yDest, GetWidth(), GetHeight(), 0, 0, dwROP); } BOOL BitBlt(HDC hDestDC, const POINT& pointDest, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return BitBlt(hDestDC, pointDest.x, pointDest.y, dwROP); } BOOL BitBlt(HDC hDestDC, const RECT& rectDest, const POINT& pointSrc, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return BitBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, @@ -198,18 +198,18 @@ public: pointSrc.x, pointSrc.y, dwROP); } - BOOL Create(int nWidth, int nHeight, int nBPP, DWORD dwFlags = 0) throw() + BOOL Create(int nWidth, int nHeight, int nBPP, DWORD dwFlags = 0) noexcept { return CreateEx(nWidth, nHeight, nBPP, BI_RGB, NULL, dwFlags); } BOOL CreateEx(int nWidth, int nHeight, int nBPP, DWORD eCompression, - const DWORD* pdwBitmasks = NULL, DWORD dwFlags = 0) throw() + const DWORD* pdwBitmasks = NULL, DWORD dwFlags = 0) noexcept { return CreateInternal(nWidth, nHeight, nBPP, eCompression, pdwBitmasks, dwFlags); } - void Destroy() throw() + void Destroy() noexcept { if (m_hBitmap) { @@ -218,7 +218,7 @@ public: } BOOL Draw(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, - int xSrc, int ySrc, int nSrcWidth, int nSrcHeight) const throw() + int xSrc, int ySrc, int nSrcWidth, int nSrcHeight) const noexcept { ATLASSERT(IsTransparencySupported()); if (m_bHasAlphaChannel) @@ -242,7 +242,7 @@ public: xSrc, ySrc, nSrcWidth, nSrcHeight); } } - BOOL Draw(HDC hDestDC, const RECT& rectDest, const RECT& rectSrc) const throw() + BOOL Draw(HDC hDestDC, const RECT& rectDest, const RECT& rectSrc) const noexcept { return Draw(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, @@ -251,28 +251,28 @@ public: rectSrc.right - rectSrc.left, rectSrc.bottom - rectSrc.top); } - BOOL Draw(HDC hDestDC, int xDest, int yDest) const throw() + BOOL Draw(HDC hDestDC, int xDest, int yDest) const noexcept { return Draw(hDestDC, xDest, yDest, GetWidth(), GetHeight()); } - BOOL Draw(HDC hDestDC, const POINT& pointDest) const throw() + BOOL Draw(HDC hDestDC, const POINT& pointDest) const noexcept { return Draw(hDestDC, pointDest.x, pointDest.y); } BOOL Draw(HDC hDestDC, int xDest, int yDest, - int nDestWidth, int nDestHeight) const throw() + int nDestWidth, int nDestHeight) const noexcept { return Draw(hDestDC, xDest, yDest, nDestWidth, nDestHeight, 0, 0, GetWidth(), GetHeight()); } - BOOL Draw(HDC hDestDC, const RECT& rectDest) const throw() + BOOL Draw(HDC hDestDC, const RECT& rectDest) const noexcept { return Draw(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, rectDest.bottom - rectDest.top); } - void *GetBits() throw() + void *GetBits() noexcept { ATLASSERT(IsDIBSection()); BYTE *pb = (BYTE *)m_bm.bmBits; @@ -283,14 +283,14 @@ public: return pb; } - int GetBPP() const throw() + int GetBPP() const noexcept { ATLASSERT(m_hBitmap); return m_bm.bmBitsPixel; } void GetColorTable(UINT iFirstColor, UINT nColors, - RGBQUAD* prgbColors) const throw() + RGBQUAD* prgbColors) const noexcept { ATLASSERT(IsDIBSection()); GetDC(); @@ -298,13 +298,13 @@ public: ReleaseDC(); } - int GetHeight() const throw() + int GetHeight() const noexcept { ATLASSERT(m_hBitmap); return m_bm.bmHeight; } - int GetMaxColorTableEntries() const throw() + int GetMaxColorTableEntries() const noexcept { ATLASSERT(IsDIBSection()); if (m_ds.dsBmih.biClrUsed && m_ds.dsBmih.biBitCount < 16) @@ -324,7 +324,7 @@ public: } } - int GetPitch() const throw() + int GetPitch() const noexcept { ATLASSERT(IsDIBSection()); if (m_eOrientation == DIBOR_BOTTOMUP) @@ -333,7 +333,7 @@ public: return m_bm.bmWidthBytes; } - COLORREF GetPixel(int x, int y) const throw() + COLORREF GetPixel(int x, int y) const noexcept { GetDC(); COLORREF ret = ::GetPixel(m_hDC, x, y); @@ -341,7 +341,7 @@ public: return ret; } - void* GetPixelAddress(int x, int y) throw() + void* GetPixelAddress(int x, int y) noexcept { ATLASSERT(IsDIBSection()); BYTE *pb = (BYTE *)GetBits(); @@ -350,35 +350,35 @@ public: return pb; } - COLORREF GetTransparentColor() const throw() + COLORREF GetTransparentColor() const noexcept { return m_clrTransparentColor; } - int GetWidth() const throw() + int GetWidth() const noexcept { ATLASSERT(m_hBitmap); return m_bm.bmWidth; } - bool IsDIBSection() const throw() + bool IsDIBSection() const noexcept { ATLASSERT(m_hBitmap); return m_bIsDIBSection; } - bool IsIndexed() const throw() + bool IsIndexed() const noexcept { ATLASSERT(IsDIBSection()); return GetBPP() <= 8; } - bool IsNull() const throw() + bool IsNull() const noexcept { return m_hBitmap == NULL; } - HRESULT Load(LPCTSTR pszFileName) throw() + HRESULT Load(LPCTSTR pszFileName) noexcept { if (!InitGDIPlus()) return E_FAIL; @@ -407,7 +407,7 @@ public: Attach(hbm); return (status == Ok ? S_OK : E_FAIL); } - HRESULT Load(IStream* pStream) throw() + HRESULT Load(IStream* pStream) noexcept { if (!InitGDIPlus()) return E_FAIL; @@ -435,13 +435,13 @@ public: } // NOTE: LoadFromResource loads BITMAP resource only - void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName) throw() + void LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName) noexcept { HANDLE hHandle = ::LoadImage(hInstance, pszResourceName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); Attach(reinterpret_cast<HBITMAP>(hHandle)); } - void LoadFromResource(HINSTANCE hInstance, UINT nIDResource) throw() + void LoadFromResource(HINSTANCE hInstance, UINT nIDResource) noexcept { LoadFromResource(hInstance, MAKEINTRESOURCE(nIDResource)); } @@ -449,7 +449,7 @@ public: BOOL MaskBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, HBITMAP hbmMask, int xMask, int yMask, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { ATLASSERT(IsTransparencySupported()); GetDC(); @@ -461,20 +461,20 @@ public: } BOOL MaskBlt(HDC hDestDC, const RECT& rectDest, const POINT& pointSrc, HBITMAP hbmMask, const POINT& pointMask, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return MaskBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, rectDest.bottom - rectDest.top, pointSrc.x, pointSrc.y, hbmMask, pointMask.x, pointMask.y, dwROP); } BOOL MaskBlt(HDC hDestDC, int xDest, int yDest, - HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const throw() + HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const noexcept { return MaskBlt(hDestDC, xDest, yDest, GetWidth(), GetHeight(), 0, 0, hbmMask, 0, 0, dwROP); } BOOL MaskBlt(HDC hDestDC, const POINT& pointDest, - HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const throw() + HBITMAP hbmMask, DWORD dwROP = SRCCOPY) const noexcept { return MaskBlt(hDestDC, pointDest.x, pointDest.y, hbmMask, dwROP); } @@ -482,7 +482,7 @@ public: BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, HBITMAP hbmMask = NULL, - int xMask = 0, int yMask = 0) const throw() + int xMask = 0, int yMask = 0) const noexcept { ATLASSERT(IsTransparencySupported()); GetDC(); @@ -493,26 +493,26 @@ public: return ret; } BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, - HBITMAP hbmMask = NULL) const throw() + HBITMAP hbmMask = NULL) const noexcept { return PlgBlt(hDestDC, pPoints, 0, 0, GetWidth(), GetHeight(), hbmMask); } BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, const RECT& rectSrc, - HBITMAP hbmMask, const POINT& pointMask) const throw() + HBITMAP hbmMask, const POINT& pointMask) const noexcept { return PlgBlt(hDestDC, pPoints, rectSrc.left, rectSrc.top, rectSrc.right - rectSrc.left, rectSrc.bottom - rectSrc.top, hbmMask, pointMask.x, pointMask.y); } BOOL PlgBlt(HDC hDestDC, const POINT* pPoints, const RECT& rectSrc, - HBITMAP hbmMask = NULL) const throw() + HBITMAP hbmMask = NULL) const noexcept { POINT pointMask = {0, 0}; return PlgBlt(hDestDC, pPoints, rectSrc, hbmMask, pointMask); } - HRESULT Save(IStream* pStream, GUID *guidFileType) const throw() + HRESULT Save(IStream* pStream, GUID *guidFileType) const noexcept { if (!InitGDIPlus()) return E_FAIL; @@ -543,7 +543,7 @@ public: } HRESULT Save(LPCTSTR pszFileName, - REFGUID guidFileType = GUID_NULL) const throw() + REFGUID guidFileType = GUID_NULL) const noexcept { if (!InitGDIPlus()) return E_FAIL; @@ -585,7 +585,7 @@ public: } void SetColorTable(UINT iFirstColor, UINT nColors, - const RGBQUAD* prgbColors) throw() + const RGBQUAD* prgbColors) noexcept { ATLASSERT(IsDIBSection()); GetDC(); @@ -593,14 +593,14 @@ public: ReleaseDC(); } - void SetPixel(int x, int y, COLORREF color) throw() + void SetPixel(int x, int y, COLORREF color) noexcept { GetDC(); ::SetPixelV(m_hDC, x, y, color); ReleaseDC(); } - void SetPixelIndexed(int x, int y, int iIndex) throw() + void SetPixelIndexed(int x, int y, int iIndex) noexcept { ATLASSERT(IsIndexed()); GetDC(); @@ -608,12 +608,12 @@ public: ReleaseDC(); } - void SetPixelRGB(int x, int y, BYTE r, BYTE g, BYTE b) throw() + void SetPixelRGB(int x, int y, BYTE r, BYTE g, BYTE b) noexcept { SetPixel(x, y, RGB(r, g, b)); } - COLORREF SetTransparentColor(COLORREF rgbTransparent) throw() + COLORREF SetTransparentColor(COLORREF rgbTransparent) noexcept { ATLASSERT(m_hBitmap); COLORREF rgbOldColor = m_clrTransparentColor; @@ -624,7 +624,7 @@ public: BOOL StretchBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { GetDC(); BOOL ret = ::StretchBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight, @@ -634,20 +634,20 @@ public: } BOOL StretchBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return StretchBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight, 0, 0, GetWidth(), GetHeight(), dwROP); } BOOL StretchBlt(HDC hDestDC, const RECT& rectDest, - DWORD dwROP = SRCCOPY) const throw() + DWORD dwROP = SRCCOPY) const noexcept { return StretchBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, rectDest.bottom - rectDest.top, dwROP); } BOOL StretchBlt(HDC hDestDC, const RECT& rectDest, - const RECT& rectSrc, DWORD dwROP = SRCCOPY) const throw() + const RECT& rectSrc, DWORD dwROP = SRCCOPY) const noexcept { return StretchBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, @@ -660,7 +660,7 @@ public: BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, - UINT crTransparent = CLR_INVALID) const throw() + UINT crTransparent = CLR_INVALID) const noexcept { ATLASSERT(IsTransparencySupported()); GetDC(); @@ -673,13 +673,13 @@ public: } BOOL TransparentBlt(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, - UINT crTransparent = CLR_INVALID) const throw() + UINT crTransparent = CLR_INVALID) const noexcept { return TransparentBlt(hDestDC, xDest, yDest, nDestWidth, nDestHeight, 0, 0, GetWidth(), GetHeight(), crTransparent); } BOOL TransparentBlt(HDC hDestDC, const RECT& rectDest, - UINT crTransparent = CLR_INVALID) const throw() + UINT crTransparent = CLR_INVALID) const noexcept { return TransparentBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, @@ -687,7 +687,7 @@ public: } BOOL TransparentBlt( HDC hDestDC, const RECT& rectDest, - const RECT& rectSrc, UINT crTransparent = CLR_INVALID) const throw() + const RECT& rectSrc, UINT crTransparent = CLR_INVALID) const noexcept { return TransparentBlt(hDestDC, rectDest.left, rectDest.top, rectDest.right - rectDest.left, rectDest.bottom - rectDest.left, @@ -695,7 +695,7 @@ public: rectSrc.bottom - rectSrc.top, crTransparent); } - static BOOL IsTransparencySupported() throw() + static BOOL IsTransparencySupported() noexcept { return TRUE; } @@ -881,7 +881,7 @@ private: LONG m_nCImageObjects; DWORD m_dwLastError; - void _clear_funs() throw() + void _clear_funs() noexcept { Startup = NULL; Shutdown = NULL; @@ -899,7 +899,7 @@ private: } template <typename T_FUN> - T_FUN _get_fun(T_FUN& fun, LPCSTR name) throw() + T_FUN _get_fun(T_FUN& fun, LPCSTR name) noexcept { if (!fun) fun = reinterpret_cast<T_FUN>(::GetProcAddress(m_hInst, name)); @@ -922,7 +922,7 @@ private: FUN_SaveImageToFile SaveImageToFile; FUN_SaveImageToStream SaveImageToStream; - CInitGDIPlus() throw() + CInitGDIPlus() noexcept : m_hInst(NULL) , m_dwToken(0) , m_nCImageObjects(0) @@ -932,13 +932,13 @@ private: ::InitializeCriticalSection(&m_sect); } - ~CInitGDIPlus() throw() + ~CInitGDIPlus() noexcept { ReleaseGDIPlus(); ::DeleteCriticalSection(&m_sect); } - bool Init() throw() + bool Init() noexcept { ::EnterCriticalSection(&m_sect); @@ -975,7 +975,7 @@ private: return ret; } - void ReleaseGDIPlus() throw() + void ReleaseGDIPlus() noexcept { ::EnterCriticalSection(&m_sect); if (m_dwToken) @@ -994,14 +994,14 @@ private: ::LeaveCriticalSection(&m_sect); } - void IncreaseCImageCount() throw() + void IncreaseCImageCount() noexcept { ::EnterCriticalSection(&m_sect); ++m_nCImageObjects; ::LeaveCriticalSection(&m_sect); } - void DecreaseCImageCount() throw() + void DecreaseCImageCount() noexcept { ::EnterCriticalSection(&m_sect); if (--m_nCImageObjects == 0) @@ -1014,7 +1014,7 @@ private: static CInitGDIPlus s_gdiplus; - static bool InitGDIPlus() throw() + static bool InitGDIPlus() noexcept { return s_gdiplus.Init(); } @@ -1134,7 +1134,7 @@ private: } void AttachInternal(HBITMAP hBitmap, DIBOrientation eOrientation, - LONG iTransColor) throw() + LONG iTransColor) noexcept { Destroy(); @@ -1154,7 +1154,7 @@ private: BOOL CreateInternal(int nWidth, int nHeight, int nBPP, DWORD eCompression, const DWORD* pdwBitmasks = NULL, - DWORD dwFlags = 0) throw() + DWORD dwFlags = 0) noexcept { ATLASSERT(nWidth != 0); ATLASSERT(nHeight != 0); @@ -1234,12 +1234,12 @@ public: { } - virtual ~CImageDC() throw() + virtual ~CImageDC() noexcept { m_image.ReleaseDC(); } - operator HDC() const throw() + operator HDC() const noexcept { return m_hDC; }
1 year, 3 months
1
0
0
0
[reactos] 01/01: [ATL][ATL_APITEST] Implement CImageDC class (#5643)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b68a3f329c2f9cb8daad6…
commit b68a3f329c2f9cb8daad63431ca1b92ce6ac4ab9 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Sep 5 09:03:32 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Sep 5 09:03:32 2023 +0900 [ATL][ATL_APITEST] Implement CImageDC class (#5643) - Use reference count for CImage::GetDC / CImage::ReleaseDC. - Add CImageDC class. - Delete modules/rostests/apitests/atl/CImage_WIP.txt. CORE-19008 --- modules/rostests/apitests/atl/CImage.cpp | 20 +++++++ modules/rostests/apitests/atl/CImage_WIP.txt | 86 ---------------------------- sdk/lib/atl/atlimage.h | 65 ++++++++++++++++----- 3 files changed, 70 insertions(+), 101 deletions(-) diff --git a/modules/rostests/apitests/atl/CImage.cpp b/modules/rostests/apitests/atl/CImage.cpp index 005cd4d9295..3ee98304da8 100644 --- a/modules/rostests/apitests/atl/CImage.cpp +++ b/modules/rostests/apitests/atl/CImage.cpp @@ -235,6 +235,26 @@ static void Test_LoadSaveImage(void) color = image1.GetPixel(5, 5); ok(color == RGB(255, 0,0), "Expected color to be 255, 0, 0; was: %i, %i, %i (for %i)\n", GetRValue(color), GetGValue(color), GetBValue(color), n); + { + CImageDC dc1(image1); + ::SetPixel(dc1, 5, 5, RGB(0, 255, 0)); + { + CImageDC dc2(image1); + ::SetPixel(dc2, 5, 5, RGB(0, 0, 255)); + } + } + + { + HDC hdcImage = image1.GetDC(); + color = ::GetPixel(hdcImage, 5, 5); + ok_long(color, RGB(0, 0, 255)); + + ::SetPixel(hdcImage, 5, 5, RGB(255, 0, 0)); + color = ::GetPixel(hdcImage, 5, 5); + ok_long(color, RGB(255, 0, 0)); + image1.ReleaseDC(); + } + bOK = DeleteFile(file); ok(bOK, "Expected bOK to be TRUE, was: %d (for %i)\n", bOK, n); } diff --git a/modules/rostests/apitests/atl/CImage_WIP.txt b/modules/rostests/apitests/atl/CImage_WIP.txt deleted file mode 100644 index 7cc02b77afe..00000000000 --- a/modules/rostests/apitests/atl/CImage_WIP.txt +++ /dev/null @@ -1,86 +0,0 @@ -Test files: - -atl_apitest: CImage class from reactos -CImage.exe : CImage class from microsoft - -================================================================================================================ -Windows Server 2003 SP2: -================================================================================================================ ->atl_apitest.exe CImage -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(234): Test failed: Expected bpp to be 8, was: 32 -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 0) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 1) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 2) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(260): Test failed: Expected bpp to be 24, was: 32 (for 3) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 4) - -CImage: 79 tests executed (0 marked as todo, 6 failures), 0 skipped. -================================================================================================================ ->CImage.exe -CImage: 79 tests executed (0 marked as todo, 0 failures), 0 skipped. -================================================================================================================ -================================================================================================================ -Windows 10: -================================================================================================================ ->atl_apitest.exe CImage -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(234): Test failed: Expected bpp to be 8, was: 32 -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 0) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 1) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 2) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(260): Test failed: Expected bpp to be 24, was: 32 (for 3) -R:\src\trunk\reactos\modules\rostests\apitests\atl\CImage.cpp(265): Test failed: Expected bpp to be 8, was: 32 (for 4) - -CImage: 79 tests executed (0 marked as todo, 6 failures), 0 skipped. -================================================================================================================ ->CImage.exe -CImage: 79 tests executed (0 marked as todo, 0 failures), 0 skipped. -================================================================================================================ -================================================================================================================ -ReactOS: -================================================================================================================ ->atl_apitest.exe CImage -CImage.cpp:234: Test failed: Expected bpp to be 8, was: 32 -CImage.cpp:265: Test failed: Expected bpp to be 8, was: 32 (for 0) -CImage.cpp:245: Test failed: Expected hr to be S_OK, was: 80004005 (for 1) -CImage.cpp:251: Test failed: Expected hr to be S_OK, was: 80004005 (for 1) -CImage.cpp:254: Test failed: Expected width to be 48, was: 0 (for 1) -CImage.cpp:256: Test failed: Expected height to be 48, was: 0 (for 1) -CImage.cpp:265: Test failed: Expected bpp to be 8, was: 0 (for 1) -CImage.cpp:148: Test failed: Expected status to be 0, was: 1 -CImage.cpp:149: Test failed: Expected a valid bitmap -CImage.cpp:245: Test failed: Expected hr to be S_OK, was: 80004005 (for 2) -CImage.cpp:251: Test failed: Expected hr to be S_OK, was: 80004005 (for 2) -CImage.cpp:254: Test failed: Expected width to be 48, was: 0 (for 2) -CImage.cpp:256: Test failed: Expected height to be 48, was: 0 (for 2) -CImage.cpp:265: Test failed: Expected bpp to be 8, was: 0 (for 2) -CImage.cpp:148: Test failed: Expected status to be 0, was: 1 -CImage.cpp:149: Test failed: Expected a valid bitmap -CImage.cpp:260: Test failed: Expected bpp to be 24, was: 32 (for 3) -CImage.cpp:154: Test failed: Expected PixelFormat to be 0x21808, was: 0x30803 -CImage.cpp:265: Test failed: Expected bpp to be 8, was: 32 (for 4) -CImage.cpp:154: Test failed: Expected PixelFormat to be 0x30803, was: 0x21808 - -CImage: 77 tests executed (0 marked as todo, 20 failures), 0 skipped. -================================================================================================================ ->CImage.exe -../CImage.cpp (245): Expected hr to be S_OK, was: 80004005 (for 1) -../CImage.cpp (251): Expected hr to be S_OK, was: 80004005 (for 1) -../CImage.cpp (254): Expected width to be 48, was: 0 (for 1) -../CImage.cpp (256): Expected height to be 48, was: 0 (for 1) -../CImage.cpp (265): Expected bpp to be 8, was: 0 (for 1) -../CImage.cpp (148): Expected status to be 0, was: 1 -../CImage.cpp (149): Expected a valid bitmap -../CImage.cpp (245): Expected hr to be S_OK, was: 80004005 (for 2) -../CImage.cpp (251): Expected hr to be S_OK, was: 80004005 (for 2) -../CImage.cpp (254): Expected width to be 48, was: 0 (for 2) -../CImage.cpp (256): Expected height to be 48, was: 0 (for 2) -../CImage.cpp (265): Expected bpp to be 8, was: 0 (for 2) -../CImage.cpp (148): Expected status to be 0, was: 1 -../CImage.cpp (149): Expected a valid bitmap -../CImage.cpp (260): Expected bpp to be 24, was: 8 (for 3) -../CImage.cpp (154): Expected PixelFormat to be 0x21808, was: 0x30803 -../CImage.cpp (265): Expected bpp to be 8, was: 24 (for 4) -../CImage.cpp (154): Expected PixelFormat to be 0x30803, was: 0x21808 -CImage: 77 tests executed (0 marked as todo, 18 failures), 0 skipped. -================================================================================================================ - diff --git a/sdk/lib/atl/atlimage.h b/sdk/lib/atl/atlimage.h index 31cceac8c76..c77c4dbc67b 100644 --- a/sdk/lib/atl/atlimage.h +++ b/sdk/lib/atl/atlimage.h @@ -6,12 +6,6 @@ #ifndef __ATLIMAGE_H__ #define __ATLIMAGE_H__ -// !!!! -// TODO: The backend (gdi+) that this class relies on is not yet complete! -// Before that is finished, this class will not be a perfect replacement. -// See rostest/apitests/atl/CImage_WIP.txt for test results. -// !!!! - #pragma once #include <atlcore.h> // for ATL Core @@ -93,28 +87,41 @@ public: HDC GetDC() const throw() { - if (m_hDC) - return m_hDC; + ATLASSERT(m_nDCRefCount >= 0); + if (::InterlockedIncrement(&m_nDCRefCount) == 1) + { + ATLASSERT(m_hDC == NULL); + ATLASSERT(m_hOldBitmap == NULL); + + m_hDC = ::CreateCompatibleDC(NULL); + ATLASSERT(m_hDC != NULL); + + m_hOldBitmap = (HBITMAP)::SelectObject(m_hDC, m_hBitmap); + ATLASSERT(m_hOldBitmap != NULL); + } - m_hDC = ::CreateCompatibleDC(NULL); - m_hOldBitmap = (HBITMAP)::SelectObject(m_hDC, m_hBitmap); return m_hDC; } void ReleaseDC() const throw() { - ATLASSERT(m_hDC); + ATLASSERT(m_nDCRefCount > 0); - if (m_hDC == NULL) + if (::InterlockedDecrement(&m_nDCRefCount) != 0) return; if (m_hOldBitmap) { + ATLASSERT(m_hDC != NULL); ::SelectObject(m_hDC, m_hOldBitmap); m_hOldBitmap = NULL; } - ::DeleteDC(m_hDC); - m_hDC = NULL; + + if (m_hDC) + { + ::DeleteDC(m_hDC); + m_hDC = NULL; + } } BOOL AlphaBlend(HDC hDestDC, @@ -1016,6 +1023,7 @@ private: HBITMAP m_hBitmap; mutable HBITMAP m_hOldBitmap; mutable HDC m_hDC; + mutable LONG m_nDCRefCount = 0; DIBOrientation m_eOrientation; bool m_bHasAlphaChannel; bool m_bIsDIBSection; @@ -1213,7 +1221,34 @@ private: DECLSPEC_SELECTANY CImage::CInitGDIPlus CImage::s_gdiplus; -} +class CImageDC +{ +private: + const CImage& m_image; + HDC m_hDC; + +public: + CImageDC(const CImage& image) + : m_image(image) + , m_hDC(image.GetDC()) + { + } + + virtual ~CImageDC() throw() + { + m_image.ReleaseDC(); + } + + operator HDC() const throw() + { + return m_hDC; + } + + CImageDC(const CImageDC&) = delete; + CImageDC& operator=(const CImageDC&) = delete; +}; + +} // namespace ATL #endif
1 year, 3 months
1
0
0
0
[reactos] 01/01: [COMDLG32] GetOpen/GetSaveFileName: Improve extension handling (#5640)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d55e33d0f3cf7ca8a1b08…
commit d55e33d0f3cf7ca8a1b087a677ef5726834130aa Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Sep 4 21:11:24 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Mon Sep 4 21:11:24 2023 +0900 [COMDLG32] GetOpen/GetSaveFileName: Improve extension handling (#5640) - Improve GetOpenFileName and GetSaveFileName functions. - Add FILEDLG95_GetFallbackExtension and FILEDLG95_AddDotExtIfNeeded helper functions. - Modify FILEDLG95_ValidatePathAction and FILEDLG95_OnOpen functions. CORE-19148, CORE-15020 --- dll/win32/comdlg32/cdlg.h | 6 ++ dll/win32/comdlg32/filedlg.c | 202 +++++++++++++++++++----------------- dll/win32/comdlg32/filedlgbrowser.h | 5 +- 3 files changed, 118 insertions(+), 95 deletions(-) diff --git a/dll/win32/comdlg32/cdlg.h b/dll/win32/comdlg32/cdlg.h index 7570acebb9e..4c8be081e84 100644 --- a/dll/win32/comdlg32/cdlg.h +++ b/dll/win32/comdlg32/cdlg.h @@ -199,8 +199,14 @@ HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) /* Shared helper functions */ void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile) DECLSPEC_HIDDEN; +#ifdef __REACTOS__ +struct FileOpenDlgInfos; +int FILEDLG95_ValidatePathAction(struct FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile, IShellFolder **ppsf, + HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction) DECLSPEC_HIDDEN; +#else int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction) DECLSPEC_HIDDEN; +#endif int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed) DECLSPEC_HIDDEN; void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) DECLSPEC_HIDDEN; diff --git a/dll/win32/comdlg32/filedlg.c b/dll/win32/comdlg32/filedlg.c index 54bbc544aab..8aa8eae3987 100644 --- a/dll/win32/comdlg32/filedlg.c +++ b/dll/win32/comdlg32/filedlg.c @@ -2826,8 +2826,98 @@ void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND); } +#ifdef __REACTOS__ +/* The return value needs LocalFree */ +static LPWSTR FILEDLG95_GetFallbackExtension(FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile) +{ + LPWSTR lpstrFilter, the_ext = NULL, pchDot = NULL; + + /* Without lpstrDefExt, append no extension */ + if (!fodInfos->defext) + return NULL; + + /* Get filter extensions */ + lpstrFilter = (LPWSTR)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, + fodInfos->ofnInfos->nFilterIndex - 1); + if (lpstrFilter != (LPWSTR)CB_ERR && lpstrFilter && *lpstrFilter) + { + LPWSTR pchSemicolon = wcschr(lpstrFilter, L';'); + + if (pchSemicolon) + *pchSemicolon = UNICODE_NULL; + + pchDot = wcschr(lpstrFilter, L'.'); + + if (pchDot && pchDot[1] && !wcschr(pchDot, L'*') && !wcschr(pchDot, L'?')) + the_ext = StrDupW(pchDot + 1); + + if (pchSemicolon) + *pchSemicolon = L';'; + } + + if (!the_ext && (!pchDot || pchDot[1])) + { + /* use default extension if no extension in filter */ + the_ext = StrDupW(fodInfos->defext); + } + + return the_ext; +} + +static BOOL +FILEDLG95_AddDotExtIfNeeded(FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile) +{ + BOOL ret = FALSE; + LPWSTR ext = PathFindExtensionW(lpstrPathAndFile); + int PathLength = lstrlenW(lpstrPathAndFile); + LPWSTR the_ext = FILEDLG95_GetFallbackExtension(fodInfos, lpstrPathAndFile); + + if (the_ext && *the_ext && + (*ext == UNICODE_NULL || lstrcmpiW(ext + 1, the_ext) != 0)) + { + if (strlenW(lpstrPathAndFile) + 1 + strlenW(the_ext) + 1 <= + fodInfos->ofnInfos->nMaxFile) + { + /* Make the extension lowercase */ + CharLowerW(the_ext); + /* Append it (with dot) to the file */ + lstrcatW(lpstrPathAndFile, L"."); + lstrcatW(lpstrPathAndFile, the_ext); + /* update ext */ + ext = PathFindExtensionW(lpstrPathAndFile); + ret = TRUE; + } + } + + LocalFree(the_ext); + + /* In Open dialog: if file does not exist try without extension */ + if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile)) + { + lpstrPathAndFile[PathLength] = UNICODE_NULL; + ret = FALSE; + } + + /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */ + if (*ext) + ext++; + if (!lstrcmpiW(fodInfos->defext, ext)) + fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT; + else + fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT; + + return ret; +} +#endif + +#ifdef __REACTOS__ +int FILEDLG95_ValidatePathAction(struct FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile, + IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, + int defAction) +#else int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction) +#endif { int nOpenAction = defAction; LPWSTR lpszTemp, lpszTemp1; @@ -2924,8 +3014,17 @@ int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, { if( (flags & OFN_FILEMUSTEXIST) && !isSaveDlg ) { +#ifdef __REACTOS__ + FILEDLG95_AddDotExtIfNeeded(fodInfos, lpstrPathAndFile); + if (!PathFileExistsW(lpstrPathAndFile)) + { + FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING); + break; + } +#else FILEDLG95_OnOpenMessage(hwnd, 0, IDS_FILENOTEXISTING); break; +#endif } } /* change to the current folder */ @@ -3011,7 +3110,11 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) else nOpenAction = ONOPEN_BROWSE; +#ifdef __REACTOS__ + nOpenAction = FILEDLG95_ValidatePathAction(fodInfos, lpstrPathAndFile, &lpsf, hwnd, +#else nOpenAction = FILEDLG95_ValidatePathAction(lpstrPathAndFile, &lpsf, hwnd, +#endif fodInfos->ofnInfos->Flags, fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG, nOpenAction); @@ -3088,7 +3191,9 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) case ONOPEN_OPEN: /* fill in the return struct and close the dialog */ TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile)); { +#ifndef __REACTOS__ WCHAR *ext = NULL; +#endif /* update READONLY check box flag */ if ((SendMessageW(GetDlgItem(hwnd,IDC_OPENREADONLY),BM_GETCHECK,0,0) & 0x03) == BST_CHECKED) @@ -3097,104 +3202,13 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) fodInfos->ofnInfos->Flags &= ~OFN_READONLY; /* Attach the file extension with file name*/ - ext = PathFindExtensionW(lpstrPathAndFile); #ifdef __REACTOS__ - if (*ext == UNICODE_NULL && fodInfos->defext) - { - LPWSTR filterExt = NULL, lpstrFilter = NULL, pch, pchNext; - LPCWSTR the_ext = NULL; - static const WCHAR szwDot[] = {'.',0}; - int PathLength = lstrlenW(lpstrPathAndFile); - - /* get filter extensions */ - lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, - fodInfos->ofnInfos->nFilterIndex - 1); - if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */ - { - LPWSTR filterSearchIndex, pchFirst = NULL; - filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR)); - if (filterExt) - { - strcpyW(filterExt, lpstrFilter); - - if (ext && *ext) - { - /* find ext in filter */ - for (pch = filterExt; pch && *pch; pch = pchNext) - { - filterSearchIndex = strchrW(pch, ';'); - if (filterSearchIndex) - { - filterSearchIndex[0] = 0; - pchNext = filterSearchIndex + 1; - } - else - { - pchNext = NULL; - } - - while (*pch == '*' || *pch == '.' || *pch == '?') - { - ++pch; - } - - if (!pchFirst) - pchFirst = pch; - - if (lstrcmpiW(pch, &ext[1]) == 0) - { - the_ext = pch; - break; - } - } - - /* use first one if not found */ - if (!the_ext && pchFirst && *pchFirst) - { - the_ext = pchFirst; - } - } - } - } - - if (!the_ext) - { - /* use default extension if no extension in filter */ - the_ext = fodInfos->defext; - } - - if (the_ext && *the_ext && lstrcmpiW(&ext[1], the_ext) != 0) - { - if (strlenW(lpstrPathAndFile) + 1 + strlenW(the_ext) + 1 <= - fodInfos->ofnInfos->nMaxFile) - { - /* append the dot */ - lstrcatW(lpstrPathAndFile, szwDot); - /* append the extension */ - lstrcatW(lpstrPathAndFile, the_ext); - /* update ext */ - ext = PathFindExtensionW(lpstrPathAndFile); - } - } - - heap_free(filterExt); - - /* In Open dialog: if file does not exist try without extension */ - if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile)) - lpstrPathAndFile[PathLength] = 0; - - /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */ - if (*ext) - ext++; - if (!lstrcmpiW(fodInfos->defext, ext)) - fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT; - else - fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT; - } - + /* Add extension if necessary */ + FILEDLG95_AddDotExtIfNeeded(fodInfos, lpstrPathAndFile); /* update dialog data */ SetWindowTextW(fodInfos->DlgInfos.hwndFileName, PathFindFileNameW(lpstrPathAndFile)); #else /* __REACTOS__ */ + ext = PathFindExtensionW(lpstrPathAndFile); if (! *ext && fodInfos->defext) { /* if no extension is specified with file name, then */ diff --git a/dll/win32/comdlg32/filedlgbrowser.h b/dll/win32/comdlg32/filedlgbrowser.h index 67c07a8793c..ee7fbdc79d8 100644 --- a/dll/win32/comdlg32/filedlgbrowser.h +++ b/dll/win32/comdlg32/filedlgbrowser.h @@ -47,8 +47,11 @@ * Data structure */ - +#ifdef __REACTOS__ +typedef struct FileOpenDlgInfos +#else typedef struct +#endif { LPOPENFILENAMEW ofnInfos; BOOL unicode;
1 year, 3 months
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
Results per page:
10
25
50
100
200