Skip to content

Commit 0b058bf

Browse files
Updated to ver. 1.9.1.0
1 parent 48c792c commit 0b058bf

File tree

3 files changed

+63
-33
lines changed

3 files changed

+63
-33
lines changed

Windows11DragAndDropToTaskbarFix/Windows11DragAndDropToTaskbarFix.cpp

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,8 @@ static BOOL CALLBACK enumWindowCallback_SecondaryTrayWnd(HWND hWnd, LPARAM lpara
15411541
wstring ClassNameLower = Mona_toLowerWs(ClassName);
15421542
if (ClassNameLower == L"shell_secondarytraywnd") {
15431543
CurrentSecondaryScreen = windowsHWNDs();
1544-
TmpWorkerW = 0;
1545-
TmpTaskList = 0;
1544+
TmpWorkerW = NULL;
1545+
TmpTaskList = NULL;
15461546
CurrentSecondaryScreen.hWndTray = hWnd;
15471547
EnumChildWindows(hWnd, enumChildWindowCallback_SecondaryTrayWnd, NULL);
15481548
CurrentSecondaryScreen.hWndMSTaskSwWClass = TmpTaskList;
@@ -1954,9 +1954,6 @@ int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int nS
19541954

19551955

19561956
if (!DetectedHWNDsForThisMouseClick) {
1957-
DetectedHWNDsForThisMouseClick = true;
1958-
1959-
Array_Windows_by_Screen.clear();
19601957
//Primary screen variables:
19611958
Update_Primary_Screen_Windows_HWNDSs();
19621959

@@ -1965,6 +1962,7 @@ int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int nS
19651962
if (PrimaryScreen.hWndMSTaskSwWClass) {
19661963
if (Fix_Taskbar_Size_Bug(PrimaryScreen.hWndMSTaskSwWClass)) {
19671964
//Fixed. Ignore this loop to get potentially new HWND and RECTs.
1965+
DetectedHWNDsForThisMouseClick = false;//IMPORTANT ver. 1.9.1 to fix program crash after the sleep mode.
19681966
if (UseFixForBugAfterSleepMode) {
19691967
SleepModeFix_Previous_TimeNow = TimeNow;
19701968
}
@@ -1974,13 +1972,17 @@ int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int nS
19741972
}
19751973
}
19761974

1975+
Array_Windows_by_Screen.clear();
1976+
//Before version 1.9.1 this array could be empty after the sleep mode bug fix, causing program crashes.
19771977
Array_Windows_by_Screen.push_back(PrimaryScreen);
19781978
//Shell_SecondaryTrayWnd:
19791979
EnumWindows(enumWindowCallback_SecondaryTrayWnd, NULL);
19801980

19811981
hDesktop = GetDesktopWindow();
19821982
GetWindowRect(hDesktop, &desktop);
19831983
ShowDesktopStartPosition = desktop.right - DefaultShowDesktopButtonWidth;
1984+
1985+
DetectedHWNDsForThisMouseClick = true;//Moved from top to bottom.
19841986
}
19851987

19861988
//Unfortunately we can't optimize it at the moment since cursor might move with dragged file from screen-to-screen.
@@ -1991,7 +1993,7 @@ int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int nS
19911993
GetClassNameW(WindowUnderMouse, WindowClassName, MAX_PATH);
19921994
//std::wcout << L"Class Name Under Mouse: " << WindowClassName << L"\n";
19931995
if (_wcsicmp(WindowClassName, L"MSTaskListWClass") == 0) {
1994-
if (WindowUnderMouse != hWndMSTaskSwWClass) {
1996+
if (WindowUnderMouse != PrimaryScreen.hWndMSTaskSwWClass) {
19951997
if (PrintDebugInfo) {
19961998
std::wcout << L"Found Taskbar Window on Secondary Screen. Switching HWNDs to the other monitor mode. " << WindowUnderMouse << "\n";
19971999
}
@@ -2017,30 +2019,58 @@ int APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int nS
20172019
}
20182020

20192021
//ver 1.5 continued:
2020-
hWndTray = Array_Windows_by_Screen[WindowsScreenSet].hWndTray;
2022+
//WARNING: Detected some program crashes at this location. Attempting to code it more securely.
2023+
2024+
if (Array_Windows_by_Screen[WindowsScreenSet].hWndTray) {
2025+
hWndTray = Array_Windows_by_Screen[WindowsScreenSet].hWndTray;
2026+
}
2027+
else {
2028+
hWndTray = NULL;
2029+
}
2030+
20212031
if (hWndTray) {
2022-
hWndTrayNotify = Array_Windows_by_Screen[0].hWndTrayNotify;
2032+
if (Array_Windows_by_Screen[0].hWndTrayNotify) {
2033+
hWndTrayNotify = Array_Windows_by_Screen[0].hWndTrayNotify;
2034+
}
2035+
else {
2036+
hWndTrayNotify = NULL;
2037+
}
20232038
}
20242039
else {
2025-
hWndTrayNotify = 0;
2040+
hWndTrayNotify = NULL;
20262041
}
20272042

20282043
if (hWndTray) {
2029-
hWndRebar = Array_Windows_by_Screen[0].hWndRebar;
2044+
if (Array_Windows_by_Screen[0].hWndRebar) {
2045+
hWndRebar = Array_Windows_by_Screen[0].hWndRebar;
2046+
}
2047+
else {
2048+
hWndRebar = NULL;
2049+
}
20302050
}
20312051
else {
2032-
hWndRebar = 0;
2052+
hWndRebar = NULL;
20332053
}
20342054

20352055
if (hWndRebar) {
2036-
hWndMSTaskSwWClass = Array_Windows_by_Screen[WindowsScreenSet].hWndMSTaskSwWClass;
2056+
if (Array_Windows_by_Screen[WindowsScreenSet].hWndMSTaskSwWClass) {
2057+
hWndMSTaskSwWClass = Array_Windows_by_Screen[WindowsScreenSet].hWndMSTaskSwWClass;
2058+
}
2059+
else {
2060+
hWndMSTaskSwWClass = NULL;
2061+
}
20372062
}
20382063
else {
2039-
hWndMSTaskSwWClass = 0;
2064+
hWndMSTaskSwWClass = NULL;
20402065
}
20412066

20422067
//Find a window that should be invisible when app has no active window!
2043-
TaskListThumbnailWnd = Array_Windows_by_Screen[0].TaskListThumbnailWnd;
2068+
if (Array_Windows_by_Screen[0].TaskListThumbnailWnd) {
2069+
TaskListThumbnailWnd = Array_Windows_by_Screen[0].TaskListThumbnailWnd;
2070+
}
2071+
else {
2072+
TaskListThumbnailWnd = NULL;
2073+
}
20442074

20452075
if (PrintDebugInfo) {
20462076
std::wcout << L"Found Taskbar Window: " << hWndMSTaskSwWClass << "\n";

Windows11DragAndDropToTaskbarFix/Windows11DragAndDropToTaskbarFix.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int SleepTimeButtonsElevenPlusMilliseconds = 5;//Unused by default
6666
int AnimationLagButtonsElevenPlusMilliseconds = 100;//Unused by default
6767

6868
//Dynamic variables:
69-
wstring ProgramVersion = L"1.9.0.0";
69+
wstring ProgramVersion = L"1.9.1.0";
7070
wstring GitHubConfiguration = L"https://github.com/HerMajestyDrMona/Windows11DragAndDropToTaskbarFix/blob/main/CONFIGURATION.md";
7171
wstring GitHubReleases = L"https://github.com/HerMajestyDrMona/Windows11DragAndDropToTaskbarFix/releases";
7272
wstring GitHubAbout = L"https://github.com/HerMajestyDrMona/Windows11DragAndDropToTaskbarFix";
@@ -155,14 +155,14 @@ const std::vector<std::pair<WPARAM, LPARAM>> New_WM_HOTKEY_Array_LogoWin_CTRL_Nu
155155
};
156156
bool CurrentlyLeftMouseButtonIsPressed = false;
157157
bool DetectedHWNDsForThisMouseClick = false;
158-
HWND hWndTray = 0;
159-
HWND hWndTrayNotify = 0;
160-
HWND hWndRebar = 0;
161-
HWND hWndMSTaskSwWClass = 0;
162-
HWND hWndWindowForShowDesktopArea = 0;
163-
HWND TaskListThumbnailWnd = 0;
158+
HWND hWndTray = NULL;
159+
HWND hWndTrayNotify = NULL;
160+
HWND hWndRebar = NULL;
161+
HWND hWndMSTaskSwWClass = NULL;
162+
HWND hWndWindowForShowDesktopArea = NULL;
163+
HWND TaskListThumbnailWnd = NULL;
164164
RECT desktop;
165-
HWND hDesktop = 0;
165+
HWND hDesktop = NULL;
166166
int ShowDesktopStartPosition = 0;
167167
int TaskbarWindowWidth = 0;
168168
int NumberOfItemsOnTaskbar = 0;
@@ -189,18 +189,18 @@ std::chrono::milliseconds AwaitingForEnterClickSince = std::chrono::milliseconds
189189
wchar_t WindowClassName[MAX_PATH];
190190
class windowsHWNDs {
191191
public:
192-
HWND hWndTray = 0;
193-
HWND hWndTrayNotify = 0;
194-
HWND hWndRebar = 0;
195-
HWND hWndMSTaskSwWClass = 0;
196-
HWND TaskListThumbnailWnd = 0;
192+
HWND hWndTray = NULL;
193+
HWND hWndTrayNotify = NULL;
194+
HWND hWndRebar = NULL;
195+
HWND hWndMSTaskSwWClass = NULL;
196+
HWND TaskListThumbnailWnd = NULL;
197197

198198
};
199199
windowsHWNDs PrimaryScreen;
200200
windowsHWNDs CurrentSecondaryScreen;
201201
std::vector<windowsHWNDs> Array_Windows_by_Screen;
202-
HWND TmpWorkerW = 0;
203-
HWND TmpTaskList = 0;
202+
HWND TmpWorkerW = NULL;
203+
HWND TmpTaskList = NULL;
204204
int Current_Mouse_Button_Zero_Left_One_Right = -1;
205205
int Previous_Mouse_Button_Zero_Left_One_Right = -1;
206206
std::wstring Current_Button_Name = L"Unknown";

Windows11DragAndDropToTaskbarFix/Windows11DragAndDropToTaskbarFix.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
2525
//
2626

2727
VS_VERSION_INFO VERSIONINFO
28-
FILEVERSION 1,9,0,0
29-
PRODUCTVERSION 1,9,0,0
28+
FILEVERSION 1,9,1,0
29+
PRODUCTVERSION 1,9,1,0
3030
FILEFLAGSMASK 0x3fL
3131
#ifdef _DEBUG
3232
FILEFLAGS 0x1L
@@ -43,12 +43,12 @@ BEGIN
4343
BEGIN
4444
VALUE "CompanyName", "Dr Mona Lisa"
4545
VALUE "FileDescription", "Windows 11 Drag & Drop to the Taskbar (Fix)"
46-
VALUE "FileVersion", "1.9.0.0"
46+
VALUE "FileVersion", "1.9.1.0"
4747
VALUE "InternalName", "Windows11DragAndDropToTaskbarFix.exe"
4848
VALUE "LegalCopyright", "(C) 2021 Copyright by Dr.MonaLisa. All Rights Reserved."
4949
VALUE "OriginalFilename", "Windows11DragAndDropToTaskbarFix.exe"
5050
VALUE "ProductName", "Windows 11 Drag & Drop to the Taskbar (Fix)"
51-
VALUE "ProductVersion", "1.9.0.0"
51+
VALUE "ProductVersion", "1.9.1.0"
5252
END
5353
END
5454
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)