-
Notifications
You must be signed in to change notification settings - Fork 44
/
MsnPopup.pas
1138 lines (978 loc) · 29.5 KB
/
MsnPopup.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
MsnPopup - using MSN-style popup windows in your Delphi programs
Copyright (C) 2001-2003 JWB Software
Web: http://people.zeelandnet.nl/famboek/delphi/
Email: jwbsoftware@zeelandnet.nl
}
Unit MSNPopUp;
Interface
Uses
Windows, Classes, Graphics, StdCtrls, ExtCtrls, Controls, Forms,
ShellApi, Dialogs, SysUtils, Messages;
// fix for Delphi-5 users
Const
WS_EX_NOACTIVATE = $8000000;
Type
TURLEvent = Procedure(Sender: TObject; URL: String) Of Object;
Type
TMouseLabel = Class(TLabel)
private
{ Private declarations }
fMouseEnter: TNotifyEvent;
fMouseLeave: TNotifyEvent;
Procedure CMMouseEnter(Var Message: TMessage); message CM_MOUSEENTER;
Procedure CMMouseLeave(Var Message: TMessage); message CM_MOUSELEAVE;
published
{ Published declarations }
Property OnMouseEnter: TNotifyEvent read fMouseEnter write fMouseEnter;
Property OnMouseLeave: TNotifyEvent read fMouseLeave write fMouseLeave;
End;
Type
TOrientation = (mbHorizontal, mbVertical);
TScrollSpeed = 1..50;
TMSNPopupOption = (msnAutoOpenURL, msnSystemFont, msnCascadePopups,
msnAllowScroll, msnAllowHyperlink);
// Anomy
TMSNImageDrawMethod = (dmActualSize, dmTile, dmFit);
TMSNPopupOptions = Set Of TMSNPopupOption;
TMSNPopUp = Class(TComponent)
private
{ Private declarations }
FURL: String;
FText: String;
FTitle: String;
FAlphaBlend: boolean;
FAlphaBlendValue: integer;
FIcon: TBitmap;
FWidth: Integer;
FHeight: Integer;
FTimeOut: Integer;
FScrollSpeed: TScrollSpeed;
FColor1: TColor;
FColor2: TColor;
FGradientOrientation: TOrientation;
FFont: TFont;
FHoverFont: TFont;
FTitleFont: TFont;
FCursor: TCursor;
FOptions: TMSNPopupOptions;
// Anomy
FTextAlignment: TAlignment;
FBackgroundDrawMethod: TMSNImageDrawMethod;
//Jelmer
FPopupMarge, FPopupStartX, FPopupStartY: Integer;
PopupCount, NextPopupPos: Integer;
LastBorder: Integer;
FDefaultMonitor: TDefaultMonitor;
FBackground: TBitmap;
FFlagImage, FNotifyImage: TBitmap;
FIconLeft, FIconTop: Integer;
FOnClick: TNotifyEvent;
FOnURLClick: TURLEvent;
Procedure SetIcon(Value: TBitmap);
Function GetEdge: Integer;
Function GetCaptionFont: TFont;
// Jiang Hong
Procedure SetFont(Value: TFont);
Procedure SetHoverFont(Value: TFont);
Procedure SetTitleFont(Value: TFont);
//Jelmer
Procedure SetBackground(Value: TBitmap);
Procedure SetFlagImage(Value: TBitmap);
Procedure SetNotifyImage(Value: TBitmap);
public
{ Public declarations }
Function ShowPopUp: Boolean;
Procedure ClosePopUps;
published
{ Published declarations }
Property Text: String read FText write FText;
Property URL: String read FURL write FURL;
Property AlphaBlend: boolean read FAlphaBlend write FAlphaBlend default False;
Property AlphaBlendValue: integer read FAlphaBlendValue write FAlphaBlendValue default 255;
Property IconBitmap: TBitmap read FIcon write SetIcon stored True;
Property IconLeft: Integer read FIconLeft write FIconLeft;
Property IconTop: Integer read FIconTop write FIconTop;
Property TimeOut: Integer read FTimeOut write FTimeOut default 10;
Property Width: Integer read FWidth write FWidth default 175;
Property Height: Integer read FHeight write FHeight default 175;
Property GradientColor1: TColor read FColor1 write FColor1;
Property GradientColor2: TColor read FColor2 write FColor2;
Property GradientOrientation: TOrientation read FGradientOrientation write FGradientOrientation default mbVertical;
Property ScrollSpeed: TScrollSpeed read FScrollSpeed write FScrollSpeed default 5;
Property Font: TFont read FFont write SetFont;
Property HoverFont: TFont read FHoverFont write SetHoverFont; //Jiang Hong
Property Title: String read FTitle write FTitle; //Jiang Hong
Property TitleFont: TFont read FTitleFont write SetTitleFont; //Jiang Hong
Property Options: TMSNPopupOptions read FOptions write FOptions;
// Anomy
Property TextAlignment: TAlignment read FTextAlignment write FTextAlignment default taLeftJustify;
Property BackgroundDrawMethod: TMSNImageDrawMethod read FBackgroundDrawMethod write FBackgroundDrawMethod default dmActualSize;
//Jelmer
Property TextCursor: TCursor read FCursor write FCursor;
Property PopupMarge: Integer read FPopupMarge write FPopupMarge;
Property PopupStartX: Integer read FPopupStartX write FPopupStartX;
Property PopupStartY: Integer read FPopupStartY write FPopupStartY;
Property DefaultMonitor: TDefaultMonitor read FDefaultMonitor write FDefaultMonitor;
Property BackgroundImage: TBitmap read FBackground write SetBackground;
Property FlagImage: TBitmap read FFlagImage write SetFlagImage;
Property NotifyImage: TBitmap read FNotifyImage write SetNotifyImage;
Property OnClick: TNotifyEvent read FOnClick write FOnClick;
Property OnURLClick: TURLEvent read FOnURLClick write FOnURLClick;
Constructor Create(AOwner: TComponent); override;
Destructor Destroy; override;
End;
Type
TfrmMSNPopUp = Class(TCustomForm)
pnlBorder: TPanel;
imgIcon: TImage;
lblText: TMouseLabel;
imgGradient: TImage;
imgFlag: TImage;
imgNotifyImage: TImage;
//
tmrExit: TTimer;
tmrScroll: TTimer;
// add by Ahmed Hamed 20-3-2002
tmrScrollDown: TTimer;
//
lblTitle: TMouseLabel;
// Added by Anomy
Procedure lblTextMouseEnter(Sender: TObject);
Procedure lblTextMouseLeave(Sender: TObject);
Procedure lblTextClick(Sender: TObject);
Procedure tmrExitTimer(Sender: TObject);
// add by Ahmed Hamed 20-3-2002
Procedure tmrscrollDownTimer(Sender: TObject);
//
Procedure lblTextMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Procedure lblTitleMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Procedure tmrScrollTimer(Sender: TObject);
Procedure imgIconMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Procedure imgGradientMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
protected
Procedure CreateParams(Var Params: TCreateParams); override;
Procedure DoClose(Var Action: TCloseAction); override;
private
//Jelmer
PopupPos: Integer;
ParentMSNPopup: TMSNPopup;
CanClose: Boolean;
// Anomy
BGDrawMethod: TMSNImageDrawMethod;
Function CalcColorIndex(StartColor, EndColor: TColor; Steps, ColorIndex: Integer): TColor;
Procedure PositionText;
Function IsWinXP: Boolean;
public
{ Public declarations }
URL, Text, Title: String;
TimeOut: Integer;
Icon: TBitmap;
sWidth: Integer;
sHeight: Integer;
bScroll, bHyperlink: Boolean;
Color1, Color2: TColor;
Orientation: TOrientation;
ScrollSpeed: TScrollSpeed;
Font, HoverFont, TitleFont: TFont;
StoredBorder: Integer;
Cursor: TCursor;
Constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
Procedure PopUp;
End;
Procedure Register;
Function IsNT4: Boolean;
Implementation
Function IsNT4: Boolean;
Var
VersionInfo: _OSVERSIONINFOW;
Begin
Result := False;
VersionInfo.dwOSVersionInfoSize := sizeof(VersionInfo);
GetVersionEx(VersionInfo);
If VersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT Then
Begin
If (VersionInfo.dwMajorVersion <= 4) and ((VersionInfo.dwMinorVersion = 0) or
(VersionInfo.dwMinorVersion = 51)) Then
Result := True;
End;
End;
Procedure Register;
Begin
RegisterComponents('MSNPopUp', [TMSNPopUp]);
End;
// mouselabel-stuff
Procedure TMouseLabel.CMMouseEnter(Var Message: TMessage);
Begin
If assigned(fMouseEnter) Then
fMouseEnter(self);
End;
Procedure TMouseLabel.CMMouseLeave(Var Message: TMessage);
Begin
If assigned(fMouseLeave) Then
fMouseLeave(self);
End;
// component stuff
Function TMSNPopUp.ShowPopUp: Boolean;
Var
r: TRect;
MSNPopUp: TfrmMSNPopUp;
Begin
//Jelmer
If GetEdge <> LastBorder Then
Begin
LastBorder := GetEdge;
PopupCount := 0;
End;
Result := True;
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
If PopupCount > 0 Then
Begin
Case LastBorder Of
ABE_BOTTOM:
If (r.Bottom - (NextPopupPos + FHeight + PopupStartY)) < 0 Then
Begin
Result := False;
Exit;
End;
ABE_LEFT:
If (NextPopupPos + FWidth + PopupStartX) > r.Right Then
Begin
Result := False;
Exit;
End;
ABE_RIGHT:
If (r.Right - (NextPopupPos + FHeight + PopupStartY)) < 0 Then
Begin
Result := False;
Exit;
End;
ABE_TOP:
If ((NextPopupPos + FHeight + PopupStartY)) > r.Bottom Then
Begin
Result := False;
Exit;
End;
End;
End
Else
NextPopupPos := 0;
Inc(PopupCount);
MSNPopUp := TfrmMSNPopUp.CreateNew(Self.Owner);
MSNPopUp.DoubleBuffered := True;
MSNPopUp.pnlBorder.DoubleBuffered := True;
MSNPopUp.Hide;
MSNPopUp.AlphaBlend := FAlphaBlend;
MSNPopUp.AlphaBlendValue := FAlphaBlendValue;
//Jelmer
MSNPopUp.ParentMSNPopup := Self;
MSNPopUp.DefaultMonitor := FDefaultMonitor;
MSNPopUp.sWidth := FWidth;
MSNPopUp.sHeight := FHeight;
MSNPopUp.Text := FText;
MSNPopUp.URL := FURL;
MSNPopUp.Title := FTitle;
MSNPopUp.TimeOut := FTimeOut;
MSNPopUp.Icon := FIcon;
MSNPopUp.bScroll := msnAllowScroll in FOptions;
MSNPopUp.bHyperlink := msnAllowHyperlink in FOptions;
MSNPopUp.ScrollSpeed := FScrollSpeed;
MSNPopUp.Font := FFont;
MSNPopUp.HoverFont := FHoverFont;
MSNPopUp.TitleFont := FTitleFont;
MSNPopUp.Cursor := FCursor;
MSNPopUp.Color1 := FColor1;
MSNPopUp.Color2 := FColor2;
MSNPopUp.Orientation := FGradientOrientation;
// Anomy
MSNPopUp.lblText.Alignment := FTextAlignment;
MSNPopUp.pnlBorder.Align := alClient;
MSNPopUp.BGDrawMethod := FBackgroundDrawMethod;
MSNPopUp.PopUp;
End;
// JWB
Procedure TMSNPopUp.ClosePopUps;
Var
hTfrmMSNPopUp: Cardinal;
i: Integer;
Begin
For i := 0 To PopUpCount Do
Begin
hTfrmMSNPopUp := FindWindow(PChar('TfrmMSNPopUP'), nil);
If hTfrmMSNPopUp <> 0 Then
Begin
SendMessage(hTfrmMSNPopUp, WM_CLOSE, 0,0);
Application.ProcessMessages;
End;
End;
End;
//Jiang Hong
Procedure TMSNPopup.SetFont(Value: TFont);
Begin
If not (FFont = Value) Then
FFont.Assign(Value);
End;
//Jiang Hong
Procedure TMSNPopup.SetHoverFont(Value: TFont);
Begin
If not (FHoverFont = Value) Then
FHoverFont.Assign(Value);
End;
//Jiang Hong
Procedure TMSNPopup.SetTitleFont(Value: TFont);
Begin
If not (FTitleFont = Value) Then
FTitleFont.Assign(Value);
End;
Procedure TMSNPopUp.SetIcon(Value: TBitmap);
Begin
If Value <> Self.FIcon Then
Begin
Self.FIcon.Assign(Value);
End;
End;
// function to find out system's default font
Function TMSNPopUp.GetCaptionFont: TFont;
Var
ncMetrics: TNonClientMetrics;
Begin
ncMetrics.cbSize := sizeof(TNonClientMetrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(TNonClientMetrics), @ncMetrics, 0);
Result := TFont.Create;
Result.Handle := CreateFontIndirect(ncMetrics.lfMenuFont);
End;
Constructor TMSNPopUp.Create(AOwner: TComponent);
Begin
Inherited;
FOptions := [msnAllowScroll, msnAllowHyperlink, msnAutoOpenURL, msnCascadePopups];
FIcon := TBitmap.Create;
FFont := TFont.Create;
FHoverFont := TFont.Create;
FTitleFont := TFont.Create;
//Jelmer
FBackground := TBitmap.Create();
FFlagImage := TBitmap.Create();
FNotifyImage := TBitmap.Create();
If msnSystemFont in FOptions Then
Begin
FFont.Name := GetCaptionFont.Name;
FHoverFont.Name := GetCaptionFont.Name;
FTitleFont.Name := GetCaptionFont.Name;
End;
FWidth := 148;
FHeight := 121;
FTimeOut := 10;
FScrollSpeed := 9;
FIconLeft := 8;
FIconTop := 8;
FText := 'text';
FURL := 'http://www.url.com/';
FTitle := 'title';
FCursor := crDefault;
FColor1 := $00FFCC99;
FColor2 := $00FFFFFF;
FGradientOrientation := mbVertical;
FHoverFont.Style := [fsUnderline];
FHoverFont.Color := clBlue;
FTitleFont.Style := [fsBold];
// Anomy
FBackgroundDrawMethod := dmActualSize;
FTextAlignment := taLeftJustify;
//Jelmer
PopupCount := 0;
LastBorder := 0;
FPopupMarge := 2;
FPopupStartX := 16;
FPopupStartY := 2;
//---
End;
Destructor TMSNPopUp.Destroy;
Begin
FIcon.Free;
FFont.Free;
FHoverFont.Free;
FTitleFont.Free;
//Jelmer
FBackground.Free;
FFlagImage.Free;
FNotifyImage.Free;
Inherited;
End;
// form's functions
Procedure TfrmMSNPopUp.CreateParams(Var Params: TCreateParams);
Begin
Inherited;
Params.Style := Params.Style and not WS_CAPTION or WS_POPUP;
If IsNT4 Then
Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW
Else
Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW or WS_EX_NOACTIVATE;
Params.WndParent := GetDesktopWindow;
End;
Constructor TfrmMSNPopUp.CreateNew(AOwner: TComponent; Dummy: Integer = 0);
Begin
Inherited;
BorderStyle := {bsDialog} bsNone;
pnlBorder := TPanel.Create(Self);
pnlBorder.Parent := Self;
pnlBorder.Align := alClient;
//pnlBorder.BevelWidth := 2;
pnlBorder.BevelOuter := {bvLowered} bvNone;
imgGradient := TImage.Create(Self);
imgGradient.Parent := pnlBorder;
imgGradient.Align := alClient;
imgGradient.Anchors := [akTop, akLeft, akRight, akBottom];
imgGradient.OnMouseUp := Self.imgGradientMouseUp;
imgFlag := TImage.Create(Self);
imgFlag.Stretch := True;
imgFlag.Parent := pnlBorder;
imgFlag.Align := alNone;
imgFlag.Anchors := [akTop, akRight];
imgNotifyImage := TImage.Create(Self);
imgNotifyImage.Stretch := True;
imgNotifyImage.Parent := pnlBorder;
imgNotifyImage.Align := alNone;
imgNotifyImage.Anchors := [akTop, akLeft];
imgIcon := TImage.Create(Self);
imgIcon.Parent := pnlBorder;
imgIcon.Left := 3;
imgIcon.Top := 8;
imgIcon.OnMouseUp := Self.imgIconMouseUp;
lblText := TMouseLabel.Create(Self);
lblText.ShowAccelChar := False;
lblText.Layout := tlCenter;
lblText.AutoSize := True;
lblText.WordWrap := True;
lblText.Parent := pnlBorder;
lblText.Transparent := True;
lblText.OnMouseEnter := Self.lblTextMouseEnter;
lblText.OnMouseLeave := Self.lblTextMouseLeave;
lblText.OnClick := Self.lblTextClick;
lblText.OnMouseUp := Self.lblTextMouseUp;
lblText.Left := 9;
lblText.Top := 48;
lblText.Width := 3;
lblText.Height := 13;
lblTitle := TMouseLabel.Create(Self);
lblTitle.ShowAccelChar := False;
lblTitle.Parent := pnlBorder;
lblTitle.Transparent := True;
lblTitle.Top := 8;
lblTitle.Left := 48;
lblTitle.OnMouseUp := Self.lblTitleMouseUp;
tmrExit := TTimer.Create(Self);
tmrExit.Enabled := False;
tmrExit.OnTimer := tmrExitTimer;
tmrExit.Interval := 10000;
tmrScroll := TTimer.Create(Self);
tmrScroll.Enabled := False;
tmrScroll.OnTimer := tmrScrollTimer;
tmrScroll.Interval := 25;
// add by Ahmed Hamed 20-3-2002
tmrScrollDown := TTimer.Create(Self);
tmrScrollDown.Enabled := False;
tmrScrollDown.OnTimer := tmrScrollDownTimer;
tmrScrollDown.Interval := 25;
//
End;
Function TMSNPopup.GetEdge: Integer;
Var
AppBar: TAppbarData;
Begin
Result := -1;
FillChar(AppBar, sizeof(AppBar), 0);
AppBar.cbSize := Sizeof(AppBar);
If ShAppBarMessage(ABM_GETTASKBARPOS, AppBar) <> 0 Then
Begin
If ((AppBar.rc.top = AppBar.rc.left) and (AppBar.rc.bottom > AppBar.rc.right)) Then
Result := ABE_LEFT
Else If ((AppBar.rc.top = AppBar.rc.left) and (AppBar.rc.bottom < AppBar.rc.right)) Then
Result := ABE_TOP
Else If (AppBar.rc.top > AppBar.rc.left) Then
Result := ABE_BOTTOM
Else
Result := ABE_RIGHT;
End;
End;
Procedure TfrmMSNPopUp.PopUp;
Var
r: TRect;
gradient: TBitmap;
i: Integer;
tileX, tileY: Integer;
//Jelmer
OldLeft, OldTop: Integer;
Begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
Self.AutoScroll := False;
Self.Height := sHeight;
Self.Width := sWidth;
lblText.Cursor := Cursor;
//Jelmer
StoredBorder := ParentMSNPopup.GetEdge;
CanClose := True;
Case StoredBorder Of
ABE_LEFT:
Begin
Self.Left := r.Left + ParentMSNPopup.PopupStartX;
//Jelmer
Self.Top := r.Bottom - ParentMSNPopup.PopupStartY - Self.Height - ParentMSNPopup.NextPopupPos;
End;
ABE_TOP:
Begin
Self.Left := r.Right - Self.Width - ParentMSNPopup.PopupStartX;
//Jelmer
Self.Top := r.Top + ParentMSNPopup.PopupStartY + ParentMSNPopup.NextPopupPos;
End;
ABE_BOTTOM:
Begin
Self.Left := r.Right - Self.Width - ParentMSNPopup.PopupStartX;
//Jelmer
Self.Top := r.Bottom - ParentMSNPopup.PopupStartY - Self.Height - ParentMSNPopup.NextPopupPos;
End;
ABE_RIGHT:
Begin
Self.Left := r.Right - Self.Width - ParentMSNPopup.PopupStartX;
//Jelmer
Self.Top := r.Bottom - ParentMSNPopup.PopupStartY - Self.Height - ParentMSNPopup.NextPopupPos;
End;
End;
//Jelmer
PopupPos := ParentMSNPopup.NextPopupPos;
If msnCascadePopups in ParentMSNPopup.FOptions = True Then
Begin
If (StoredBorder = ABE_BOTTOM) or (StoredBorder = ABE_TOP) Then
Begin
ParentMSNPopup.NextPopupPos := ParentMSNPopup.NextPopupPos + sHeight + ParentMSNPopup.FPopupMarge;
End
Else If (StoredBorder = ABE_RIGHT) or (StoredBorder = ABE_LEFT) Then
Begin
ParentMSNPopup.NextPopupPos := ParentMSNPopup.NextPopupPos + sHeight + ParentMSNPopup.FPopupMarge;
End;
End
Else
ParentMSNPopup.NextPopupPos := 0;
lblTitle.Font := TitleFont;
lblTitle.Caption := Title;
//Jelmer
OldLeft := Left;
OldTop := Top;
Left := -Width - 10;
Top := -Height - 10;
Visible := True;
Visible := False;
Left := OldLeft;
Top := OldTop;
imgGradient.Align := alClient;
//Jelmer
If Self.ParentMSNPopup.FBackground.Empty Then
Begin
gradient := TBitmap.Create;
gradient.Width := imgGradient.Width;
gradient.Height := imgGradient.Height;
If Orientation = mbVertical Then
Begin
For i := 0 To gradient.Height Do
Begin
gradient.Canvas.Pen.Color := CalcColorIndex(Color1, Color2, gradient.Height + 1, i + 1);
gradient.Canvas.MoveTo(0,i);
gradient.Canvas.LineTo(gradient.Width, i);
End;
End;
If Orientation = mbHorizontal Then
Begin
For i := 0 To gradient.Width Do
Begin
gradient.Canvas.Pen.Color := CalcColorIndex(Color1, Color2, gradient.Height + 1, i + 1);
gradient.Canvas.MoveTo(i, 0);
gradient.Canvas.LineTo(i, gradient.Height);
End;
End;
imgGradient.Canvas.Draw(0,0,gradient);
gradient.Free;
End
Else
Begin
//Jelmer
//imgGradient.Canvas.
ParentMSNPopup.FBackground.Transparent := True;
// Anomy
Case BGDrawMethod Of
dmActualSize:
imgGradient.Canvas.Draw(0, 0, ParentMSNPopup.BackgroundImage);
dmTile:
Begin
tileX := 0;
While tileX < imgGradient.Width Do
Begin
tileY := 0;
While tileY < imgGradient.Height Do
Begin
imgGradient.Canvas.Draw(tileX, tileY, ParentMSNPopup.BackgroundImage);
tileY := tileY + ParentMSNPopup.BackgroundImage.Height;
End;
tileX := tileX + ParentMSNPopup.BackgroundImage.Width;
End;
End;
dmFit:
imgGradient.Canvas.StretchDraw(Bounds(0,0,imgGradient.Width,
imgGradient.Height),
ParentMSNPopup.BackgroundImage
);
End;
End;
If ParentMSNPopUp.IconBitmap.Empty = False Then
Begin
//imgIcon.Picture.Icon := Icon;
ParentMSNPopup.IconBitmap.Transparent := True;
imgGradient.Canvas.Draw(ParentMSNPopUp.IconLeft, ParentMSNPopUp.IconTop,
ParentMSNPopUp.IconBitmap);
End
Else
lblTitle.Left := 8;
If not ParentMSNPopup.FFlagImage.Empty Then
begin
imgFlag.Visible := True;
imgFlag.Width := ParentMSNPopup.FlagImage.Width;
imgFlag.Height := ParentMSNPopup.FlagImage.Height;
//imgFlag.Canvas.Draw(0, 0, ParentMSNPopup.FlagImage);
imgFlag.Picture.Assign(ParentMSNPopup.FlagImage);
imgFlag.Transparent := True;
imgFlag.Top := 8;
imgFlag.Left := imgGradient.Width - ParentMSNPopup.FlagImage.Width - 8
end else imgFlag.Visible := False;
If not ParentMSNPopup.FNotifyImage.Empty Then
begin
imgNotifyImage.Visible := True;
imgNotifyImage.Width := 80;
imgNotifyImage.Height := 80;
//imgNotifyImage.Canvas.Draw(0, 0, ParentMSNPopup.NotifyImage);
imgNotifyImage.Picture.Assign(ParentMSNPopup.NotifyImage);
imgNotifyImage.Transparent := True;
imgNotifyImage.Top := 25;
imgNotifyImage.Left := 8;
end else imgNotifyImage.Visible := False;
tmrExit.Interval := TimeOut * 1000;
If bScroll Then
Begin
Case ParentMSNPopup.GetEdge Of
ABE_TOP:
Begin
Self.Height := 1;
End;
ABE_BOTTOM:
Begin
Self.Top := Self.Top + Self.Height;
Self.Height := 1;
End;
ABE_LEFT:
Begin
Self.Width := 1;
End;
ABE_RIGHT:
Begin
Self.Left := Self.Left + Self.Width;
Self.Width := 1;
End;
End;
tmrScroll.Enabled := True;
End;
If not bScroll Then
tmrExit.Enabled := True;
Self.FormStyle := fsStayOnTop;
Self.DefaultMonitor := dmDesktop;
ShowWindow(Self.Handle, SW_SHOWNOACTIVATE);
Self.Visible := True;
lblText.Font := HoverFont;
lblText.Top := sHeight;
PositionText;
lblText.Font := Font;
lblText.Top := sHeight;
PositionText;
End;
Procedure TfrmMSNPopUp.lblTextMouseEnter(Sender: TObject);
Begin
// when mouse cursor enters the url area,
// the text is made blue & underlined
If bHyperlink Then
Begin
//lblText.Font := HoverFont;
End;
End;
Procedure TfrmMSNPopUp.lblTextMouseLeave(Sender: TObject);
Begin
// when mouse cursor leaves the url area,
// style of text is normal again
If bHyperlink Then
Begin
//lblText.Font := Font;
End;
End;
Procedure TfrmMSNPopUp.PositionText;
Begin
lblText.Caption := Text;
lblText.Width := pnlBorder.Width - 15;
lblText.WordWrap := False;
lblText.Left := lblTitle.Left;
lblText.Top := (lblText.Top - lblText.Height) - 5;
end;
Function TfrmMSNPopUp.CalcColorIndex(StartColor, EndColor: TColor; Steps, ColorIndex: Integer): TColor;
Var
BeginRGBValue: Array[0..2] Of Byte;
RGBDifference: Array[0..2] Of Integer;
Red, Green, Blue: Byte;
NumColors: Integer;
Begin
// Initialize
NumColors := Steps;
Dec(ColorIndex);
// Values are set
BeginRGBValue[0] := GetRValue(ColorToRGB(StartColor));
BeginRGBValue[1] := GetGValue(ColorToRGB(StartColor));
BeginRGBValue[2] := GetBValue(ColorToRGB(StartColor));
RGBDifference[0] := GetRValue(ColorToRGB(EndColor)) - BeginRGBValue[0];
RGBDifference[1] := GetGValue(ColorToRGB(EndColor)) - BeginRGBValue[1];
RGBDifference[2] := GetBValue(ColorToRGB(EndColor)) - BeginRGBValue[2];
// Calculate the bands color
Red := BeginRGBValue[0] + MulDiv(ColorIndex, RGBDifference[0], NumColors - 1);
Green := BeginRGBValue[1] + MulDiv(ColorIndex, RGBDifference[1], NumColors - 1);
Blue := BeginRGBValue[2] + MulDiv(ColorIndex, RGBDifference[2], NumColors - 1);
// The final color is returned
Result := RGB(Red, Green, Blue);
End;
Procedure TfrmMSNPopUp.lblTextClick(Sender: TObject);
Begin
// when user clicks the hyperlink, and the Hyperlink
// property is true, a browser window opens
//Jelmer
CanClose := False;
If bHyperlink Then
Begin
If Assigned(ParentMSNPopup.FOnURLClick) Then
ParentMSNPopup.FOnURLClick(Self, URL);
If msnAutoOpenURL in ParentMSNPopup.FOptions = True Then
ShellExecute(0, nil, PChar(URL), nil, nil, SW_SHOWDEFAULT);
End
Else If Assigned(ParentMSNPopup.FOnClick) Then
ParentMSNPopup.FOnClick(Self);
CanClose := True;
Close;
End;
Procedure TfrmMSNPopUp.tmrExitTimer(Sender: TObject);
Begin
// after several seconds, the popup window will disappear
// add by Ahmed Hamed 20-3-2002
tmrExit.Enabled := False;
tmrScrollDown.Enabled := True;
//
End;
// add by Ahmed Hamed 20-3-2002
Procedure TfrmMSNPopUp.tmrScrollDownTimer(Sender: TObject);
Var
r: TRect;
Begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
Application.ProcessMessages;
Case StoredBorder Of
ABE_LEFT:
Begin
If (Self.Width - Scrollspeed) > 0 Then
Begin
Self.Width := Self.Width - ScrollSpeed;
End
Else
Self.Close;
End;
ABE_TOP:
Begin
If (Self.Height - ScrollSpeed) > 0 Then
Begin
Self.Height := Self.Height - ScrollSpeed;
End
Else
Self.Close;
End;
ABE_BOTTOM:
Begin
If (Self.Height - ScrollSpeed) > 0 Then
Begin
Self.Top := Self.Top + ScrollSpeed;
Self.Height := Self.Height - ScrollSpeed;
End
Else
Self.Close;
End;
ABE_RIGHT:
Begin
If (Self.Width - ScrollSpeed) > 0 Then
Begin
Self.Left := Self.Left + ScrollSpeed;
Self.Width := Self.Width - ScrollSpeed;
End
Else
Self.Close;
End;
End;
Application.ProcessMessages;
End;
//
Procedure TfrmMSNPopUp.lblTextMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Begin
// close the popup window on right click
//Jelmer
If Button = mbRight Then
Begin
If Assigned(Self.ParentMSNPopup.FOnClick) Then
Begin
CanClose := False;
Self.ParentMSNPopup.FOnClick(Self.ParentMSNPopup);
CanClose := True;
End;
Self.Close;
End;
End;
Procedure TfrmMSNPopUp.tmrScrollTimer(Sender: TObject);
Var
r: TRect;
Begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
Application.ProcessMessages;
Case StoredBorder Of
ABE_LEFT:
Begin
If (Self.Width + Scrollspeed) < sWidth Then
Begin
Self.Width := Self.Width + ScrollSpeed;
End
Else
Begin
Self.Width := sWidth;
tmrScroll.Enabled := False;
tmrExit.Enabled := True;
End;
End;
ABE_TOP:
Begin