6 static const TCHAR szMonitorSelWndClass
[] = TEXT("MONITORSELWNDCLASS");
8 typedef struct _MONSL_MON
13 } MONSL_MON
, *PMONSL_MON
;
15 typedef struct _MONITORSELWND
24 DWORD dwInternalFlags
;
35 PMONSL_MONINFO MonitorInfo
;
42 HBITMAP hbmDisabledPattern
;
44 } MONITORSELWND
, *PMONITORSELWND
;
47 MonSelNotify(IN PMONITORSELWND infoPtr
,
53 if (infoPtr
->hNotify
!= NULL
)
55 LPNMHDR pnmh
= (LPNMHDR
)data
;
57 pnmh
->hwndFrom
= infoPtr
->hSelf
;
58 pnmh
->idFrom
= GetWindowLongPtr(infoPtr
->hSelf
,
62 Ret
= SendMessage(infoPtr
->hNotify
,
72 MonSelNotifyMonitor(IN PMONITORSELWND infoPtr
,
75 IN OUT PMONSL_MONNMHDR pmonnmh
)
77 pmonnmh
->Index
= Index
;
81 pmonnmh
->MonitorInfo
= infoPtr
->MonitorInfo
[Index
];
85 ZeroMemory(&pmonnmh
->MonitorInfo
,
86 sizeof(pmonnmh
->MonitorInfo
));
89 return MonSelNotify(infoPtr
,
95 MonSelChangeFont(IN OUT PMONITORSELWND infoPtr
,
99 HFONT hOldFont
= infoPtr
->hFont
;
100 infoPtr
->hFont
= hFont
;
104 InvalidateRect(infoPtr
->hSelf
,
113 MonSelRectToScreen(IN PMONITORSELWND infoPtr
,
115 OUT PRECT prcOnScreen
)
118 OffsetRect(prcOnScreen
,
119 -infoPtr
->ScrollPos
.x
,
120 -infoPtr
->ScrollPos
.y
);
124 MonSelScreenToPt(IN PMONITORSELWND infoPtr
,
125 IN
const POINT
*pptOnScreen
,
128 ppt
->x
= pptOnScreen
->x
+ infoPtr
->ScrollPos
.x
;
129 ppt
->y
= pptOnScreen
->y
+ infoPtr
->ScrollPos
.y
;
133 MonSelMonInfoToRect(IN
const MONSL_MONINFO
*pMonInfo
,
136 prc
->left
= pMonInfo
->Position
.x
;
137 prc
->top
= pMonInfo
->Position
.y
;
138 prc
->right
= pMonInfo
->Position
.x
+ pMonInfo
->Size
.cx
;
139 prc
->bottom
= pMonInfo
->Position
.y
+ pMonInfo
->Size
.cy
;
143 MonSelHitTest(IN PMONITORSELWND infoPtr
,
149 if (infoPtr
->CanDisplay
)
151 MonSelScreenToPt(infoPtr
,
155 for (Index
= 0; Index
< (INT
)infoPtr
->MonitorsCount
; Index
++)
157 if (PtInRect(&infoPtr
->Monitors
[Index
].rc
,
170 MonSelUpdateExtent(IN OUT PMONITORSELWND infoPtr
)
175 /* NOTE: This routine calculates the extent of all monitor coordinates.
176 These are not control coordinates! */
177 if (infoPtr
->MonitorsCount
> 0)
179 MonSelMonInfoToRect(&infoPtr
->MonitorInfo
[0],
182 for (Index
= 1; Index
< infoPtr
->MonitorsCount
; Index
++)
184 MonSelMonInfoToRect(&infoPtr
->MonitorInfo
[Index
],
187 UnionRect(&infoPtr
->rcExtent
,
194 ZeroMemory(&infoPtr
->rcExtent
,
195 sizeof(infoPtr
->rcExtent
));
200 MonSelScaleRectRelative(IN
const RECT
*prcBaseFrom
,
201 IN
const RECT
*prcFrom
,
202 IN
const RECT
*prcBaseTo
,
205 SIZE BaseFrom
, BaseTo
, From
;
207 BaseFrom
.cx
= prcBaseFrom
->right
- prcBaseFrom
->left
;
208 BaseFrom
.cy
= prcBaseFrom
->bottom
- prcBaseFrom
->top
;
209 BaseTo
.cx
= prcBaseTo
->right
- prcBaseTo
->left
;
210 BaseTo
.cy
= prcBaseTo
->bottom
- prcBaseTo
->top
;
211 From
.cx
= prcFrom
->right
- prcFrom
->left
;
212 From
.cy
= prcFrom
->bottom
- prcFrom
->top
;
214 prcTo
->left
= prcBaseTo
->left
+ (((prcFrom
->left
- prcBaseFrom
->left
) * BaseTo
.cx
) / BaseFrom
.cx
);
215 prcTo
->top
= prcBaseTo
->top
+ (((prcFrom
->top
- prcBaseFrom
->top
) * BaseTo
.cy
) / BaseFrom
.cy
);
216 prcTo
->right
= prcTo
->left
+ ((From
.cx
* BaseTo
.cx
) / BaseFrom
.cx
);
217 prcTo
->bottom
= prcTo
->top
+ ((From
.cy
* BaseTo
.cy
) / BaseFrom
.cy
);
221 ScaleRectSizeFit(IN
const RECT
*prcContainerRect
,
222 IN OUT PRECT prcRectToScale
)
224 SIZE ContainerSize
, RectSize
;
226 ContainerSize
.cx
= prcContainerRect
->right
- prcContainerRect
->left
;
227 ContainerSize
.cy
= prcContainerRect
->bottom
- prcContainerRect
->top
;
228 RectSize
.cx
= prcRectToScale
->right
- prcRectToScale
->left
;
229 RectSize
.cy
= prcRectToScale
->bottom
- prcRectToScale
->top
;
231 if (((RectSize
.cx
* 0xFFF) / RectSize
.cy
) < ((ContainerSize
.cx
* 0xFFF) / ContainerSize
.cy
))
233 RectSize
.cx
= (RectSize
.cx
* ((ContainerSize
.cy
* 0xFFF) / RectSize
.cy
)) / 0xFFF;
234 RectSize
.cy
= ContainerSize
.cy
;
238 RectSize
.cy
= (RectSize
.cy
* ((ContainerSize
.cx
* 0xFFF) / RectSize
.cx
)) / 0xFFF;
239 RectSize
.cx
= ContainerSize
.cx
;
242 prcRectToScale
->right
= prcRectToScale
->left
+ RectSize
.cx
;
243 prcRectToScale
->bottom
= prcRectToScale
->top
+ RectSize
.cy
;
245 OffsetRect(prcRectToScale
,
246 prcContainerRect
->left
+ ((ContainerSize
.cx
- RectSize
.cx
) / 2),
247 prcContainerRect
->top
+ ((ContainerSize
.cy
- RectSize
.cy
) / 2));
251 MonSelRepaint(IN PMONITORSELWND infoPtr
)
255 MonSelRectToScreen(infoPtr
,
256 &infoPtr
->rcMonitors
,
258 InvalidateRect(infoPtr
->hSelf
,
264 MonSelRepaintMonitor(IN PMONITORSELWND infoPtr
,
269 if (Index
< infoPtr
->MonitorsCount
)
271 MonSelRectToScreen(infoPtr
,
272 &infoPtr
->Monitors
[Index
].rc
,
274 InvalidateRect(infoPtr
->hSelf
,
281 MonSelRepaintSelected(IN PMONITORSELWND infoPtr
)
283 if (infoPtr
->SelectedMonitor
>= 0)
285 MonSelRepaintMonitor(infoPtr
,
286 (DWORD
)infoPtr
->SelectedMonitor
);
291 MonSelResetMonitors(IN OUT PMONITORSELWND infoPtr
)
295 for (Index
= 0; Index
< infoPtr
->MonitorsCount
; Index
++)
297 if (infoPtr
->Monitors
[Index
].hFont
!= NULL
)
299 DeleteObject(infoPtr
->Monitors
[Index
].hFont
);
300 infoPtr
->Monitors
[Index
].hFont
= NULL
;
307 MonSelUpdateMonitorsInfo(IN OUT PMONITORSELWND infoPtr
,
310 RECT rcExtSurface
, rcExtDisplay
;
313 /* Recalculate rcExtent */
314 MonSelUpdateExtent(infoPtr
);
316 infoPtr
-> CanDisplay
= infoPtr
->MonitorsCount
!= 0 &&
317 (infoPtr
->ClientSize
.cx
> (2 * (infoPtr
->Margin
.cx
+ infoPtr
->SelectionFrame
.cx
))) &&
318 (infoPtr
->ClientSize
.cy
> (2 * (infoPtr
->Margin
.cy
+ infoPtr
->SelectionFrame
.cy
)));
320 if (infoPtr
->CanDisplay
)
322 /* Calculate the rectangle on the control in which may be painted */
323 rcExtSurface
.left
= infoPtr
->Margin
.cx
;
324 rcExtSurface
.top
= infoPtr
->Margin
.cy
;
325 rcExtSurface
.right
= rcExtSurface
.left
+ infoPtr
->ClientSize
.cx
- (2 * infoPtr
->Margin
.cx
);
326 rcExtSurface
.bottom
= rcExtSurface
.top
+ infoPtr
->ClientSize
.cy
- (2 * infoPtr
->Margin
.cy
);
328 /* Calculate the rectangle on the control that is actually painted on */
329 rcExtDisplay
.left
= rcExtDisplay
.top
= 0;
330 rcExtDisplay
.right
= infoPtr
->rcExtent
.right
- infoPtr
->rcExtent
.left
;
331 rcExtDisplay
.bottom
= infoPtr
->rcExtent
.bottom
- infoPtr
->rcExtent
.top
;
333 ScaleRectSizeFit(&rcExtSurface
,
336 infoPtr
->rcMonitors
= rcExtDisplay
;
338 /* Now that we know in which area all monitors are located,
339 calculate the monitors selection rectangles on the screen */
341 for (Index
= 0; Index
< infoPtr
->MonitorsCount
; Index
++)
343 MonSelMonInfoToRect(&infoPtr
->MonitorInfo
[Index
],
346 MonSelScaleRectRelative(&infoPtr
->rcExtent
,
348 &infoPtr
->rcMonitors
,
349 &infoPtr
->Monitors
[Index
].rc
);
352 MonSelResetMonitors(infoPtr
);
355 MonSelRepaint(infoPtr
);
359 InvalidateRect(infoPtr
->hSelf
,
366 MonSelSetMonitorsInfo(IN OUT PMONITORSELWND infoPtr
,
368 IN
const MONSL_MONINFO
*MonitorsInfo
)
373 if (infoPtr
->MonitorInfo
!= NULL
)
375 LocalFree((HLOCAL
)infoPtr
->MonitorInfo
);
376 infoPtr
->MonitorInfo
= NULL
;
378 MonSelResetMonitors(infoPtr
);
380 LocalFree((HLOCAL
)infoPtr
->Monitors
);
381 infoPtr
->Monitors
= NULL
;
383 infoPtr
->MonitorsCount
= 0;
388 infoPtr
->MonitorInfo
= (PMONSL_MONINFO
)LocalAlloc(LMEM_FIXED
,
389 dwMonitors
* sizeof(MONSL_MONINFO
));
390 if (infoPtr
->MonitorInfo
!= NULL
)
392 infoPtr
->Monitors
= (PMONSL_MON
)LocalAlloc(LMEM_FIXED
,
393 dwMonitors
* sizeof(MONSL_MON
));
394 if (infoPtr
->Monitors
!= NULL
)
396 CopyMemory(infoPtr
->MonitorInfo
,
398 dwMonitors
* sizeof(MONSL_MONINFO
));
399 ZeroMemory(infoPtr
->Monitors
,
400 dwMonitors
* sizeof(MONSL_MON
));
402 for (Index
= 0; Index
< dwMonitors
; Index
++)
404 _stprintf(infoPtr
->Monitors
[Index
].szCaption
,
409 infoPtr
->MonitorsCount
= dwMonitors
;
411 if (infoPtr
->SelectedMonitor
>= (INT
)infoPtr
->MonitorsCount
)
412 infoPtr
->SelectedMonitor
= -1;
414 if (!(infoPtr
->ControlExStyle
& MSLM_EX_ALLOWSELECTNONE
) && infoPtr
->SelectedMonitor
< 0)
415 infoPtr
->SelectedMonitor
= 0;
417 MonSelUpdateMonitorsInfo(infoPtr
,
422 LocalFree((HLOCAL
)infoPtr
->MonitorInfo
);
423 infoPtr
->MonitorInfo
= NULL
;
433 infoPtr
->SelectedMonitor
= -1;
435 if (!Ret
|| dwMonitors
== 0)
437 InvalidateRect(infoPtr
->hSelf
,
446 MonSelGetMonitorsInfo(IN PMONITORSELWND infoPtr
,
448 IN OUT PMONSL_MONINFO MonitorsInfo
)
452 if (dwMonitors
> infoPtr
->MonitorsCount
)
453 dwMonitors
= infoPtr
->MonitorsCount
;
455 CopyMemory(MonitorsInfo
,
456 infoPtr
->MonitorInfo
,
457 dwMonitors
* sizeof(MONSL_MONINFO
));
461 return infoPtr
->MonitorsCount
;
465 MonSelSetMonitorInfo(IN OUT PMONITORSELWND infoPtr
,
467 IN
const MONSL_MONINFO
*MonitorsInfo
)
469 if (Index
>= 0 && Index
< (INT
)infoPtr
->MonitorsCount
)
471 CopyMemory(&infoPtr
->MonitorInfo
[Index
],
473 sizeof(MONSL_MONINFO
));
475 MonSelUpdateMonitorsInfo(infoPtr
,
484 MonSelGetMonitorInfo(IN PMONITORSELWND infoPtr
,
486 IN OUT PMONSL_MONINFO MonitorsInfo
)
488 if (Index
>= 0 && Index
< (INT
)infoPtr
->MonitorsCount
)
490 CopyMemory(MonitorsInfo
,
491 &infoPtr
->MonitorInfo
[Index
],
492 sizeof(MONSL_MONINFO
));
500 MonSelGetMonitorRect(IN OUT PMONITORSELWND infoPtr
,
506 if (Index
< 0 || Index
>= infoPtr
->MonitorsCount
)
509 if (!infoPtr
->CanDisplay
)
512 MonSelRectToScreen(infoPtr
,
513 &infoPtr
->Monitors
[Index
].rc
,
516 rcClient
.left
= rcClient
.top
= 0;
517 rcClient
.right
= infoPtr
->ClientSize
.cx
;
518 rcClient
.bottom
= infoPtr
->ClientSize
.cy
;
520 return IntersectRect(&rc
,
526 MonSelSetCurSelMonitor(IN OUT PMONITORSELWND infoPtr
,
531 BOOL PreventSelect
= FALSE
;
534 if (Index
== -1 || Index
< (INT
)infoPtr
->MonitorsCount
)
536 if (Index
!= infoPtr
->SelectedMonitor
)
538 if ((infoPtr
->MonitorInfo
[Index
].Flags
& MSL_MIF_DISABLED
) &&
539 !(infoPtr
->ControlExStyle
& MSLM_EX_ALLOWSELECTDISABLED
))
541 PreventSelect
= TRUE
;
544 if (!PreventSelect
&& bNotify
)
546 MONSL_MONNMMONITORCHANGING nmi
;
548 nmi
.PreviousSelected
= infoPtr
->SelectedMonitor
;
549 nmi
.AllowChanging
= TRUE
;
551 MonSelNotifyMonitor(infoPtr
,
552 MSLN_MONITORCHANGING
,
556 PreventSelect
= (nmi
.AllowChanging
== FALSE
);
561 PrevSel
= infoPtr
->SelectedMonitor
;
562 infoPtr
->SelectedMonitor
= Index
;
566 MonSelRepaintMonitor(infoPtr
,
570 if (infoPtr
->SelectedMonitor
>= 0)
571 MonSelRepaintSelected(infoPtr
);
577 MonSelNotifyMonitor(infoPtr
,
592 MonSelCreate(IN OUT PMONITORSELWND infoPtr
)
594 infoPtr
->SelectionFrame
.cx
= infoPtr
->SelectionFrame
.cy
= 4;
595 infoPtr
->Margin
.cx
= infoPtr
->Margin
.cy
= 20;
596 infoPtr
->SelectedMonitor
= -1;
597 infoPtr
->ControlExStyle
= MSLM_EX_ALLOWSELECTDISABLED
| MSLM_EX_HIDENUMBERONSINGLE
|
598 MSLM_EX_SELECTONRIGHTCLICK
;
603 MonSelDestroy(IN OUT PMONITORSELWND infoPtr
)
605 /* Free all monitors */
606 MonSelSetMonitorsInfo(infoPtr
,
610 if (infoPtr
->hbrDisabled
!= NULL
)
612 DeleteObject(infoPtr
->hbrDisabled
);
613 infoPtr
->hbrDisabled
= NULL
;
616 if (infoPtr
->hbmDisabledPattern
!= NULL
)
618 DeleteObject(infoPtr
->hbmDisabledPattern
);
619 infoPtr
->hbmDisabledPattern
= NULL
;
624 MonSelSetExtendedStyle(IN OUT PMONITORSELWND infoPtr
,
625 IN DWORD dwExtendedStyle
)
627 if (dwExtendedStyle
!= infoPtr
->ControlExStyle
)
629 infoPtr
->ControlExStyle
= dwExtendedStyle
;
631 /* Repaint the control */
632 InvalidateRect(infoPtr
->hSelf
,
641 MonSelGetExtendedStyle(IN PMONITORSELWND infoPtr
)
643 return infoPtr
->ControlExStyle
;
647 MonSelGetMonitorFont(IN OUT PMONITORSELWND infoPtr
,
654 HFONT hPrevFont
, hFont
;
657 hFont
= infoPtr
->Monitors
[Index
].hFont
;
659 GetObject(infoPtr
->hFont
,
663 rcsize
.cx
= infoPtr
->Monitors
[Index
].rc
.right
- infoPtr
->Monitors
[Index
].rc
.left
-
664 (2 * infoPtr
->SelectionFrame
.cx
) - 2;
665 rcsize
.cy
= infoPtr
->Monitors
[Index
].rc
.bottom
- infoPtr
->Monitors
[Index
].rc
.top
-
666 (2 * infoPtr
->SelectionFrame
.cy
) - 2;
667 rcsize
.cy
= (rcsize
.cy
* 60) / 100;
669 len
= _tcslen(infoPtr
->Monitors
[Index
].szCaption
);
671 hPrevFont
= SelectObject(hDC
,
674 if (GetTextMetrics(hDC
,
677 lf
.lfWeight
= FW_SEMIBOLD
;
678 lf
.lfHeight
= -MulDiv(rcsize
.cy
- tm
.tmExternalLeading
,
683 hFont
= CreateFontIndirect(&lf
);
685 infoPtr
->Monitors
[Index
].hFont
= hFont
;
696 MonSelDrawDisabledRect(IN OUT PMONITORSELWND infoPtr
,
702 if (infoPtr
->hbrDisabled
== NULL
)
704 static const DWORD Pattern
[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
706 if (infoPtr
->hbmDisabledPattern
== NULL
)
708 infoPtr
->hbmDisabledPattern
= CreateBitmap(8,
715 if (infoPtr
->hbmDisabledPattern
!= NULL
)
716 infoPtr
->hbrDisabled
= CreatePatternBrush(infoPtr
->hbmDisabledPattern
);
719 if (infoPtr
->hbrDisabled
!= NULL
)
721 /* FIXME - implement */
728 MonSelPaint(IN OUT PMONITORSELWND infoPtr
,
730 IN
const RECT
*prcUpdate
)
732 COLORREF crPrevText
, crPrevText2
;
733 HFONT hFont
, hPrevFont
;
734 HBRUSH hbBk
, hbOldBk
;
741 bHideNumber
= (infoPtr
->ControlExStyle
& MSLM_EX_HIDENUMBERS
) ||
742 ((infoPtr
->MonitorsCount
== 1) && (infoPtr
->ControlExStyle
& MSLM_EX_HIDENUMBERONSINGLE
));
744 hbBk
= GetSysColorBrush(COLOR_BACKGROUND
);
745 hpFg
= CreatePen(PS_SOLID
,
747 GetSysColor(COLOR_HIGHLIGHTTEXT
));
749 hbOldBk
= SelectObject(hDC
,
751 hpOldFg
= SelectObject(hDC
,
753 iPrevBkMode
= SetBkMode(hDC
,
755 crPrevText
= SetTextColor(hDC
,
756 GetSysColor(COLOR_HIGHLIGHTTEXT
));
758 for (Index
= 0; Index
< infoPtr
->MonitorsCount
; Index
++)
760 MonSelRectToScreen(infoPtr
,
761 &infoPtr
->Monitors
[Index
].rc
,
764 if (!IntersectRect(&rctmp
,
771 if ((INT
)Index
== infoPtr
->SelectedMonitor
)
775 (HBRUSH
)(COLOR_HIGHLIGHT
+ 1));
777 if (infoPtr
->HasFocus
&& !(infoPtr
->UIState
& UISF_HIDEFOCUS
))
779 /* NOTE: We need to switch the text color to the default, because
780 DrawFocusRect draws a solid line if the text is white! */
782 crPrevText2
= SetTextColor(hDC
,
794 -infoPtr
->SelectionFrame
.cx
,
795 -infoPtr
->SelectionFrame
.cy
);
809 hFont
= MonSelGetMonitorFont(infoPtr
,
814 hPrevFont
= SelectObject(hDC
,
818 infoPtr
->Monitors
[Index
].szCaption
,
821 DT_VCENTER
| DT_CENTER
| DT_NOPREFIX
| DT_SINGLELINE
);
828 if (infoPtr
->MonitorInfo
[Index
].Flags
& MSL_MIF_DISABLED
)
834 MonSelDrawDisabledRect(infoPtr
,
851 MonSelContextMenu(IN OUT PMONITORSELWND infoPtr
,
855 MONSL_MONNMBUTTONCLICKED nm
;
858 if (!infoPtr
->HasFocus
)
859 SetFocus(infoPtr
->hSelf
);
864 Index
= MonSelHitTest(infoPtr
,
867 MonSelNotifyMonitor(infoPtr
,
870 (PMONSL_MONNMHDR
)&nm
);
872 /* Send a WM_CONTEXTMENU notification */
873 MapWindowPoints(infoPtr
->hSelf
,
878 SendMessage(infoPtr
->hSelf
,
880 (WPARAM
)infoPtr
->hSelf
,
885 static LRESULT CALLBACK
886 MonitorSelWndProc(IN HWND hwnd
,
891 PMONITORSELWND infoPtr
;
894 infoPtr
= (PMONITORSELWND
)GetWindowLongPtrW(hwnd
,
897 if (infoPtr
== NULL
&& uMsg
!= WM_CREATE
)
899 goto HandleDefaultMessage
;
912 if (!GetUpdateRect(hwnd
,
922 hDC
= BeginPaint(hwnd
,
930 if (infoPtr
->CanDisplay
)
947 if (!(infoPtr
->ControlExStyle
& MSLM_EX_SELECTONRIGHTCLICK
))
953 case WM_LBUTTONDBLCLK
:
959 pt
.x
= (LONG
)LOWORD(lParam
);
960 pt
.y
= (LONG
)HIWORD(lParam
);
962 Index
= MonSelHitTest(infoPtr
,
964 if (Index
>= 0 || (infoPtr
->ControlExStyle
& MSLM_EX_ALLOWSELECTNONE
))
966 MonSelSetCurSelMonitor(infoPtr
,
976 if (!infoPtr
->HasFocus
)
983 MonSelContextMenu(infoPtr
,
984 (SHORT
)LOWORD(lParam
),
985 (SHORT
)HIWORD(lParam
));
993 virtKey
= (lParam
!= 0 ? (INT
)((LPMSG
)lParam
)->wParam
: 0);
998 /* change the UI status */
999 SendMessage(GetAncestor(hwnd
,
1002 MAKEWPARAM(UIS_INITIALIZE
,
1009 Ret
|= DLGC_WANTARROWS
;
1015 infoPtr
->HasFocus
= TRUE
;
1016 MonSelRepaintSelected(infoPtr
);
1022 infoPtr
->HasFocus
= FALSE
;
1023 MonSelRepaintSelected(infoPtr
);
1027 case WM_UPDATEUISTATE
:
1029 DWORD OldUIState
= infoPtr
->UIState
;
1030 switch (LOWORD(wParam
))
1033 infoPtr
->UIState
|= HIWORD(wParam
);
1037 infoPtr
->UIState
&= ~HIWORD(wParam
);
1041 if (infoPtr
->UIState
!= OldUIState
)
1042 MonSelRepaintSelected(infoPtr
);
1048 Ret
= (LRESULT
)MonSelChangeFont(infoPtr
,
1050 (BOOL
)LOWORD(lParam
));
1056 infoPtr
->ClientSize
.cx
= LOWORD(lParam
);
1057 infoPtr
->ClientSize
.cy
= HIWORD(lParam
);
1059 /* Don't let MonSelUpdateMonitorsInfo repaint the control
1060 because this won't work properly in case the control
1062 MonSelUpdateMonitorsInfo(infoPtr
,
1064 InvalidateRect(infoPtr
->hSelf
,
1072 Ret
= (LRESULT
)infoPtr
->hFont
;
1078 infoPtr
->Enabled
= ((BOOL
)wParam
!= FALSE
);
1079 MonSelRepaint(infoPtr
);
1083 case WM_STYLECHANGED
:
1085 if (wParam
== GWL_STYLE
)
1087 unsigned int OldEnabled
= infoPtr
->Enabled
;
1088 infoPtr
->Enabled
= !(((LPSTYLESTRUCT
)lParam
)->styleNew
& WS_DISABLED
);
1090 if (OldEnabled
!= infoPtr
->Enabled
)
1091 MonSelRepaint(infoPtr
);
1096 case MSLM_SETMONITORSINFO
:
1098 Ret
= MonSelSetMonitorsInfo(infoPtr
,
1100 (const MONSL_MONINFO
*)lParam
);
1104 case MSLM_GETMONITORSINFO
:
1106 Ret
= MonSelGetMonitorsInfo(infoPtr
,
1108 (PMONSL_MONINFO
)lParam
);
1112 case MSLM_GETMONITORINFOCOUNT
:
1114 Ret
= infoPtr
->MonitorsCount
;
1120 Ret
= MonSelHitTest(infoPtr
,
1121 (const POINT
*)wParam
);
1125 case MSLM_SETCURSEL
:
1127 Ret
= MonSelSetCurSelMonitor(infoPtr
,
1133 case MSLM_GETCURSEL
:
1135 Ret
= infoPtr
->SelectedMonitor
;
1139 case MSLM_SETMONITORINFO
:
1141 Ret
= MonSelSetMonitorInfo(infoPtr
,
1143 (const MONSL_MONINFO
*)lParam
);
1147 case MSLM_GETMONITORINFO
:
1149 Ret
= MonSelGetMonitorInfo(infoPtr
,
1151 (PMONSL_MONINFO
)lParam
);
1155 case MSLM_SETEXSTYLE
:
1157 Ret
= MonSelSetExtendedStyle(infoPtr
,
1162 case MSLM_GETEXSTYLE
:
1164 Ret
= MonSelGetExtendedStyle(infoPtr
);
1168 case MSLM_GETMONITORRECT
:
1170 Ret
= (LRESULT
)MonSelGetMonitorRect(infoPtr
,
1178 infoPtr
= (PMONITORSELWND
) HeapAlloc(GetProcessHeap(),
1180 sizeof(MONITORSELWND
));
1181 if (infoPtr
== NULL
)
1188 sizeof(MONITORSELWND
));
1189 infoPtr
->hSelf
= hwnd
;
1190 infoPtr
->hNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
1191 infoPtr
->Enabled
= !(((LPCREATESTRUCTW
)lParam
)->style
& WS_DISABLED
);
1192 infoPtr
->UIState
= SendMessage(hwnd
,
1197 SetWindowLongPtrW(hwnd
,
1201 MonSelCreate(infoPtr
);
1207 MonSelDestroy(infoPtr
);
1209 HeapFree(GetProcessHeap(),
1212 SetWindowLongPtrW(hwnd
,
1220 HandleDefaultMessage
:
1221 Ret
= DefWindowProcW(hwnd
,
1233 RegisterMonitorSelectionControl(IN HINSTANCE hInstance
)
1237 wc
.style
= CS_DBLCLKS
;
1238 wc
.lpfnWndProc
= MonitorSelWndProc
;
1239 wc
.cbWndExtra
= sizeof(PMONITORSELWND
);
1240 wc
.hInstance
= hInstance
;
1241 wc
.hCursor
= LoadCursorW(NULL
,
1243 wc
.hbrBackground
= (HBRUSH
)(COLOR_APPWORKSPACE
+ 1);
1244 wc
.lpszClassName
= szMonitorSelWndClass
;
1246 return RegisterClass(&wc
) != 0;
1250 UnregisterMonitorSelectionControl(IN HINSTANCE hInstance
)
1252 UnregisterClassW(szMonitorSelWndClass
,