-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathBaseConflictSplash.pas
99 lines (83 loc) · 2.01 KB
/
BaseConflictSplash.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
99
unit BaseConflictSplash;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
System.Types,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Engine.Helferlein.Windows,
Vcl.Imaging.pngimage;
type
TSplashForm = class(TForm)
private
{ Private-Deklarationen }
protected
procedure WMNCHitTest(var Message : TWMNCHitTest); message WM_NCHITTEST;
public
procedure Execute;
end;
var
SplashForm : TSplashForm;
implementation
{$R *.dfm}
{ TSplashForm }
procedure TSplashForm.Execute;
var
BlendFunction : TBlendFunction;
BitmapPos : TPoint;
BitmapSize : TSize;
exStyle : DWORD;
Png : TPngImage;
Bitmap : TBitmap;
begin
// // if file is not present skip this form
// if not HFilepathManager.FileExists('Splash.png') then
// begin
// Hide;
// exit;
// end;
// Enable window layering
exStyle := GetWindowLongA(Handle, GWL_EXSTYLE);
if (exStyle and WS_EX_LAYERED = 0) then
SetWindowLong(Handle, GWL_EXSTYLE, exStyle or WS_EX_LAYERED);
Bitmap := TBitmap.Create;
Png := TPngImage.Create;
try
try
Png.LoadFromResourceName(HInstance, 'Splash.png');
Bitmap.Assign(Png);
// Resize form to fit bitmap
ClientWidth := Bitmap.Width;
ClientHeight := Bitmap.Height;
// Position bitmap on form
BitmapPos := Point(0, 0);
BitmapSize.cx := Bitmap.Width;
BitmapSize.cy := Bitmap.Height;
// Setup alpha blending parameters
BlendFunction.BlendOp := AC_SRC_OVER;
BlendFunction.BlendFlags := 0;
BlendFunction.SourceConstantAlpha := 255;
BlendFunction.AlphaFormat := AC_SRC_ALPHA;
// ... and action!
UpdateLayeredWindow(Handle, 0, nil, @BitmapSize, Bitmap.Canvas.Handle,
@BitmapPos, 0, @BlendFunction, ULW_ALPHA);
Show;
except
Hide;
end;
finally
Png.Free;
Bitmap.Free;
end;
end;
procedure TSplashForm.WMNCHitTest(var Message : TWMNCHitTest);
begin
message.Result := HTCAPTION;
end;
end.