Allow altering the monitor arrangement control behavior flags

svn path=/trunk/; revision=29298
This commit is contained in:
Thomas Bluemel 2007-09-29 18:04:40 +00:00
parent bfdb1965c9
commit 69f3c70b62
2 changed files with 88 additions and 16 deletions

View file

@ -21,15 +21,15 @@ typedef struct _MONITORSELWND
DWORD UIState;
union
{
DWORD dwFlags;
DWORD dwInternalFlags;
struct
{
UINT Enabled : 1;
UINT HasFocus : 1;
UINT CanDisplay : 1;
UINT AllowSelectNone : 1;
};
};
DWORD ControlExStyle;
DWORD MonitorsCount;
INT SelectedMonitor;
PMONSL_MONINFO MonitorInfo;
@ -363,7 +363,7 @@ MonSelSetMonitorsInfo(IN OUT PMONITORSELWND infoPtr,
if (infoPtr->SelectedMonitor >= (INT)infoPtr->MonitorsCount)
infoPtr->SelectedMonitor = -1;
if (!infoPtr->AllowSelectNone && infoPtr->SelectedMonitor < 0)
if (!(infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTNONE) && infoPtr->SelectedMonitor < 0)
infoPtr->SelectedMonitor = 0;
MonSelUpdateMonitorsInfo(infoPtr,
@ -453,23 +453,33 @@ MonSelSetCurSelMonitor(IN OUT PMONITORSELWND infoPtr,
IN INT Index)
{
INT PrevSel;
BOOL PreventSelect = FALSE;
BOOL Ret = FALSE;
if (Index == -1 || Index < (INT)infoPtr->MonitorsCount)
{
if (Index != infoPtr->SelectedMonitor)
{
PrevSel = infoPtr->SelectedMonitor;
infoPtr->SelectedMonitor = Index;
if (PrevSel >= 0)
if ((infoPtr->MonitorInfo[Index].Flags & MSL_MIF_DISABLED) &&
!(infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTDISABLED))
{
MonSelRepaintMonitor(infoPtr,
PrevSel);
PreventSelect = TRUE;
}
if (infoPtr->SelectedMonitor >= 0)
MonSelRepaintSelected(infoPtr);
if (!PreventSelect)
{
PrevSel = infoPtr->SelectedMonitor;
infoPtr->SelectedMonitor = Index;
if (PrevSel >= 0)
{
MonSelRepaintMonitor(infoPtr,
PrevSel);
}
if (infoPtr->SelectedMonitor >= 0)
MonSelRepaintSelected(infoPtr);
}
}
Ret = TRUE;
@ -508,6 +518,29 @@ MonSelDestroy(IN OUT PMONITORSELWND infoPtr)
}
}
static BOOL
MonSelSetExtendedStyle(IN OUT PMONITORSELWND infoPtr,
IN DWORD dwExtendedStyle)
{
if (dwExtendedStyle != infoPtr->ControlExStyle)
{
infoPtr->ControlExStyle = dwExtendedStyle;
/* Repaint the control */
InvalidateRect(infoPtr->hSelf,
NULL,
TRUE);
}
return TRUE;
}
static DWORD
MonSelGetExtendedStyle(IN PMONITORSELWND infoPtr)
{
return infoPtr->ControlExStyle;
}
static HFONT
MonSelGetMonitorFont(IN OUT PMONITORSELWND infoPtr,
IN HDC hDC,
@ -777,7 +810,7 @@ MonitorSelWndProc(IN HWND hwnd,
Index = MonSelHitTest(infoPtr,
&pt);
if (Index >= 0 || infoPtr->AllowSelectNone)
if (Index >= 0 || (infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTNONE))
{
MonSelSetCurSelMonitor(infoPtr,
Index);
@ -883,7 +916,7 @@ MonitorSelWndProc(IN HWND hwnd,
case WM_ENABLE:
{
infoPtr->Enabled = ((BOOL)wParam != FALSE);
/* FIXME */
MonSelRepaint(infoPtr);
break;
}
@ -895,9 +928,7 @@ MonitorSelWndProc(IN HWND hwnd,
infoPtr->Enabled = !(((LPSTYLESTRUCT)lParam)->styleNew & WS_DISABLED);
if (OldEnabled != infoPtr->Enabled)
{
/* FIXME */
}
MonSelRepaint(infoPtr);
}
break;
}
@ -960,6 +991,19 @@ MonitorSelWndProc(IN HWND hwnd,
break;
}
case MSLM_SETEXSTYLE:
{
Ret = MonSelSetExtendedStyle(infoPtr,
(DWORD)lParam);
break;
}
case MSLM_GETEXSTYLE:
{
Ret = MonSelGetExtendedStyle(infoPtr);
break;
}
case WM_CREATE:
{
infoPtr = (PMONITORSELWND) HeapAlloc(GetProcessHeap(),

View file

@ -1,6 +1,10 @@
#ifndef __MONSLCTL__H
#define __MONSLCTL__H
/* Control extended styles */
#define MSLM_EX_ALLOWSELECTNONE 0x1
#define MSLM_EX_ALLOWSELECTDISABLED 0x2
/* MONSL_MONINFO Flags */
#define MSL_MIF_DISABLED 0x1
@ -95,6 +99,30 @@ typedef struct _MONSL_MONINFO
*/
#define MSLM_GETMONITORINFO (WM_USER + 0x17)
/*
* MSLM_SETEXSTYLE
* wParam: Ignored.
* lParam: DWORD
* Can be a combination of the following flags:
* * MSLM_EX_ALLOWSELECTNONE
* Allow deselecting a monitor by clicking into
* unused areas of the control.
* * MSLM_EX_ALLOWSELECTDISABLED
* Allow selecting disabled monitors
*
* Returns non-zero value if successful.
*/
#define MSLM_SETEXSTYLE (WM_USER + 0x18)
/*
* MSLM_GETEXSTYLE
* wParam: Ignored.
* lParam: Ignored
*
* Returns the control's extended style flags.
*/
#define MSLM_GETEXSTYLE (WM_USER + 0x19)
BOOL RegisterMonitorSelectionControl(IN HINSTANCE hInstance);
VOID UnregisterMonitorSelectionControl(IN HINSTANCE hInstance);