-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.cpp
More file actions
34 lines (27 loc) · 1.02 KB
/
Util.cpp
File metadata and controls
34 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Util.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
void EnsureOnScreen(TForm *Form)
{
HMONITOR hMonitor = MonitorFromWindow(Form->Handle, MONITOR_DEFAULTTONEAREST);
MONITORINFO MonitorInfo;
memset(&MonitorInfo, 0, sizeof(MonitorInfo));
MonitorInfo.cbSize = sizeof(MonitorInfo);
GetMonitorInfo(hMonitor, &MonitorInfo);
TRect WorkArea = MonitorInfo.rcWork;
if (Form->Left + Form->Width > WorkArea.Right)
Form->Left = WorkArea.Right - Form->Width;
if (Form->Top + Form->Height > WorkArea.Bottom)
Form->Top = WorkArea.Bottom - Form->Height;
if (Form->Left < WorkArea.Left)
Form->Left = WorkArea.Left;
if (Form->Top < WorkArea.Top)
Form->Top = WorkArea.Top;
/*
Left = PrimMonitorRect.Right - Width - GetSystemMetrics(SM_CXSIZEFRAME);
Top = PrimMonitorRect.Bottom - Height - GetSystemMetrics(SM_CYSIZEFRAME);
*/
}