57 if (infoPtr->hNotify !=
NULL)
81 pmonnmh->Index =
Index;
85 pmonnmh->MonitorInfo = infoPtr->MonitorInfo[
Index];
90 sizeof(pmonnmh->MonitorInfo));
103 HFONT hOldFont = infoPtr->hFont;
104 infoPtr->hFont =
hFont;
123 -infoPtr->ScrollPos.x,
124 -infoPtr->ScrollPos.y);
132 ppt->x = pptOnScreen->x + infoPtr->ScrollPos.x;
133 ppt->y = pptOnScreen->y + infoPtr->ScrollPos.y;
140 prc->
left = pMonInfo->Position.x;
141 prc->
top = pMonInfo->Position.y;
142 prc->
right = pMonInfo->Position.x + pMonInfo->Size.cx;
143 prc->
bottom = pMonInfo->Position.y + pMonInfo->Size.cy;
153 if (infoPtr->CanDisplay)
181 if (infoPtr->MonitorsCount > 0)
199 sizeof(infoPtr->rcExtent));
209 SIZE BaseFrom, BaseTo, From;
211 BaseFrom.
cx = prcBaseFrom->right - prcBaseFrom->left;
212 BaseFrom.
cy = prcBaseFrom->bottom - prcBaseFrom->top;
213 BaseTo.
cx = prcBaseTo->right - prcBaseTo->left;
214 BaseTo.
cy = prcBaseTo->bottom - prcBaseTo->top;
215 From.
cx = prcFrom->right - prcFrom->left;
216 From.
cy = prcFrom->bottom - prcFrom->top;
218 prcTo->left = prcBaseTo->left + (((prcFrom->left - prcBaseFrom->left) * BaseTo.
cx) / BaseFrom.
cx);
219 prcTo->top = prcBaseTo->top + (((prcFrom->top - prcBaseFrom->top) * BaseTo.
cy) / BaseFrom.
cy);
220 prcTo->right = prcTo->left + ((From.
cx * BaseTo.
cx) / BaseFrom.
cx);
221 prcTo->bottom = prcTo->top + ((From.
cy * BaseTo.
cy) / BaseFrom.
cy);
228 SIZE ContainerSize, RectSize;
230 ContainerSize.
cx = prcContainerRect->right - prcContainerRect->left;
231 ContainerSize.
cy = prcContainerRect->bottom - prcContainerRect->top;
232 RectSize.
cx = prcRectToScale->right - prcRectToScale->left;
233 RectSize.
cy = prcRectToScale->bottom - prcRectToScale->top;
235 if (((RectSize.
cx * 0xFFF) / RectSize.
cy) < ((ContainerSize.
cx * 0xFFF) / ContainerSize.
cy))
237 RectSize.
cx = (RectSize.
cx * ((ContainerSize.
cy * 0xFFF) / RectSize.
cy)) / 0xFFF;
238 RectSize.
cy = ContainerSize.
cy;
242 RectSize.
cy = (RectSize.
cy * ((ContainerSize.
cx * 0xFFF) / RectSize.
cx)) / 0xFFF;
243 RectSize.
cx = ContainerSize.
cx;
246 prcRectToScale->right = prcRectToScale->left + RectSize.
cx;
247 prcRectToScale->bottom = prcRectToScale->top + RectSize.
cy;
250 prcContainerRect->left + ((ContainerSize.
cx - RectSize.
cx) / 2),
251 prcContainerRect->top + ((ContainerSize.
cy - RectSize.
cy) / 2));
260 &infoPtr->rcMonitors,
266 if (!
EqualRect(&infoPtr->rcMonitors, &infoPtr->rcOldMonitors) &&
267 infoPtr->rcOldMonitors.right != infoPtr->rcOldMonitors.left)
271 infoPtr->rcOldMonitors = infoPtr->rcMonitors;
286 if (infoPtr->IsDraggingMonitor)
289 &infoPtr->rcDragging,
298 &infoPtr->Monitors[
Index].rc,
314 if (infoPtr->SelectedMonitor >= 0)
317 (
DWORD)infoPtr->SelectedMonitor);
328 if (infoPtr->Monitors[
Index].hFont !=
NULL)
341 RECT rcExtSurface, rcExtDisplay;
347 infoPtr-> CanDisplay = infoPtr->MonitorsCount != 0 &&
348 (infoPtr->ClientSize.cx > (2 * (infoPtr->Margin.cx + infoPtr->SelectionFrame.cx))) &&
349 (infoPtr->ClientSize.cy > (2 * (infoPtr->Margin.cy + infoPtr->SelectionFrame.cy)));
351 if (infoPtr->CanDisplay)
354 rcExtSurface.
left = infoPtr->Margin.cx;
355 rcExtSurface.
top = infoPtr->Margin.cy;
356 rcExtSurface.
right = rcExtSurface.
left + infoPtr->ClientSize.cx - (2 * infoPtr->Margin.cx);
357 rcExtSurface.
bottom = rcExtSurface.
top + infoPtr->ClientSize.cy - (2 * infoPtr->Margin.cy);
360 rcExtDisplay.
left = rcExtDisplay.
top = 0;
361 rcExtDisplay.
right = infoPtr->rcExtent.right - infoPtr->rcExtent.left;
362 rcExtDisplay.
bottom = infoPtr->rcExtent.bottom - infoPtr->rcExtent.top;
367 infoPtr->rcOldMonitors = infoPtr->rcMonitors;
368 infoPtr->rcMonitors = rcExtDisplay;
380 &infoPtr->rcMonitors,
381 &infoPtr->Monitors[
Index].rc);
405 if (infoPtr->DraggingMonitor >= 0)
408 if (infoPtr->MonitorInfo !=
NULL)
411 infoPtr->MonitorInfo =
NULL;
416 infoPtr->Monitors =
NULL;
418 infoPtr->MonitorsCount = 0;
425 if (infoPtr->MonitorInfo !=
NULL)
429 if (infoPtr->Monitors !=
NULL)
444 infoPtr->MonitorsCount = dwMonitors;
446 if (infoPtr->SelectedMonitor >= (
INT)infoPtr->MonitorsCount)
447 infoPtr->SelectedMonitor = -1;
450 infoPtr->SelectedMonitor = 0;
458 infoPtr->MonitorInfo =
NULL;
468 infoPtr->SelectedMonitor = -1;
470 if (!Ret || dwMonitors == 0)
487 if (dwMonitors > infoPtr->MonitorsCount)
488 dwMonitors = infoPtr->MonitorsCount;
491 infoPtr->MonitorInfo,
496 return infoPtr->MonitorsCount;
504 if (infoPtr->DraggingMonitor < 0 &&
527 &infoPtr->MonitorInfo[
Index],
545 if (!infoPtr->CanDisplay)
549 &infoPtr->Monitors[
Index].rc,
552 rcClient.
left = rcClient.
top = 0;
553 rcClient.
right = infoPtr->ClientSize.cx;
554 rcClient.
bottom = infoPtr->ClientSize.cy;
570 if (infoPtr->DraggingMonitor < 0 &&
573 if (
Index != infoPtr->SelectedMonitor)
578 PreventSelect =
TRUE;
581 if (!PreventSelect && bNotify)
598 PrevSel = infoPtr->SelectedMonitor;
599 infoPtr->SelectedMonitor =
Index;
607 if (infoPtr->SelectedMonitor >= 0)
631 infoPtr->SelectionFrame.cx = infoPtr->SelectionFrame.cy = 4;
632 infoPtr->Margin.cx = infoPtr->Margin.cy = 20;
633 infoPtr->SelectedMonitor = -1;
634 infoPtr->DraggingMonitor = -1;
648 if (infoPtr->hbrDisabled !=
NULL)
651 infoPtr->hbrDisabled =
NULL;
654 if (infoPtr->hbmDisabledPattern !=
NULL)
657 infoPtr->hbmDisabledPattern =
NULL;
665 if (infoPtr->DraggingMonitor >= 0)
668 if (dwExtendedStyle != infoPtr->ControlExStyle)
670 infoPtr->ControlExStyle = dwExtendedStyle;
684 return infoPtr->ControlExStyle;
704 rcsize.
cx = infoPtr->Monitors[
Index].rc.right - infoPtr->Monitors[
Index].rc.left -
705 (2 * infoPtr->SelectionFrame.cx) - 2;
706 rcsize.
cy = infoPtr->Monitors[
Index].rc.bottom - infoPtr->Monitors[
Index].rc.top -
707 (2 * infoPtr->SelectionFrame.cy) - 2;
708 rcsize.
cy = (rcsize.
cy * 60) / 100;
743 if (infoPtr->hbrDisabled ==
NULL)
745 static const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
747 if (infoPtr->hbmDisabledPattern ==
NULL)
756 if (infoPtr->hbmDisabledPattern !=
NULL)
760 if (infoPtr->hbrDisabled !=
NULL)
779 if ((
INT)
Index == infoPtr->SelectedMonitor)
785 if (infoPtr->HasFocus && !(infoPtr->UIState & UISF_HIDEFOCUS))
802 -infoPtr->SelectionFrame.cx,
803 -infoPtr->SelectionFrame.cy);
826 infoPtr->Monitors[
Index].szCaption,
854 HBRUSH hbBk, hbOldBk;
880 if (infoPtr->IsDraggingMonitor &&
887 &infoPtr->Monitors[
Index].rc,
904 if (infoPtr->IsDraggingMonitor &&
905 infoPtr->DraggingMonitor >= 0)
908 &infoPtr->rcDragging,
917 (
DWORD)infoPtr->DraggingMonitor,
944 if (!infoPtr->HasFocus)
980 rc.
right = infoPtr->ClientSize.cx;
981 rc.
bottom = infoPtr->ClientSize.cy;
1005 if (infoPtr->CanDisplay)
1010 if (infoPtr->ptDrag.x != ppt->x ||
1011 infoPtr->ptDrag.y != ppt->y)
1013 infoPtr->ptDrag = *ppt;
1015 rcPrev = infoPtr->rcDragging;
1018 prc = &infoPtr->Monitors[infoPtr->DraggingMonitor].rc;
1019 infoPtr->rcDragging.
left = ppt->x - infoPtr->DraggingMargin.cx;
1020 infoPtr->rcDragging.top = ppt->y - infoPtr->DraggingMargin.cy;
1021 infoPtr->rcDragging.right = infoPtr->rcDragging.left + (
prc->
right -
prc->
left);
1022 infoPtr->rcDragging.bottom = infoPtr->rcDragging.top + (
prc->
bottom -
prc->
top);
1029 if (hRgnPrev !=
NULL)
1032 infoPtr->rcDragging.left - rcPrev.
left,
1033 infoPtr->rcDragging.top - rcPrev.
top,
1055 &infoPtr->rcDragging,
1071 if (infoPtr->DraggingMonitor >= 0)
1074 &infoPtr->ptDragBegin);
1077 infoPtr->DraggingMonitor = -1;
1079 if (infoPtr->CanDisplay)
1085 infoPtr->IsDraggingMonitor =
FALSE;
1092 infoPtr->IsDraggingMonitor =
FALSE;
1109 infoPtr->IsDraggingMonitor =
FALSE;
1115 infoPtr->ptDrag = infoPtr->ptDragBegin =
pt;
1116 infoPtr->DraggingMonitor = (
INT)
Index;
1118 infoPtr->DraggingMargin.cx = ppt->x - infoPtr->Monitors[
Index].rc.left;
1119 infoPtr->DraggingMargin.cy = ppt->y - infoPtr->Monitors[
Index].rc.top;
1120 infoPtr->rcDragging = infoPtr->Monitors[
Index].rc;
1134 if (infoPtr->DraggingMonitor >= 0)
1140 if (!infoPtr->IsDraggingMonitor)
1145 rcDrag.
left = infoPtr->Monitors[infoPtr->DraggingMonitor].rc.left + infoPtr->DraggingMargin.cx - (szDrag.
cx / 2);
1146 rcDrag.
top = infoPtr->Monitors[infoPtr->DraggingMonitor].rc.top + infoPtr->DraggingMargin.cy - (szDrag.
cy / 2);
1154 infoPtr->IsDraggingMonitor =
TRUE;
1181 goto HandleDefaultMessage;
1353 case WM_UPDATEUISTATE:
1362 OldUIState = infoPtr->
UIState;
1374 if (infoPtr->
UIState != OldUIState)
1416 case WM_STYLECHANGED:
1420 unsigned int OldEnabled = infoPtr->
Enabled;
1423 if (OldEnabled != infoPtr->
Enabled)
1586 if (infoPtr ==
NULL)
1625 HandleDefaultMessage:
static DWORD MonSelGetMonitorsInfo(IN PMONITORSELWND infoPtr, IN DWORD dwMonitors, IN OUT PMONSL_MONINFO MonitorsInfo)
#define MSLM_GETMONITORINFOCOUNT
static INT MonSelGetMonitorRect(IN OUT PMONITORSELWND infoPtr, IN INT Index, OUT PRECT prc)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
struct _MONSL_MONINFO * PMONSL_MONINFO
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
static DWORD MonSelGetExtendedStyle(IN PMONITORSELWND infoPtr)
#define MSLM_EX_SELECTONRIGHTCLICK
#define MSLM_SETMONITORSINFO
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
static VOID MonSelPaint(IN OUT PMONITORSELWND infoPtr, IN HDC hDC, IN const RECT *prcUpdate)
#define MSLM_SETMONITORINFO
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define MSLM_EX_ALLOWSELECTDISABLED
static VOID MonSelApplyCursorClipping(IN PMONITORSELWND infoPtr, IN BOOL bClip)
static BOOL MonSelSetMonitorsInfo(IN OUT PMONITORSELWND infoPtr, IN DWORD dwMonitors, IN const MONSL_MONINFO *MonitorsInfo)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
static VOID MonSelScreenToPt(IN PMONITORSELWND infoPtr, IN const POINT *pptOnScreen, OUT PPOINT ppt)
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define MSLM_EX_SELECTBYNUMKEY
GLint GLint GLint GLint GLint x
#define COLOR_APPWORKSPACE
HWND WINAPI SetFocus(_In_opt_ HWND)
struct _MONITORSELWND MONITORSELWND
static VOID MonSelRepaintSelected(IN PMONITORSELWND infoPtr)
static BOOL MonSelSetMonitorInfo(IN OUT PMONITORSELWND infoPtr, IN INT Index, IN const MONSL_MONINFO *MonitorsInfo)
#define GetWindowLongPtrW
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
static VOID MonSelRectToScreen(IN PMONITORSELWND infoPtr, IN const RECT *prc, OUT PRECT prcOnScreen)
static VOID MonSelScaleRectRelative(IN const RECT *prcBaseFrom, IN const RECT *prcFrom, IN const RECT *prcBaseTo, OUT PRECT prcTo)
DWORD WINAPI GetSysColor(_In_ int)
struct tagNMHDR * LPNMHDR
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static INT MonSelHitTest(IN PMONITORSELWND infoPtr, IN const POINT *ppt)
static HFONT MonSelChangeFont(IN OUT PMONITORSELWND infoPtr, IN HFONT hFont, IN BOOL Redraw)
#define MSLM_GETMONITORRECT
static VOID MonSelDestroy(IN OUT PMONITORSELWND infoPtr)
static VOID MonSelContextMenu(IN OUT PMONITORSELWND infoPtr, IN SHORT x, IN SHORT y)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
#define MSLM_EX_HIDENUMBERS
static VOID MonSelRepaint(IN PMONITORSELWND infoPtr)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
struct _MONSL_MON MONSL_MON
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static const TCHAR szMonitorSelWndClass[]
static BOOL MonSelDrawDisabledRect(IN OUT PMONITORSELWND infoPtr, IN HDC hDC, IN const RECT *prc)
static LRESULT CALLBACK MonitorSelWndProc(IN HWND hwnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
static VOID MonSelDrag(IN OUT PMONITORSELWND infoPtr, IN PPOINT ppt)
VOID UnregisterMonitorSelectionControl(IN HINSTANCE hInstance)
#define COLOR_HIGHLIGHTTEXT
#define MSLM_EX_SELECTBYARROWKEY
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
BOOL WINAPI ScrollDC(_In_ HDC, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT)
struct _MONSL_MON * PMONSL_MON
#define MSLN_MONITORCHANGING
static BOOL MonSelSetExtendedStyle(IN OUT PMONITORSELWND infoPtr, IN DWORD dwExtendedStyle)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
#define MSLM_EX_ALLOWSELECTNONE
struct tagSTYLESTRUCT * LPSTYLESTRUCT
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
PMONSL_MONINFO MonitorInfo
static VOID MonSelCancelDragging(IN OUT PMONITORSELWND infoPtr)
_In_ WDFCOLLECTION _In_ ULONG Index
#define MSLM_EX_HIDENUMBERONSINGLE
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI GetSystemMetrics(_In_ int)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI UnionRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static VOID MonSelMoveDragRect(IN OUT PMONITORSELWND infoPtr, IN PPOINT ppt)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static VOID MonSelUpdateExtent(IN OUT PMONITORSELWND infoPtr)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static VOID ScaleRectSizeFit(IN const RECT *prcContainerRect, IN OUT PRECT prcRectToScale)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
static BOOL MonSelGetMonitorInfo(IN PMONITORSELWND infoPtr, IN INT Index, IN OUT PMONSL_MONINFO MonitorsInfo)
static VOID MonSelRepaintMonitor(IN PMONITORSELWND infoPtr, IN DWORD Index)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
static VOID MonSelCreate(IN OUT PMONITORSELWND infoPtr)
struct tagCREATESTRUCTW * LPCREATESTRUCTW
HBITMAP hbmDisabledPattern
#define CreateFontIndirect
static HFONT MonSelGetMonitorFont(IN OUT PMONITORSELWND infoPtr, IN HDC hDC, IN INT Index)
GLint GLint GLint GLint GLint GLint y
static VOID MonSelInitDragging(IN OUT PMONITORSELWND infoPtr, IN DWORD Index, IN PPOINT ppt)
#define MSLN_MONITORCHANGED
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
BOOL WINAPI ReleaseCapture(void)
static VOID MonSelMonInfoToRect(IN const MONSL_MONINFO *pMonInfo, OUT PRECT prc)
struct _MONITORSELWND * PMONITORSELWND
static VOID MonSelPaintMonitor(IN OUT PMONITORSELWND infoPtr, IN HDC hDC, IN DWORD Index, IN OUT PRECT prc, IN COLORREF crDefFontColor, IN BOOL bHideNumber)
#define SetWindowLongPtrW
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
static VOID MonSelResetMonitors(IN OUT PMONITORSELWND infoPtr)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define MSLM_GETMONITORSINFO
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define MSLM_GETMONITORINFO
static LRESULT MonSelNotifyMonitor(IN PMONITORSELWND infoPtr, IN UINT code, IN INT Index, IN OUT PMONSL_MONNMHDR pmonnmh)
static VOID MonSelUpdateMonitorsInfo(IN OUT PMONITORSELWND infoPtr, IN BOOL bRepaint)
#define HeapFree(x, y, z)
static LRESULT MonSelNotify(IN PMONITORSELWND infoPtr, IN UINT code, IN OUT PVOID data)
static BOOL MonSelSetCurSelMonitor(IN OUT PMONITORSELWND infoPtr, IN INT Index, IN BOOL bNotify)
BOOL RegisterMonitorSelectionControl(IN HINSTANCE hInstance)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)