Author: weiden Date: Sat Sep 29 23:12:21 2007 New Revision: 29300
URL: http://svn.reactos.org/svn/reactos?rev=29300&view=rev Log: Send notification if another monitor is selected
Modified: trunk/reactos/dll/cpl/desk/monslctl.c trunk/reactos/dll/cpl/desk/monslctl.h
Modified: trunk/reactos/dll/cpl/desk/monslctl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/monslctl.c?rev... ============================================================================== --- trunk/reactos/dll/cpl/desk/monslctl.c (original) +++ trunk/reactos/dll/cpl/desk/monslctl.c Sat Sep 29 23:12:21 2007 @@ -43,6 +43,54 @@ HBRUSH hbrDisabled; } MONITORSELWND, *PMONITORSELWND;
+static LRESULT +MonSelNotify(IN PMONITORSELWND infoPtr, + IN UINT code, + IN OUT PVOID data) +{ + LRESULT Ret = 0; + + if (infoPtr->hNotify != NULL) + { + LPNMHDR pnmh = (LPNMHDR)data; + + pnmh->hwndFrom = infoPtr->hSelf; + pnmh->idFrom = GetWindowLongPtr(infoPtr->hSelf, + GWLP_ID); + pnmh->code = code; + + Ret = SendMessage(infoPtr->hNotify, + WM_NOTIFY, + (WPARAM)pnmh->idFrom, + (LPARAM)pnmh); + } + + return Ret; +} + +static LRESULT +MonSelNotifyMonitor(IN PMONITORSELWND infoPtr, + IN UINT code, + IN INT Index, + IN OUT PMONSL_MONNMHDR pmonnmh) +{ + pmonnmh->Index = Index; + + if (Index >= 0) + { + pmonnmh->MonitorInfo = infoPtr->MonitorInfo[Index]; + } + else + { + ZeroMemory(&pmonnmh->MonitorInfo, + sizeof(pmonnmh->MonitorInfo)); + } + + return MonSelNotify(infoPtr, + code, + pmonnmh); +} + static HFONT MonSelChangeFont(IN OUT PMONITORSELWND infoPtr, IN HFONT hFont, @@ -450,7 +498,8 @@
static BOOL MonSelSetCurSelMonitor(IN OUT PMONITORSELWND infoPtr, - IN INT Index) + IN INT Index, + IN BOOL bNotify) { INT PrevSel; BOOL PreventSelect = FALSE; @@ -464,6 +513,21 @@ !(infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTDISABLED)) { PreventSelect = TRUE; + } + + if (!PreventSelect && bNotify) + { + MONSL_MONNMMONITORCHANGING nmi; + + nmi.PreviousSelected = infoPtr->SelectedMonitor; + nmi.AllowChanging = TRUE; + + MonSelNotifyMonitor(infoPtr, + MSLN_MONITORCHANGING, + Index, + &nmi.hdr); + + PreventSelect = (nmi.AllowChanging == FALSE); }
if (!PreventSelect) @@ -479,6 +543,16 @@
if (infoPtr->SelectedMonitor >= 0) MonSelRepaintSelected(infoPtr); + + if (bNotify) + { + MONSL_MONNMHDR nm; + + MonSelNotifyMonitor(infoPtr, + MSLN_MONITORCHANGED, + Index, + &nm); + } } }
@@ -494,6 +568,7 @@ infoPtr->SelectionFrame.cx = infoPtr->SelectionFrame.cy = 4; infoPtr->Margin.cx = infoPtr->Margin.cy = 20; infoPtr->SelectedMonitor = -1; + infoPtr->ControlExStyle = MSLM_EX_ALLOWSELECTDISABLED; return; }
@@ -813,7 +888,8 @@ if (Index >= 0 || (infoPtr->ControlExStyle & MSLM_EX_ALLOWSELECTNONE)) { MonSelSetCurSelMonitor(infoPtr, - Index); + Index, + TRUE); }
/* fall through */ @@ -965,7 +1041,8 @@ case MSLM_SETCURSEL: { Ret = MonSelSetCurSelMonitor(infoPtr, - (INT)wParam); + (INT)wParam, + FALSE); break; }
Modified: trunk/reactos/dll/cpl/desk/monslctl.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/monslctl.h?rev... ============================================================================== --- trunk/reactos/dll/cpl/desk/monslctl.h (original) +++ trunk/reactos/dll/cpl/desk/monslctl.h Sat Sep 29 23:12:21 2007 @@ -15,6 +15,44 @@ DWORD Flags; /* MSL_MIF_* */ LPARAM lParam; } MONSL_MONINFO, *PMONSL_MONINFO; + +typedef struct _MONSL_MONNMHDR +{ + NMHDR hdr; + INT Index; + /* NOTE: MonitorInfo is only valid if Index >= 0 */ + MONSL_MONINFO MonitorInfo; +} MONSL_MONNMHDR, *PMONSL_MONNMHDR; + +typedef struct _MONSL_MONNMMONITORCHANGING +{ + /* Used with MSLN_MONITORCHANGING */ + MONSL_MONNMHDR hdr; + INT PreviousSelected; + BOOL AllowChanging; +} MONSL_MONNMMONITORCHANGING, *PMONSL_MONNMMONITORCHANGING; + +/* + * MSLN_MONITORCHANGING + * This notification code is sent through WM_NOTIFY before another monitor + * can be selected. This notification is not sent in response to a + * MSLM_SETCURSEL message. + * + * lParam: PMONSL_MONNMMONITORCHANGING + * Change AllowChanging to FALSE to prevent the new monitor to + * be selected. + */ +#define MSLN_MONITORCHANGING 101 + +/* + * MSLN_MONITORCHANGED + * This notification code is sent through WM_NOTIFY after a new monitor + * was selected. This notification is not sent in response to a + * MSLM_SETCURSEL message. + * + * lParam: PMONSL_MONNMHDR + */ +#define MSLN_MONITORCHANGED 101
/* * MSLM_SETMONITORSINFO