Skip to content

Commit

Permalink
Version 4.6
Browse files Browse the repository at this point in the history
Fix compatibility issue with some Windows 10 64 bit environments (closes #3).
  • Loading branch information
bnason-nf authored and benbuck committed Aug 29, 2017
1 parent 941a476 commit e99381f
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#/ipch
/.vs
/afxres.h
*.aps
*.cache
*.db
Expand All @@ -12,6 +13,8 @@
*.opendb
*.pdb
*.res
*.sdf
*.suo
*.tlog
*.user
!/**/RBTray.exe
!/**/RBTray.exe
46 changes: 32 additions & 14 deletions RBHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,52 @@
// ****************************************************************************

#include <windows.h>
#include <stdio.h>
#include "rbtray.h"

static HHOOK _hMouse = NULL;
static HHOOK _hWndProc = NULL;
static HWND _hLastHit = NULL;
static unsigned int _hack;

//#define DEBUG_PRINTF(fmt, ...) do { char buf[1024]; snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); OutputDebugStringA(buf); } while (0)

// Works for 32-bit and 64-bit apps
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode >= 0) {
//if ((wParam != WM_MOUSEMOVE) && (wParam != WM_NCMOUSEMOVE)) DEBUG_PRINTF("%s(%d): nCode %d, wParam %llx, lParam %llx\n", __FUNCTION__, __LINE__, nCode, (long long int)wParam, (long long int)lParam);
MOUSEHOOKSTRUCT *info = (MOUSEHOOKSTRUCT*)lParam;
//if ((wParam != WM_MOUSEMOVE) && (wParam != WM_NCMOUSEMOVE)) DEBUG_PRINTF("%s(%d): pt (%ld, %ld), hwnd %p, wHitTestCode %u, dwExtraInfo %llx\n", __FUNCTION__, __LINE__, info->pt.x, info->pt.y, info->hwnd, info->wHitTestCode, info->dwExtraInfo);
if ((wParam == WM_NCRBUTTONDOWN) || (wParam == WM_NCRBUTTONUP)) {
MOUSEHOOKSTRUCT *info = (MOUSEHOOKSTRUCT*)lParam;
BOOL isHit = (info->wHitTestCode == HTMINBUTTON) || ((info->wHitTestCode == HTCAPTION) && (GetKeyState(VK_SHIFT) & 0x8000));
if ((wParam == WM_NCRBUTTONDOWN) && isHit) {
_hLastHit = info->hwnd;
return 1;
}
else if ((wParam == WM_NCRBUTTONUP) && isHit) {
if (info->hwnd == _hLastHit) {
PostMessage(FindWindow(NAME, NAME), WM_ADDTRAY, 0, (LPARAM)info->hwnd);
//DEBUG_PRINTF("%s(%d): button\n", __FUNCTION__, __LINE__);
if (info->wHitTestCode == HTCLIENT) {
//DEBUG_PRINTF("%s(%d): ignoring client hit test code for non-client message\n", __FUNCTION__, __LINE__);
} else {
BOOL shiftKeyDown = (GetKeyState(VK_SHIFT) & 0x8000) ? TRUE : FALSE;
BOOL isHit = (info->wHitTestCode == HTMINBUTTON) || ((info->wHitTestCode == HTCAPTION) && shiftKeyDown);
//DEBUG_PRINTF("%s(%d): shift %s, hit %s\n", __FUNCTION__, __LINE__, shiftKeyDown ? "yes" : "no", isHit ? "yes" : "no");
if ((wParam == WM_NCRBUTTONDOWN) && isHit) {
//DEBUG_PRINTF("%s(%d): down hit\n", __FUNCTION__, __LINE__);
_hLastHit = info->hwnd;
return 1;
}
else if ((wParam == WM_NCRBUTTONUP) && isHit) {
//DEBUG_PRINTF("%s(%d): up hit\n", __FUNCTION__, __LINE__);
if (info->hwnd == _hLastHit) {
//DEBUG_PRINTF("%s(%d): up hit match\n", __FUNCTION__, __LINE__);
PostMessage(FindWindow(NAME, NAME), WM_ADDTRAY, 0, (LPARAM)info->hwnd);
}
_hLastHit = NULL;
return 1;
}
else {
//DEBUG_PRINTF("%s(%d): miss\n", __FUNCTION__, __LINE__);
_hLastHit = NULL;
}
_hLastHit = NULL;
return 1;
}
else {
_hLastHit = NULL;
}
}
else if (wParam == WM_RBUTTONDOWN || wParam == WM_RBUTTONUP) {
//DEBUG_PRINTF("%s(%d): not button\n", __FUNCTION__, __LINE__);
_hLastHit = NULL;
}
}
Expand Down
10 changes: 5 additions & 5 deletions RBTray.rc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,75,142,50,14
ICON IDI_RBTRAY,IDC_STATIC,7,7,20,20
LTEXT "RBTray 4.5\r\n\r\nThis program is distributed under the GNU General Public License.\r\n\r\nCopyright � 1998-2011,2015\r\n\r\nNikolay Redko\r\nhttp://rbtray.sourceforge.net/\r\n\r\nJ.D. Purcell\r\nhttp://www.moitah.net/\r\n\r\nBenbuck Nason\r\nhttps://github.com/benbuck/rbtray-code",IDC_STATIC,38,7,151,133
LTEXT "RBTray 4.6\r\n\r\nThis program is distributed under the GNU General Public License.\r\n\r\nCopyright � 1998-2011,2015\r\n\r\nNikolay Redko\r\nhttp://rbtray.sourceforge.net/\r\n\r\nJ.D. Purcell\r\nhttp://www.moitah.net/\r\n\r\nBenbuck Nason\r\nhttps://github.com/benbuck/rbtray-code",IDC_STATIC,38,7,151,133
END


Expand Down Expand Up @@ -96,8 +96,8 @@ IDI_RBTRAY ICON "RBTray.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,5,0,0
PRODUCTVERSION 4,5,0,0
FILEVERSION 4,6,0,0
PRODUCTVERSION 4,6,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -113,12 +113,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "RBTray"
VALUE "FileVersion", "4.5.0.0"
VALUE "FileVersion", "4.6.0.0"
VALUE "InternalName", "RBTray"
VALUE "LegalCopyright", "Copyright � 1998-2011 Nikolay Redko, J.D. Purcell, Benbuck Nason"
VALUE "OriginalFilename", "RBTray.exe"
VALUE "ProductName", "RBTray"
VALUE "ProductVersion", "4.5.0.0"
VALUE "ProductVersion", "4.6.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Version 4.5
Add some error handling.
Fix bug in shift key check.
Update project files to VS2015.

Version 4.6
Fix compatibility issue with some Windows 10 64 bit environments.
4 changes: 3 additions & 1 deletion htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<br>
<span style="font-size: large; font-weight: bold">Changes:</span><br>
<pre>
4.6 fork (2017-Aug-29) - Benbuck Nason
* Fix compatibility issue with some Windows 10 64 bit environments.
4.5 fork (2017-May-12) - Benbuck Nason
* Add some error handling.
* Fix bug in shift key check.
Expand Down Expand Up @@ -56,4 +58,4 @@
<br>
Copyright &copy; 2015 Benbuck Nason
</body>
</html>
</html>
Binary file modified x64/RBHook.dll
Binary file not shown.
Binary file modified x64/RBTray.exe
Binary file not shown.
Binary file modified x86/RBHook.dll
Binary file not shown.
Binary file modified x86/RBTray.exe
Binary file not shown.

0 comments on commit e99381f

Please sign in to comment.