-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSelectProjectScreen.pas
98 lines (84 loc) · 2.85 KB
/
SelectProjectScreen.pas
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
unit SelectProjectScreen;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TFSelectProjectScreen = class(TForm)
Label1: TLabel;
CrossHair: TImage;
BCancel: TButton;
Timer1: TTimer;
LScreen: TLabel;
procedure CrossHairMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure CrossHairMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BCancelClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MonitorNum : integer;
end;
var
FSelectProjectScreen: TFSelectProjectScreen;
implementation
uses Appear, SBMain;
{$R *.dfm}
procedure TFSelectProjectScreen.CrossHairMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Screen.Cursor := crCross;
SetCapture(Self.Handle);
Timer1.Enabled := true;
end;
procedure TFSelectProjectScreen.CrossHairMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var hMonitor, hPrimary : TMonitor;
begin
ReleaseCapture;
Screen.Cursor := crDefault;
Timer1.Enabled := false;
if not PtInRect( Self.BoundsRect, Mouse.CursorPos ) then begin
hMonitor := Screen.Monitors[MonitorNum-1];
FSongbase.DefaultScreen := MonitorNum;
FSongbase.ProjectScreen := MonitorNum;
FSongbase.szDisplaySize.cx := hMonitor.Width;
FSongbase.szDisplaySize.cy := hMonitor.Height;
FSongbase.ptDisplayOrigin.X := hMonitor.Left;
FSongbase.ptDisplayOrigin.Y := hMonitor.Top;
FSettings.btMonitor.Caption := IntToStr(MonitorNum);
// If this is the monitor that currently contains the main window then
// we disable multimonitor support.
hPrimary := Screen.MonitorFromPoint( Point( FSongbase.Left, FSongbase.Top ),
mdPrimary );
FSongbase.bMultiMonitor := (hMonitor <> hPrimary);
FSettings.btMonitor.Enabled := FSongbase.bMultiMonitor;
FSettings.cbDualMonitor.Checked := FSongbase.bMultiMonitor;
Close;
end;
end;
procedure TFSelectProjectScreen.BCancelClick(Sender: TObject);
begin
Close;
end;
procedure TFSelectProjectScreen.Timer1Timer(Sender: TObject);
var hMonitor : TMonitor;
begin
if not PtInRect( Self.BoundsRect, Mouse.CursorPos ) then begin
hMonitor := Screen.MonitorFromPoint( Mouse.CursorPos, mdNull );
if nil <> hMonitor then begin
LScreen.Caption := 'Screen ' + IntToStr(1+hMonitor.MonitorNum);
MonitorNum := 1+hMonitor.MonitorNum;
end;
end;
end;
procedure TFSelectProjectScreen.FormShow(Sender: TObject);
begin
MonitorNum := FSongbase.DefaultScreen;
LScreen.Caption := 'Screen ' + IntToStr(MonitorNum);
end;
end.