Added the case of a user defined icon for the sysbutton hittest.
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 2363857..beb10f8 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -861,8 +861,18 @@
if (!PtInRect16( &rect, pt ))
{
/* Check system menu */
- if ((wndPtr->dwStyle & WS_SYSMENU) && (!(wndPtr->dwStyle & DS_MODALFRAME)))
- rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
+ if(wndPtr->dwStyle & WS_SYSMENU)
+ {
+ /* Check if there is an user icon */
+ HICON hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICONSM);
+ if(!hIcon) hIcon = (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON);
+
+ /* If there is an icon associated with the window OR */
+ /* If there is no hIcon specified and this is not a modal dialog, */
+ /* there is a system menu icon. */
+ if((hIcon != 0) || (!(wndPtr->dwStyle & DS_MODALFRAME)))
+ rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
+ }
if (pt.x < rect.left) return HTSYSMENU;
/* Check close button */