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;
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,
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;
}
}
+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,
Index = MonSelHitTest(infoPtr,
&pt);
- if (Index >= 0 || infoPtr->AllowSelectNone)
+ if (Index >= 0 || (infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTNONE))
{
MonSelSetCurSelMonitor(infoPtr,
Index);
case WM_ENABLE:
{
infoPtr->Enabled = ((BOOL)wParam != FALSE);
- /* FIXME */
+ MonSelRepaint(infoPtr);
break;
}
infoPtr->Enabled = !(((LPSTYLESTRUCT)lParam)->styleNew & WS_DISABLED);
if (OldEnabled != infoPtr->Enabled)
- {
- /* FIXME */
- }
+ MonSelRepaint(infoPtr);
}
break;
}
break;
}
+ case MSLM_SETEXSTYLE:
+ {
+ Ret = MonSelSetExtendedStyle(infoPtr,
+ (DWORD)lParam);
+ break;
+ }
+
+ case MSLM_GETEXSTYLE:
+ {
+ Ret = MonSelGetExtendedStyle(infoPtr);
+ break;
+ }
+
case WM_CREATE:
{
infoPtr = (PMONITORSELWND) HeapAlloc(GetProcessHeap(),
#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
*/
#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);