File: app.pas

package info (click to toggle)
vmg 3.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,528 kB
  • sloc: pascal: 5,160; cpp: 605; sh: 278; lex: 105; ansic: 68; makefile: 37
file content (1601 lines) | stat: -rw-r--r-- 56,369 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
{
app.pas

Main window and general user interface code

Copyright (C) 1998 - 2010 Harri Pyy, Chris O'Donnell, Felipe Monteiro de Carvalho

This file is part of Virtual Magnifying Glass.

Virtual Magnifying Glass is free software;
you can redistribute it and/or modify it under the
terms of the GNU General Public License version 2
as published by the Free Software Foundation.

Virtual Magnifying Glass is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Please note that the General Public License version 2 does not permit
incorporating Virtual Magnifying Glass into proprietary
programs.

AUTHORS: Chris O'Donnell, Felipe Monteiro de Carvalho and Harri Pyy
}
unit app;

{$IFDEF FPC}
  {$MODE DELPHI}{$H+}
{$ENDIF}

{$IFDEF Win32}
  {$DEFINE Windows}
{$ENDIF}

// This greatly increases the speed in non-Windows platforms
{$ifndef LCLWin32}
  {$define VMG_DIRECT_FORM_RENDERING}
{$ENDIF}

// This makes the magnifier a small window to help debug exceptions and other problems
// which might make the fullscreen app block the system
{.$define VMG_DEBUG_SMALL_MODE}

interface

uses
{$IFDEF Windows}

  {$IFDEF WinCE}
    Windows, Messages, Registry,
  {$ELSE}
    Windows, ShellAPI, Messages, Registry,
  {$ENDIF}

  {$IFDEF VER150} // VER150 = Delphi 7
    olddelphitrayicon,
  {$ENDIF}

{$ENDIF}

{$IFDEF UNIX}
  Unix,
{$ENDIF}
{$ifdef LCLCustomdrawn}
  customdrawnint,
{$endif}

  LCLType, LCLIntf, LMessages, LCLProc,
  Forms, Classes, SysUtils, Controls, Graphics, Menus, ExtCtrls, Clipbrd,
  glass, constants, appsettings, plugins {, lazfmlviewer};

type

  { TMainWindow }

  TMainWindow = class(TForm)
  private
    MyMenuItems: array[0..22] of TMenuItem;
    MySubMenuItems: array[0..30] of TMenuItem;
    vMenu: TPopupMenu;
    SystrayIcon: TTrayIcon;
    DynamicModeTimer: TTimer;
    procedure ChangeInvertColors(Sender: TObject);
    procedure ChangeGraphicalBorder(Sender: TObject);
    procedure ChangeWidth(Sender: TObject);
    procedure ChangeHeight(Sender: TObject);
    procedure ChangeMagnification(Sender: TObject);
    procedure ChangeTools(Sender: TObject);
    procedure ChangeAutoRun(Sender: TObject);
    procedure ChangeAntiAliasing(Sender: TObject);
    procedure ChangeShowWhenExecuted(Sender: TObject);
    procedure ChangeLanguage(Sender: TObject);
    procedure CloseWindow(Sender: TObject);
    procedure CreateTaskbarMenu(var lpMenu: TPopupMenu);
    procedure HandleFormPaint(Sender: TObject);
    procedure HandleKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure HandleKeyPress(Sender: TObject; var Key: Char);
    procedure HandleOnClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure HandleShow(Sender: TObject);
    procedure HandleClosePlugin(Sender: TObject);
    procedure HandleMouseWheel(Sender: TObject; Shift: TShiftState;
     WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    procedure HandleDynamicMode(Sender: TObject);
    procedure HandleHideGlass(Sender: TObject);
    procedure HideWindow(Sender: TObject);
    procedure HideMenu(Sender: TObject);
    procedure MoveGlass(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    function  SetTaskbarIcon(uID: Cardinal): Boolean;
    procedure ShowHomePage(Sender: TObject);
    procedure ShowAboutBox(Sender: TObject);
    procedure ShowConfigDialog(Sender: TObject);
    procedure ShowHelp(Sender: TObject);
    procedure SystrayClick(Sender: TObject);
    procedure ShowLensClick(Sender: TObject);
    procedure TranslateTaskbarMenu(Sender: TObject);
  public
    ControlToInvalidate: TWinControl;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure UpdateConfigurations;
    procedure UpdateHotKey(Sender: TObject);
    procedure ExecuteLens(Sender: TObject);
    procedure HandleDynamicModeTimer(Sender: TObject);
    procedure DoChangeLanguage(AID: Integer);
    {$IFDEF Win32}
    procedure WndProc(var TheMessage : TLMessage); override;
    {$ENDIF}
    function DisableFormBackgroundDrawing(AForm: TCustomForm): Boolean;
  end;

var
  vMainWindow: TMainWindow;

implementation

uses about, translationsvmg, configdlg;

{*******************************************************************
*  app.dfm is a dummy resource file required by Delphi to create the form
*******************************************************************}
{$IFNDEF FPC}
  {$R app.dfm}
{$ENDIF}

{ TMainWindow }

{*******************************************************************}
{@@
  Standard event for hiding the main window
}
{*******************************************************************}
procedure TMainWindow.HideWindow(Sender: TObject);
begin
{$ifdef wince}
  Close;
{$else}
  Hide;
{$endif}
end;

{*******************************************************************}
{@@
  Standard event for closing the main window
}
{*******************************************************************}
procedure TMainWindow.CloseWindow(Sender: TObject);
begin
  HandleClosePlugin(nil); // Otherwise exiting might be prevented
  Close;
  Application.Terminate;
end;

{*******************************************************************}
{@@
  Creates a object from the TAplicativo class

  @param  AOwner   The owner of the component (this may be nil)

  @return          A pointer to the newly created object
}
{*******************************************************************}
constructor TMainWindow.Create(AOwner: TComponent);
var
  lResult: LongBool;
begin
  inherited Create(AOwner);

  {$ifdef LCLCustomdrawn}
  CDWidgetSet.DisableFormBackgroundDrawingProc := DisableFormBackgroundDrawing;
  {$endif}

  // The caption is necessary so a second instance can find the glass
  Caption := szAppTitle;

  // Properties

  BorderStyle := bsNone;
  Self.KeyPreview := true; // Required to make arrow keys work on Linux

  // Creates the glass object
  vGlass := TGlass.Create(Self);
  {$ifdef VMG_DIRECT_FORM_RENDERING}
  vGlass.Visible := False;
  ControlToInvalidate := Self;
  {$else}
  ControlToInvalidate := vGlass;
  {$endif}

  // Creates the systray menu
  SystrayIcon := TTrayIcon.Create(Self); // Needs to be done before SetTaskbarIcon
  vMenu := TPopupMenu.Create(Self);
  CreateTaskbarMenu(vMenu);
  TranslateTaskbarMenu(Self);
  SetTaskbarIcon(1);

  // Creates the dynamic mode timer
  DynamicModeTimer := TTimer.Create(nil);
  DynamicModeTimer.Enabled := False;
  DynamicModeTimer.OnTimer := HandleDynamicModeTimer;
  DynamicModeTimer.Interval := 25;
end;

{*******************************************************************}
{@@
  Loads menu to be used in taskbar from resources.
  Sets the selections of the menu.
  Remember that this functions calls UpdateConfigurations, so
  it is not necessary to do so when it is called.

  @param  lpMenu   Object to receive the menu

  @return          Nothing
}
{*******************************************************************}
procedure TMainWindow.CreateTaskbarMenu(var lpMenu: TPopupMenu);
var
  i: Integer;
begin
  MyMenuItems[ID_MENU_ACTIVATE] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_ACTIVATE].OnClick := ShowLensClick;

  MyMenuItems[ID_MENU_WIDTH] := TMenuItem.Create(Self);

    MySubMenuItems[ID_MENU_WIDTH_64] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_64].Caption := '64';
    MySubMenuItems[ID_MENU_WIDTH_64].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_96] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_96].Caption := '96';
    MySubMenuItems[ID_MENU_WIDTH_96].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_128] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_128].Caption := '128';
    MySubMenuItems[ID_MENU_WIDTH_128].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_192] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_192].Caption := '192';
    MySubMenuItems[ID_MENU_WIDTH_192].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_256] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_256].Caption := '256';
    MySubMenuItems[ID_MENU_WIDTH_256].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_320] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_320].Caption := '320';
    MySubMenuItems[ID_MENU_WIDTH_320].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_416] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_416].Caption := '416';
    MySubMenuItems[ID_MENU_WIDTH_416].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_512] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_512].Caption := '512';
    MySubMenuItems[ID_MENU_WIDTH_512].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_640] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_640].Caption := '640';
    MySubMenuItems[ID_MENU_WIDTH_640].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_768] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_768].Caption := '768';
    MySubMenuItems[ID_MENU_WIDTH_768].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_1024] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_1024].Caption := '1024';
    MySubMenuItems[ID_MENU_WIDTH_1024].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_1280] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_1280].Caption := '1280';
    MySubMenuItems[ID_MENU_WIDTH_1280].OnClick := ChangeWidth;

    MySubMenuItems[ID_MENU_WIDTH_1600] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_WIDTH_1600].Caption := '1600';
    MySubMenuItems[ID_MENU_WIDTH_1600].OnClick := ChangeWidth;

    for i := 0 to 12 do MyMenuItems[ID_MENU_WIDTH].Add(MySubMenuItems[i]);

  MyMenuItems[ID_MENU_HEIGHT] := TMenuItem.Create(Self);

    MySubMenuItems[ID_MENU_HEIGHT_64] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_64].Caption := '64';
    MySubMenuItems[ID_MENU_HEIGHT_64].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_96] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_96].Caption := '96';
    MySubMenuItems[ID_MENU_HEIGHT_96].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_128] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_128].Caption := '128';
    MySubMenuItems[ID_MENU_HEIGHT_128].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_160] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_160].Caption := '160';
    MySubMenuItems[ID_MENU_HEIGHT_160].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_192] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_192].Caption := '192';
    MySubMenuItems[ID_MENU_HEIGHT_192].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_256] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_256].Caption := '256';
    MySubMenuItems[ID_MENU_HEIGHT_256].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_320] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_320].Caption := '320';
    MySubMenuItems[ID_MENU_HEIGHT_320].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_512] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_512].Caption := '512';
    MySubMenuItems[ID_MENU_HEIGHT_512].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_768] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_768].Caption := '768';
    MySubMenuItems[ID_MENU_HEIGHT_768].OnClick := ChangeHeight;

    MySubMenuItems[ID_MENU_HEIGHT_1024] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_HEIGHT_1024].Caption := '1024';
    MySubMenuItems[ID_MENU_HEIGHT_1024].OnClick := ChangeHeight;

    for i := 0 to 9 do MyMenuItems[ID_MENU_HEIGHT].Add(MySubMenuItems[i]);

  MyMenuItems[ID_MENU_MAGNIFICATION] := TMenuItem.Create(Self);

    MySubMenuItems[0] := TMenuItem.Create(Self);
    MySubMenuItems[0].Caption := '1x';
    MySubMenuItems[0].OnClick := ChangeMagnification;

    MySubMenuItems[1] := TMenuItem.Create(Self);
    MySubMenuItems[1].Caption := '1.5x';
    MySubMenuItems[1].OnClick := ChangeMagnification;

    MySubMenuItems[2] := TMenuItem.Create(Self);
    MySubMenuItems[2].Caption := '2x';
    MySubMenuItems[2].OnClick := ChangeMagnification;

    MySubMenuItems[3] := TMenuItem.Create(Self);
    MySubMenuItems[3].Caption := '3x';
    MySubMenuItems[3].OnClick := ChangeMagnification;

    MySubMenuItems[4] := TMenuItem.Create(Self);
    MySubMenuItems[4].Caption := '4x';
    MySubMenuItems[4].OnClick := ChangeMagnification;

    MySubMenuItems[5] := TMenuItem.Create(Self);
    MySubMenuItems[5].Caption := '8x';
    MySubMenuItems[5].OnClick := ChangeMagnification;

    MySubMenuItems[6] := TMenuItem.Create(Self);
    MySubMenuItems[6].Caption := '16x';
    MySubMenuItems[6].OnClick := ChangeMagnification;

    for i := 0 to 6 do MyMenuItems[ID_MENU_MAGNIFICATION].Add(MySubMenuItems[i]);

  MyMenuItems[ID_MENU_TOOLS] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_TOOLS].OnClick := ChangeTools;

  MyMenuItems[ID_MENU_GRAPHICAL_BORDER] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_GRAPHICAL_BORDER].OnClick := ChangeGraphicalBorder;

  MyMenuItems[ID_MENU_INVERT_COLORS] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_INVERT_COLORS].OnClick := ChangeInvertColors;

  MyMenuItems[ID_MENU_ANTIALIASING] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_ANTIALIASING].OnClick := ChangeAntiAliasing;

  MyMenuItems[ID_SEPARATOR_ONE] := TMenuItem.Create(Self);
  MyMenuItems[ID_SEPARATOR_ONE].Caption := lpSeparator;

  MyMenuItems[ID_MENU_CONFIG_DIALOG] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_CONFIG_DIALOG].OnClick := ShowConfigDialog;

  MyMenuItems[ID_MENU_TRANSLATIONS] := TMenuItem.Create(Self);

    MySubMenuItems[ID_MENU_ENGLISH] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_ENGLISH].Caption := lpEnglish;
    MySubMenuItems[ID_MENU_ENGLISH].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_PORTUGUESE] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_PORTUGUESE].Caption := lpPortugues;
    MySubMenuItems[ID_MENU_PORTUGUESE].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_SPANISH] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_SPANISH].Caption := lpEspanol;
    MySubMenuItems[ID_MENU_SPANISH].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_FRENCH] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_FRENCH].Caption := lpFrancais;
    MySubMenuItems[ID_MENU_FRENCH].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_GERMAN] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_GERMAN].Caption := lpGerman;
    MySubMenuItems[ID_MENU_GERMAN].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_ITALIAN] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_ITALIAN].Caption := lpItaliano;
    MySubMenuItems[ID_MENU_ITALIAN].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_RUSSIAN] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_RUSSIAN].Caption := lpRussian;
    MySubMenuItems[ID_MENU_RUSSIAN].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_POLISH] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_POLISH].Caption := lpPolish;
    MySubMenuItems[ID_MENU_POLISH].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_JAPANESE] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_JAPANESE].Caption := lpJapanese;
    MySubMenuItems[ID_MENU_JAPANESE].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_TURKISH] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_TURKISH].Caption := lpTurkish;
    MySubMenuItems[ID_MENU_TURKISH].OnClick := ChangeLanguage;

    MySubMenuItems[ID_MENU_CHINESE] := TMenuItem.Create(Self);
    MySubMenuItems[ID_MENU_CHINESE].Caption := lpChinese;
    MySubMenuItems[ID_MENU_CHINESE].OnClick := ChangeLanguage;

    for i := 0 to 10 do MyMenuItems[ID_MENU_TRANSLATIONS].Add(MySubMenuItems[i]);

  MyMenuItems[ID_MENU_SAVE] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_SAVE].OnClick := vConfigurations.Save;

  MyMenuItems[ID_MENU_USE_PLUGIN] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_USE_PLUGIN].OnClick := HandleDynamicMode;
  {$IFDEF UNIX}
  MyMenuItems[ID_MENU_USE_PLUGIN].Enabled := False;
  {$ENDIF}

  MyMenuItems[ID_MENU_CLOSE_PLUGIN] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_CLOSE_PLUGIN].OnClick := HandleClosePlugin;
  {$IFDEF UNIX}
  MyMenuItems[ID_MENU_CLOSE_PLUGIN].Enabled := False;
  {$ENDIF}

  MyMenuItems[ID_SEPARATOR_TWO] := TMenuItem.Create(Self);
  MyMenuItems[ID_SEPARATOR_TWO].Caption := lpSeparator;

  MyMenuItems[ID_MENU_HOMEPAGE] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_HOMEPAGE].OnClick := ShowHomepage;

  MyMenuItems[ID_MENU_ABOUT] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_ABOUT].OnClick := ShowAboutBox;

  MyMenuItems[ID_MENU_HELP] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_HELP].OnClick := ShowHelp;

  MyMenuItems[ID_MENU_CANCEL] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_CANCEL].OnClick := HideMenu;

  MyMenuItems[ID_MENU_TERMINATE] := TMenuItem.Create(Self);
  MyMenuItems[ID_MENU_TERMINATE].OnClick := CloseWindow;

  for i := 0 to 19 do lpMenu.Items.Add(MyMenuItems[i]);

  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Destroys a object derived from the TApplication class
}
{*******************************************************************}
destructor TMainWindow.Destroy;
begin
  // Frees memory alocated on the Create method
  vMenu.Free;
  vGlass.Free;
  DynamicModeTimer.Free;

  { Unregister hotkeys }

  {$IFDEF MSWindows}
    UnregisterHotKey(Handle, 0);
    UnregisterHotKey(Handle, 1);
    UnregisterHotKey(Handle, 2);
    UnregisterHotKey(Handle, 3);
    UnregisterHotKey(Handle, 4);
    UnregisterHotKey(Handle, 5);
    UnregisterHotKey(Handle, 6);
    UnregisterHotKey(Handle, 7);
    UnregisterHotKey(Handle, 8);
    UnregisterHotKey(Handle, 9);
    UnregisterHotKey(Handle, 10);
    UnregisterHotKey(Handle, 11);
    UnregisterHotKey(Handle, 12);
  {$ENDIF}

  inherited Destroy;
end;

{*******************************************************************}
{@@
  Shows the Len.
}
{*******************************************************************}
procedure TMainWindow.ExecuteLens(Sender: TObject);
var
  OSVersion: TOSVersion;
begin
  // The Sleep here is necessary or else sometimes the popup menu
  // won't have time to be painted over and we will capture it's image
  Sleep(10);
  Application.ProcessMessages;

  {*******************************************************************
  *  Close any activated plugins
  *******************************************************************}
  HandleClosePlugin(Sender);

  // Initializes the Multimonitor support
  vGlass.GetScreenSize(vGlass.XScreen, vGlass.YScreen, vGlass.CXScreen, vGlass.CYScreen);

  {$ifdef VMG_DEBUG_SMALL_MODE}
  Self.Left := 0;
  Self.Top := 200;
  Self.Width := 200;
  Self.Height := 200;
  {$else}
  Self.Left := vGlass.XScreen;
  Self.Top := vGlass.YScreen;
  Self.Width := vGlass.CXScreen;
  Self.Height := vGlass.CYScreen;

  // In Linux we definetively need wsFullScreen, otherwise the window manager might do a
  // crazy repositioning of the window
  // In Windows we already have our system for doing the fullscreen, so no need to change whats working
  // In Carbon don't try because it makes wierd effects
  {$IFNDEF Windows}{$ifndef LCLCarbon}
  //Self.WindowState := wsFullScreen; // Requires LCL 0.9.31+
  {$ENDIF}{$ENDIF}
  {$ENDIF}

  vGlass.Left := 0;
  vGlass.Top := 0;
  vGlass.Width := vGlass.CXScreen;
  vGlass.Height := vGlass.CYScreen;

  vGlass.bmpOutput.Width := vGlass.CXScreen;
  vGlass.bmpOutput.Height := vGlass.CYScreen;

  // Initializes the Glass component
  vGlass.Align := alClient;
  vGlass.Parent := Self;
  vGlass.DoubleBuffered := True;
//  vGlass.Color := clNone;
//  Self.Color := clNone;

  // Connects the methods to events

  Self.OnShow := HandleShow;
  vGlass.OnMouseMove := MoveGlass;
  vGlass.OnClick := HideWindow;
  Self.OnHide := HandleHideGlass;

  {$ifdef VMG_DIRECT_FORM_RENDERING}
  Self.OnMouseMove := MoveGlass;
  Self.OnClick := HideWindow;
  Self.OnPaint := HandleFormPaint;
  {$endif}

  Self.OnKeyDown := HandleKeyDown;
  vGlass.OnKeyDown := HandleKeyDown;//* Bugfix for some Linux systems

  Self.OnKeyPress := HandleKeyPress;
  vGlass.OnKeyPress := HandleKeyPress;

  {.$ifndef Win32}
  Self.OnMouseWheel := HandleMouseWheel;
  vGlass.OnMouseWheel := HandleMouseWheel;
  {.$endif}

  // Bug fix for WinCE-LCL
  {$ifdef WinCE}
    Self.OnClose := HandleOnClose;
  {$endif}

  // Updates the position of the mouse
  vGlass.GlassTop := Mouse.CursorPos.Y - vGlass.GlassHeight div 2 - vGlass.YScreen;
  vGlass.GlassLeft := Mouse.CursorPos.X - vGlass.GlassWidth div 2 - vGlass.XScreen;

  // Updates the screen capture
  if not vGlass.GetDisplayBitmap then
    raise Exception.Create('Error in vGlass.GetDisplayBitmap');

  {*******************************************************************
  *  Shows the magnifier with a plugin
  *******************************************************************}
  if vConfigurations.UsePlugins then
  begin
    {$IFDEF USE_PLUGINS}
      { Fixs the starting position of the glass }
      { TODO: Should be removed in the future when it is more flexible }
      vGlass.FixGlassCoordinates;

      vPlugins.LoadPlugin;

      vPlugins.Initialize;
    {$ELSE}
      {$IFDEF Windows}
      // Lets turn aero off first, in the dynamic mode
      // Don't use this code in older version because then an error dialog appears
      OSVersion := vConfigurations.GetOSVersion();
      if OSVersion >= vwWinVista then
        Windows.WinExec('Rundll32 dwmApi #104', Windows.SW_HIDE);

      FormStyle := fsSystemStayOnTop;
      Windows.SetWindowLong(Handle, GWL_EXSTYLE,
        Windows.GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOPMOST
        or WS_EX_LAYERED or WS_EX_TRANSPARENT);
      Windows.SetLayeredWindowAttributes(Handle, 0, 255, LWA_ALPHA);

      // Updates the position of the window
      vGlass.GlassTop := Mouse.CursorPos.Y - vGlass.GlassHeight div 2 - vGlass.YScreen;
      vGlass.GlassLeft := Mouse.CursorPos.X - vGlass.GlassWidth div 2 - vGlass.XScreen;
      Self.Top := vGlass.GlassTop;
      Self.Left := vGlass.GlassLeft;
      Self.Height := vGlass.GlassHeight;
      Self.Width := vGlass.GlassWidth;

      // Avoids standard events of the standard glass
      OnShow := nil;
      OnMouseMove := nil;
      vGlass.OnMouseMove := nil;

      // Install a timer to update the image
      DynamicModeTimer.Enabled := True;

      // Now shows the glass
      ControlToInvalidate.Invalidate;
      Show;
      {$ENDIF}
    {$ENDIF}
  end
  {*******************************************************************
  *  Shows the glass without a plugin
  *******************************************************************}
  else
  begin
    // The cursor isn't visible while the glass is on
    // But this doesn't work on Carbon
    {$ifndef LCLCarbon}
      vGlass.Cursor := crNone;
    {$endif}

    {$IFDEF Windows}
    SetWindowLong(Handle, GWL_EXSTYLE,
      GetWindowLong(Handle, GWL_EXSTYLE) and not (WS_EX_TOPMOST
      or WS_EX_LAYERED or WS_EX_TRANSPARENT));
    {$endif}

    // Now shows the glass
    Show;

    // Make sure the Glass has focus
    Self.SetFocus;
  end;
end;

{*******************************************************************}
{@@
  Timer which updates the image in the dynamic mode
}
{*******************************************************************}
procedure TMainWindow.HandleDynamicModeTimer(Sender: TObject);
begin
  vGlass.GetDisplayBitmap;
  ControlToInvalidate.Invalidate;
end;

procedure TMainWindow.DoChangeLanguage(AID: Integer);
begin

end;

function TMainWindow.DisableFormBackgroundDrawing(AForm: TCustomForm): Boolean;
begin
  Result := AForm = Self;
end;

{*******************************************************************}
{@@
  Event designed to receive MouseMove messages from
  the OS and respond to them moving the glass.
}
{*******************************************************************}
procedure TMainWindow.MoveGlass(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  vGlass.GlassTop := Mouse.CursorPos.Y - vGlass.GlassHeight div 2 - vGlass.YScreen;
  vGlass.GlassLeft := Mouse.CursorPos.X - vGlass.GlassWidth div 2 - vGlass.XScreen;
  {$IFNDEF MAGNIFIER_USE_NATIVE_STRETCH}
  vGlass.FixGlassCoordinates(False);
  {$ENDIF}
  ControlToInvalidate.Invalidate;
end;

{*******************************************************************}
{@@
  Adds an icon to the taskbar status area.

  @param  uID      identifier of the icon to delete

  @return          TRUE if successful or FALSE otherwise.
}
{*******************************************************************}
function TMainWindow.SetTaskbarIcon(uID: Cardinal): Boolean;
{$IFDEF UNIX}
var
  PNGImage: TPortableNetworkGraphic;
{$ENDIF}
begin
   Result := True;

{$IFDEF Windows}

  SystrayIcon.Icon.Handle := Windows.LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2));

{$ENDIF}
{$IFDEF UNIX}

  try
    Write('[TMainWindow.SetTaskbarIcon] Loading ' + vConfigurations.MyDirectory + 'icon3.png');
    PNGImage := TPortableNetworkGraphic.Create;
    PNGImage.LoadFromFile(vConfigurations.MyDirectory + 'icon3.png');
    SystrayIcon.Icon.Assign(PngImage);
  except
    Write(ErrorLoading);
    Result := False;
  end;

  PngImage.Free;

  WriteLn('');

{$ENDIF}

  SystrayIcon.Hint := szAppTitle;
  SystrayIcon.PopUpMenu := vMenu;
  SystrayIcon.OnClick := SystrayClick;
//  SystrayIcon.OnMouseUp := SystrayMouseUp;

  SystrayIcon.Visible := True;
end;

{*******************************************************************}
{@@
  Click Event on the System Tray Icon
}
{*******************************************************************}
procedure TMainWindow.SystrayClick(Sender: TObject);
begin
  ExecuteLens(Self);
end;

procedure TMainWindow.ShowLensClick(Sender: TObject);
begin
  Sleep(500);
  ExecuteLens(Self);
end;

{*******************************************************************}
{@@
  Call this method when information on vConfigurations has changed
}
{*******************************************************************}
procedure TMainWindow.UpdateConfigurations;
var
  i: Integer;
begin
  {*******************************************************************
  *  Updates the Glass size
  *******************************************************************}
  vGlass.GlassWidth := vConfigurations.xSquare * 32;
  vGlass.GlassHeight := vConfigurations.ySquare * 32;

  {*******************************************************************
  *  Anti-aliasing
  *******************************************************************}
  {$ifdef fpc}
  // Reactivate in laz 0.9.28
//  if vConfigurations.AntiAliasing then vGlass.Canvas.AntialiasingMode := amOn
//  else vGlass.Canvas.AntialiasingMode := amOff;
  {$endif}

  {*******************************************************************
  *  Updates the System Tray pointer to the menu
  *******************************************************************}
  SystrayIcon.PopUpMenu := vMenu;
{$ifdef fpc}
  SystrayIcon.InternalUpdate;
{$endif}

  {*******************************************************************
  *  Updates the checked menu items
  *******************************************************************}
  vMenu.Items[ID_MENU_TOOLS].Checked := vConfigurations.showTools;
  vMenu.Items[ID_MENU_GRAPHICAL_BORDER].Checked := vConfigurations.graphicalBorder;
  vMenu.Items[ID_MENU_INVERT_COLORS].Checked := vConfigurations.invertColors;
  vMenu.Items[ID_MENU_ANTIALIASING].Checked := vConfigurations.AntiAliasing;
  vMenu.Items[ID_MENU_USE_PLUGIN].Checked := vConfigurations.UsePlugins;

  {*******************************************************************
  *  Updates the checked submenu items
  *******************************************************************}
  for i := 0 to 12 do vMenu.Items[ID_MENU_WIDTH].Items[i].Checked := False;

  case vGlass.GlassWidth of
   64:   vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_64].Checked := True;
   96:   vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_96].Checked := True;
   128:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_128].Checked := True;
   192:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_192].Checked := True;
   256:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_256].Checked := True;
   320:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_320].Checked := True;
   416:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_416].Checked := True;
   512:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_512].Checked := True;
   640:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_640].Checked := True;
   768:  vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_768].Checked := True;
   1024: vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_1024].Checked := True;
   1280: vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_1280].Checked := True;
   1600: vMenu.Items[ID_MENU_WIDTH].Items[ID_MENU_WIDTH_1600].Checked := True;
  end;

  for i := 0 to 9 do vMenu.Items[ID_MENU_HEIGHT].Items[i].Checked := False;

  case vGlass.GlassHeight of
   64:   vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_64].Checked := True;
   96:   vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_96].Checked := True;
   128:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_128].Checked := True;
   160:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_160].Checked := True;
   192:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_192].Checked := True;
   256:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_256].Checked := True;
   320:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_320].Checked := True;
   512:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_512].Checked := True;
   768:  vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_768].Checked := True;
   1024: vMenu.Items[ID_MENU_HEIGHT].Items[ID_MENU_HEIGHT_1024].Checked := True;
  end;

  for i := 0 to 6 do vMenu.Items[ID_MENU_MAGNIFICATION].Items[i].Checked := False;

  if vConfigurations.iMagnification = 1.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_1X].Checked := True
  else if  vConfigurations.iMagnification = 1.5 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_1_5X].Checked := True
  else if  vConfigurations.iMagnification = 2.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_2X].Checked := True
  else if  vConfigurations.iMagnification = 3.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_3X].Checked := True
  else if  vConfigurations.iMagnification = 4.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_4X].Checked := True
  else if  vConfigurations.iMagnification = 8.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_8X].Checked := True
  else if  vConfigurations.iMagnification = 16.0 then
   vMenu.Items[ID_MENU_MAGNIFICATION].Items[ID_MENU_MAGNIFICATION_16X].Checked := True;

  // On Carbon we need to update the menu again
  {$ifdef LCLCarbon}
    SystrayIcon.InternalUpdate;
  {$endif}
end;

{*******************************************************************}
{@@
  Changes the current language

  @param  Sender   The object which requested the action.
                   This handler actually uses the Sender to
                   verify which menu item has activated it.
}
{*******************************************************************}
procedure TMainWindow.ChangeLanguage(Sender: TObject);
begin
  if (Sender is TMenuItem) then
  begin
    vTranslations.TranslateToLanguage((Sender as TMenuItem).MenuIndex);
    vConfigurations.Language := (Sender as TMenuItem).MenuIndex;
  end;

  TranslateTaskbarMenu(Self);
end;

{*******************************************************************}
{@@
  Translates the menu items
}
{*******************************************************************}
procedure TMainWindow.TranslateTaskbarMenu(Sender: TObject);
begin
  vMenu.Items[ID_MENU_ACTIVATE].Caption := vTranslations.lpActivate;
  vMenu.Items[ID_MENU_WIDTH].Caption := vTranslations.lpWidth;
  vMenu.Items[ID_MENU_HEIGHT].Caption := vTranslations.lpHeight;
  vMenu.Items[ID_MENU_MAGNIFICATION].Caption := vTranslations.lpMagnification;
  vMenu.Items[ID_MENU_TOOLS].Caption := vTranslations.lpTools;
  vMenu.Items[ID_MENU_GRAPHICAL_BORDER].Caption := vTranslations.lpGraphicalBorder;
  vMenu.Items[ID_MENU_INVERT_COLORS].Caption := vTranslations.lpInvertColors;
  vMenu.Items[ID_MENU_ANTIALIASING].Caption := vTranslations.lpAntiAliasing;
  vMenu.Items[ID_MENU_CONFIG_DIALOG].Caption := vTranslations.lpConfigDialog;
  vMenu.Items[ID_MENU_TRANSLATIONS].Caption := vTranslations.lpTranslations;
  vMenu.Items[ID_MENU_SAVE].Caption := vTranslations.lpSave;
  vMenu.Items[ID_MENU_USE_PLUGIN].Caption := vTranslations.lpDynamicMode;
  vMenu.Items[ID_MENU_CLOSE_PLUGIN].Caption := vTranslations.lpClosePlugin;
  vMenu.Items[ID_MENU_HOMEPAGE].Caption := vTranslations.lpHomepage;
  vMenu.Items[ID_MENU_ABOUT].Caption := vTranslations.lpAbout;
  vMenu.Items[ID_MENU_HELP].Caption := vTranslations.lpHelp;
  vMenu.Items[ID_MENU_CANCEL].Caption := vTranslations.lpCancel;
  vMenu.Items[ID_MENU_TERMINATE].Caption := vTranslations.lpExit;

  // On Carbon we need to update the menu
  {$ifdef LCLCarbon}
    SystrayIcon.InternalUpdate;
  {$endif}
end;

{*******************************************************************}
{@@
  Action executed when the user clicks on the "Hide" menu item
}
{*******************************************************************}
procedure TMainWindow.HideMenu(Sender: TObject);
begin
  { Just doing nothing is enougth to hide the menu }
end;

procedure TMainWindow.HandleFormPaint(Sender: TObject);
var
  DrawInfo: TGlassDrawInfo;
begin
  {$ifdef VMG_DIRECT_FORM_RENDERING}
  // Loads the AntiAliasing configuration
  if vConfigurations.AntiAliasing then
    Canvas.AntialiasingMode := amOn
  else Canvas.AntialiasingMode := amOff;

  // Ask for update of the whole window
  vGlass.CalculateDrawInfo(Canvas, DrawInfo);
  if vConfigurations.UsePlugins then
  begin
    vGlass.DrawDynamicModeGlass(Canvas, DrawInfo);
  end
  else
  begin
    vGlass.DrawStandardGlass(Canvas, DrawInfo);
    vGlass.DrawGraphicalTools(Canvas, DrawInfo);
  end;
  {$ifend}
end;

{*******************************************************************}
{@@
  Action executed to invert the colors
}
{*******************************************************************}
procedure TMainWindow.ChangeInvertColors(Sender: TObject);
begin
  vConfigurations.invertColors := not vConfigurations.invertColors;
  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Action executed to change the graphical border state
}
{*******************************************************************}
procedure TMainWindow.ChangeGraphicalBorder(Sender: TObject);
begin
  vConfigurations.graphicalBorder := not vConfigurations.graphicalBorder;
  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Action executed to show the project's homepage

  Under Unix we first try to locate a software to
  open the default browser. If we can't find it,
  we just try to use Firefox
}
{*******************************************************************}
procedure TMainWindow.ShowHomePage(Sender: TObject);
begin
  LCLIntf.OpenURL(VMG_WEBSITE);
end;

{*******************************************************************}
{@@
  Show the about box
}
{*******************************************************************}
procedure TMainWindow.ShowAboutBox(Sender: TObject);
begin
  vAboutWindow.ShowModal;
end;

{*******************************************************************}
{@@
  Show the configurations dialog
}
{*******************************************************************}
procedure TMainWindow.ShowConfigDialog(Sender: TObject);
begin
  HandleClosePlugin(nil); // Otherwise there might be problems in the dialog
  vConfigDialog.ShowModal;
  ChangeAutoRun(Self);
end;

{*******************************************************************}
{@@
  Action executed to change the Len Height

  @param   Sender  The object which requested the action
}
{*******************************************************************}
procedure TMainWindow.ChangeHeight(Sender: TObject);
begin
  if (Sender is TMenuItem) then
  begin
    case (Sender as TMenuItem).MenuIndex of
     ID_MENU_HEIGHT_64: vConfigurations.ySquare := 2;
     ID_MENU_HEIGHT_96: vConfigurations.ySquare := 3;
     ID_MENU_HEIGHT_128: vConfigurations.ySquare := 4;
     ID_MENU_HEIGHT_160: vConfigurations.ySquare := 5;
     ID_MENU_HEIGHT_192: vConfigurations.ySquare := 6;
     ID_MENU_HEIGHT_256: vConfigurations.ySquare := 8;
     ID_MENU_HEIGHT_320: vConfigurations.ySquare := 10;
     ID_MENU_HEIGHT_512: vConfigurations.ySquare := 16;
     ID_MENU_HEIGHT_768: vConfigurations.ySquare := 24;
     ID_MENU_HEIGHT_1024: vConfigurations.ySquare := 32;
    end;
  end;
  UpdateConfigurations;
  if vConfigurations.UsePlugins then vMainWindow.Height := vGlass.GlassHeight;
end;

{*******************************************************************}
{@@
  Action executed to change the Len Width

  @param   Sender  The object which requested the action
}
{*******************************************************************}
procedure TMainWindow.ChangeWidth(Sender: TObject);
begin
  if (Sender is TMenuItem) then
  begin
    case (Sender as TMenuItem).MenuIndex of
     ID_MENU_WIDTH_64: vConfigurations.xSquare := 2;
     ID_MENU_WIDTH_96: vConfigurations.xSquare := 3;
     ID_MENU_WIDTH_128: vConfigurations.xSquare := 4;
     ID_MENU_WIDTH_192: vConfigurations.xSquare := 6;
     ID_MENU_WIDTH_256: vConfigurations.xSquare := 8;
     ID_MENU_WIDTH_320: vConfigurations.xSquare := 10;
     ID_MENU_WIDTH_416: vConfigurations.xSquare := 13;
     ID_MENU_WIDTH_512: vConfigurations.xSquare := 16;
     ID_MENU_WIDTH_640: vConfigurations.xSquare := 20;
     ID_MENU_WIDTH_768: vConfigurations.xSquare := 24;
     ID_MENU_WIDTH_1024: vConfigurations.xSquare := 32;
     ID_MENU_WIDTH_1280: vConfigurations.xSquare := 40;
     ID_MENU_WIDTH_1600: vConfigurations.xSquare := 50;
    end;
  end;
  UpdateConfigurations;
  if vConfigurations.UsePlugins then vMainWindow.Width := vGlass.GlassWidth;
end;

{*******************************************************************}
{@@
  Action executed to change the magnification status

  @param   Sender  The object which requested the action
}
{*******************************************************************}
procedure TMainWindow.ChangeMagnification(Sender: TObject);
begin
  if (Sender is TMenuItem) then
  begin
    case (Sender as TMenuItem).MenuIndex of
     ID_MENU_MAGNIFICATION_1X:   vConfigurations.iMagnification := 1.0;
     ID_MENU_MAGNIFICATION_1_5X: vConfigurations.iMagnification := 1.5;
     ID_MENU_MAGNIFICATION_2X:   vConfigurations.iMagnification := 2.0;
     ID_MENU_MAGNIFICATION_3X:   vConfigurations.iMagnification := 3.0;
     ID_MENU_MAGNIFICATION_4X:   vConfigurations.iMagnification := 4.0;
     ID_MENU_MAGNIFICATION_8X:   vConfigurations.iMagnification := 8.0;
     ID_MENU_MAGNIFICATION_16X:  vConfigurations.iMagnification := 16.0;
    end;
  end;

  UpdateConfigurations;
end;

{*******************************************************************}
{@@
}
{*******************************************************************}
procedure TMainWindow.ChangeAutoRun(Sender: TObject);
{$IFDEF Windows}
var
  Reg: TRegistry;
{$ENDIF}
begin
{$IFDEF Windows}
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True) then
    begin
      if vConfigurations.autoRun then Reg.WriteString(szAppTitle, '"' + ParamStr(0) + '"')
      else Reg.DeleteValue(szAppTitle);
    end;
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
{$ENDIF}

  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Updates the HotKey state according to vConfigurations
}
{*******************************************************************}
procedure TMainWindow.UpdateHotKey(Sender: TObject);
begin
{$IFDEF Windows}
  {$IFNDEF WinCE}
    case vConfigurations.HotKeyMode of
     ID_HOTKEY_NO_HOTKEY:
     begin
       UnregisterHotKey(Handle, 0);
       RegisterHotKey(vMainWindow.Handle, 1, MOD_ALT or MOD_CONTROL, VK_LEFT);
       RegisterHotKey(vMainWindow.Handle, 2, MOD_ALT or MOD_CONTROL, VK_UP);
       RegisterHotKey(vMainWindow.Handle, 3, MOD_ALT or MOD_CONTROL, VK_RIGHT);
       RegisterHotKey(vMainWindow.Handle, 4, MOD_ALT or MOD_CONTROL, VK_DOWN);
       RegisterHotKey(vMainWindow.Handle, 5, MOD_ALT or MOD_CONTROL, VK_A);
       RegisterHotKey(vMainWindow.Handle, 6, MOD_ALT or MOD_CONTROL, VK_W);
       RegisterHotKey(vMainWindow.Handle, 7, MOD_ALT or MOD_CONTROL, VK_D);
       RegisterHotKey(vMainWindow.Handle, 8, MOD_ALT or MOD_CONTROL, VK_S);
       RegisterHotKey(vMainWindow.Handle, 9, MOD_ALT or MOD_CONTROL, VK_NumPad4);
       RegisterHotKey(vMainWindow.Handle, 10, MOD_ALT or MOD_CONTROL, VK_NumPad8);
       RegisterHotKey(vMainWindow.Handle, 11, MOD_ALT or MOD_CONTROL, VK_NumPad5);
       RegisterHotKey(vMainWindow.Handle, 12, MOD_ALT or MOD_CONTROL, VK_NumPad6);
     end;
     ID_HOTKEY_CTRLALTKEY:
     begin
       RegisterHotKey(Handle, 0, MOD_ALT or MOD_CONTROL, VkKeyScan(vConfigurations.HotKeyKey));
       RegisterHotKey(vMainWindow.Handle, 1, MOD_ALT or MOD_CONTROL, VK_LEFT);
       RegisterHotKey(vMainWindow.Handle, 2, MOD_ALT or MOD_CONTROL, VK_UP);
       RegisterHotKey(vMainWindow.Handle, 3, MOD_ALT or MOD_CONTROL, VK_RIGHT);
       RegisterHotKey(vMainWindow.Handle, 4, MOD_ALT or MOD_CONTROL, VK_DOWN);
       RegisterHotKey(vMainWindow.Handle, 5, MOD_ALT or MOD_CONTROL, VK_A);
       RegisterHotKey(vMainWindow.Handle, 6, MOD_ALT or MOD_CONTROL, VK_W);
       RegisterHotKey(vMainWindow.Handle, 7, MOD_ALT or MOD_CONTROL, VK_D);
       RegisterHotKey(vMainWindow.Handle, 8, MOD_ALT or MOD_CONTROL, VK_S);
       RegisterHotKey(vMainWindow.Handle, 9, MOD_ALT or MOD_CONTROL, VK_NumPad4);
       RegisterHotKey(vMainWindow.Handle, 10, MOD_ALT or MOD_CONTROL, VK_NumPad8);
       RegisterHotKey(vMainWindow.Handle, 11, MOD_ALT or MOD_CONTROL, VK_NumPad5);
       RegisterHotKey(vMainWindow.Handle, 12, MOD_ALT or MOD_CONTROL, VK_NumPad6);
     end;
     ID_HOTKEY_DISABLE_ASDW:
     begin
       UnregisterHotKey(Handle, 0);
       RegisterHotKey(vMainWindow.Handle, 1, MOD_ALT or MOD_CONTROL, VK_LEFT);
       RegisterHotKey(vMainWindow.Handle, 2, MOD_ALT or MOD_CONTROL, VK_UP);
       RegisterHotKey(vMainWindow.Handle, 3, MOD_ALT or MOD_CONTROL, VK_RIGHT);
       RegisterHotKey(vMainWindow.Handle, 4, MOD_ALT or MOD_CONTROL, VK_DOWN);
       UnregisterHotKey(Handle, 5);
       UnregisterHotKey(Handle, 6);
       UnregisterHotKey(Handle, 7);
       UnregisterHotKey(Handle, 8);
       UnregisterHotKey(Handle, 9);
       UnregisterHotKey(Handle, 10);
       UnregisterHotKey(Handle, 11);
       UnregisterHotKey(Handle, 12);
     end;
    end;
  {$ENDIF}
{$ENDIF}
end;

{$IFDEF Win32}
{*******************************************************************}
{@@
  Window function of the main window.
  Only handles manually the messages for the taskbar icon.
  Other messages are forwarded to the Component Library
}
{*******************************************************************}
procedure TMainWindow.WndProc(var TheMessage: TLMessage);
var
  i: Integer;
  delta: ShortInt;
  wheel_delta: ShortInt;
  rotation: Double;
begin
  case TheMessage.Msg of
    WM_HOTKEY:
    begin
      case HiWord(TheMessage.lParam) of
       VK_UP, VK_NumPad8, VK_W:
       begin
         vGlass.GlassTop := vGlass.GlassTop - 10;
         vGlass.FixGlassCoordinates;
         {$IFNDEF USE_PLUGINS}
         if vConfigurations.UsePlugins then vMainWindow.Top := vGlass.GlassTop;
         ControlToInvalidate.Invalidate;
         {$ENDIF}
       end;
       VK_DOWN, VK_NumPad5, VK_S:
       begin
         vGlass.GlassTop := vGlass.GlassTop + 10;
         vGlass.FixGlassCoordinates;
         {$IFNDEF USE_PLUGINS}
         if vConfigurations.UsePlugins then vMainWindow.Top := vGlass.GlassTop;
         ControlToInvalidate.Invalidate;
         {$ENDIF}
       end;
       VK_RIGHT, VK_NumPad6, VK_D:
       begin
         vGlass.GlassLeft := vGlass.GlassLeft + 10;
         vGlass.FixGlassCoordinates;
         {$IFNDEF USE_PLUGINS}
         if vConfigurations.UsePlugins then vMainWindow.Left := vGlass.GlassLeft;
         ControlToInvalidate.Invalidate;
         {$ENDIF}
       end;
       VK_LEFT, VK_NumPad4, VK_A:
       begin
         vGlass.GlassLeft := vGlass.GlassLeft - 10;
         vGlass.FixGlassCoordinates;
         {$IFNDEF USE_PLUGINS}
         if vConfigurations.UsePlugins then vMainWindow.Left := vGlass.GlassLeft;
         ControlToInvalidate.Invalidate;
         {$ENDIF}
       end;
      else
        vMainWindow.ExecuteLens(vMainWindow);
      end;
    end;

{    WM_MOUSEWHEEL:
    begin
      // Why was the old code like this?
//      wheel_delta := HiWord(Message.WParam);
//      Move(wheel_delta, delta, SizeOf(Word));
//      rotation := delta / WHEEL_DELTA;

//      if (rotation > 0.0) then delta := Round(rotation + 0.5)
//      else delta := Round(rotation - 0.5);

      // New better code, based on MSDN docs
      wheel_delta := HiWord(Message.WParam);
      delta := wheel_delta div 120;

      for i := 1 to abs(delta) do
      begin
        // Call same code as from VK_ADD, VK_SUBTRACT handlers
        if (delta > 0.0) then
         vConfigurations.iMagnification := vConfigurations.iMagnification + 0.5
        else vConfigurations.iMagnification := vConfigurations.iMagnification - 0.5;
      end;

      // Hard limits for the magnification
      if vConfigurations.iMagnification < 1.0 then vConfigurations.iMagnification := 1.0
      else if vConfigurations.iMagnification > 16 then vConfigurations.iMagnification := 16;

      vGlass.Repaint;
    end;}

    MYWM_SHOWGLASS:
    begin
      // This check fixes a bug when using multiple times the keyboard shortcut
      // The glass is shown multiple times causes it to screenshot the previous one
      if not vMainWindow.Visible then vMainWindow.ExecuteLens(nil);
    end;
  end;

  inherited WndProc(TheMessage);
end;
{$ENDIF}

{*******************************************************************}
{@@
  Action executed when the user clicks on the "Anti-Aliasing" menu item
}
{*******************************************************************}
procedure TMainWindow.ChangeAntiAliasing(Sender: TObject);
begin
  vConfigurations.AntiAliasing := not vConfigurations.AntiAliasing;

  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Action executed to change the tools status
}
{*******************************************************************}
procedure TMainWindow.ChangeTools(Sender: TObject);
begin
  vConfigurations.showTools := not vConfigurations.showTools;
  UpdateConfigurations;
end;

{*******************************************************************}
{@@
  Handles the keyboard key actions
}
{*******************************************************************}
procedure TMainWindow.HandleKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
   VK_UP:
   begin
     vConfigurations.ySquare := vConfigurations.ySquare - 1;
     if vConfigurations.ySquare <= 2 then vConfigurations.ySquare := 2;
     UpdateConfigurations;
     if vConfigurations.UsePlugins then vMainWindow.Height := vGlass.GlassHeight;
   end;
   VK_DOWN:
   begin
     vConfigurations.ySquare := vConfigurations.ySquare + 1;
     if vConfigurations.ySquare >= 32 then vConfigurations.ySquare := 32;
     UpdateConfigurations;
     if vConfigurations.UsePlugins then vMainWindow.Height := vGlass.GlassHeight;
   end;
   VK_RIGHT:
   begin
     vConfigurations.xSquare := vConfigurations.xSquare + 1;
     if vConfigurations.xSquare >= 50 then vConfigurations.xSquare := 50;
     UpdateConfigurations;
     if vConfigurations.UsePlugins then vMainWindow.Width := vGlass.GlassWidth;
   end;
   VK_LEFT:
   begin
     vConfigurations.xSquare := vConfigurations.xSquare - 1;
     if vConfigurations.xSquare <= 2 then vConfigurations.xSquare := 2;
     UpdateConfigurations;
     if vConfigurations.UsePlugins then vMainWindow.Width := vGlass.GlassWidth;
   end;
   VK_W: Mouse.CursorPos := Point(Mouse.CursorPos.X, Mouse.CursorPos.Y - 10);
   VK_S: Mouse.CursorPos := Point(Mouse.CursorPos.X, Mouse.CursorPos.Y + 10);
   VK_D: Mouse.CursorPos := Point(Mouse.CursorPos.X + 10, Mouse.CursorPos.Y);
   VK_A: Mouse.CursorPos := Point(Mouse.CursorPos.X - 10, Mouse.CursorPos.Y);
   VK_PRIOR: Mouse.CursorPos := Point(Mouse.CursorPos.X, Mouse.CursorPos.Y - 50); // Page Up
   VK_NEXT: Mouse.CursorPos := Point(Mouse.CursorPos.X, Mouse.CursorPos.Y + 50);  // Page Down
   VK_ESCAPE: HideWindow(Self);
   VK_RETURN: HideWindow(Self);
   VK_B: ChangeGraphicalBorder(Self);
   VK_Q: CloseWindow(Self);
   VK_C: if Shift = [ssCtrl] then Clipboard.AsText := '';
  else
    Exit;
  end;

  // Hard limits for the magnification
  if vConfigurations.iMagnification < 1.0 then vConfigurations.iMagnification := 1.0
  else if vConfigurations.iMagnification > 16 then vConfigurations.iMagnification := 16;

  // Carbon doesn't generate an OnMove when the cursor is programatically changed
  {$ifdef LCLCarbon}
  Self.MoveGlass(nil, [], 0, 0);
  {$endif}

  ControlToInvalidate.Invalidate;
end;

{*******************************************************************}
{@@
  Handles the keyboard key actions
}
{*******************************************************************}
procedure TMainWindow.HandleKeyPress(Sender: TObject; var Key: Char);
begin
  { We need to Handle + and - in OnKeyPress and not OnKeyDown to
    allow for building this characters with key combos. OnKeyDown
    works for single key presses, not combos }
  case Key of
   '+': vConfigurations.iMagnification := vConfigurations.iMagnification + 0.5;
   '-': vConfigurations.iMagnification := vConfigurations.iMagnification - 0.5;
   'X': vConfigurations.Contrast := vConfigurations.Contrast + 1;
   'x': vConfigurations.Contrast := vConfigurations.Contrast + 1;
   'Z': vConfigurations.Contrast := vConfigurations.Contrast - 1;
   'z': vConfigurations.Contrast := vConfigurations.Contrast - 1;
   'C': vConfigurations.Contrast := 0;
   'c': vConfigurations.Contrast := 0;
  else
    Exit;
  end;

  // Hard limits for the magnification
  if vConfigurations.iMagnification < 1.0 then vConfigurations.iMagnification := 1.0
  else if vConfigurations.iMagnification > 16 then vConfigurations.iMagnification := 16;

  // Hard limits for the contrast
  if vConfigurations.Contrast < 0 then vConfigurations.Contrast := 1
  else if vConfigurations.Contrast > 126 then vConfigurations.Contrast := 126;

  ControlToInvalidate.Invalidate;
end;

{*******************************************************************
*  TMainWindow.HandleOnClose ()
*
*  PARAMETERS:     Sender -
*
*  DESCRIPTOON:   This procedure is fixes a bug on Windows CE Lazarus
*                 Component Library that prevents the main window from
*                 closing
*
*******************************************************************}
procedure TMainWindow.HandleOnClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  Self.Close;
end;

{*******************************************************************
*  TMainWindow.HandleShow ()
*
*  PARAMETERS:     Sender -
*
*  DESCRIPTOON:   This procedure is required because setting the position
*                 of a window on MS Windows to a negative value will fail
*                 before the window is shown, and this is required to
*                 support multiple monitors
*
*******************************************************************}
procedure TMainWindow.HandleShow(Sender: TObject);
begin
  {$ifndef VMG_DEBUG_SMALL_MODE}
  Self.Left := vGlass.XScreen;
  Self.Top := vGlass.YScreen;
  Self.Width := vGlass.CXScreen;
  Self.Height := vGlass.CYScreen;
  {$endif}

  {$if defined(LCLQt)} // Under Carbon don't even try, as it makes things worse
  vGlass.Cursor := crNone;
  {$ifend}
end;

{*******************************************************************
*  TMainWindow.HandleMouseWheel ()
*
*  PARAMETERS:    Sender -
*
*  DESCRIPTOON:   Handles mouse wheel scrolling
*
*******************************************************************}
procedure TMainWindow.HandleMouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
  i, delta: Integer;
begin
  delta := wheeldelta div 120;

  for i := 1 to abs(delta) do
  begin
    // Call same code as from VK_ADD, VK_SUBTRACT handlers
    if (WheelDelta > 0.0) then
     vConfigurations.iMagnification := vConfigurations.iMagnification + 0.5
    else vConfigurations.iMagnification := vConfigurations.iMagnification - 0.5;
  end;

  // Hard limits for the magnification
  if vConfigurations.iMagnification < 1.0 then vConfigurations.iMagnification := 1.0
  else if vConfigurations.iMagnification > 16 then vConfigurations.iMagnification := 16;

  {$IFDEF UNIX}
  ControlToInvalidate.Invalidate;
  {$ENDIF}

  vGlass.Repaint;
end;

{*******************************************************************
*  TMainWindow.HandleDynamicMode ()
*
*  DESCRIPTION:
*
*  PARAMETERS:     Sender -
*
*******************************************************************}
procedure TMainWindow.HandleDynamicMode(Sender: TObject);
begin
  // First close the plugin to avoid clashes
  HandleClosePlugin(Sender);

  vConfigurations.UsePlugins := not vConfigurations.UsePlugins;

  UpdateConfigurations;
end;

{*******************************************************************
*  TMainWindow.HandleHideGlass ()
*
*  DESCRIPTION:     Under Carbon and Qt the cursor keeps disappearing after the glass is hidden,
*                   so a workaround is needed
*
*******************************************************************}
procedure TMainWindow.HandleHideGlass(Sender: TObject);
begin
  DynamicModeTimer.Enabled := False;
  // Some widgetsets have trouble with mouse cursors
  // Under Carbon it would be necessary, but we don't even try setting the cursor
  {$if defined(LCLQt)}
  vGlass.Cursor := crArrow;
  {$ifend}
end;

{*******************************************************************
*  TMainWindow.ShowHelp ()
*
*  DESCRIPTION:    Action executed to show the project's homepage
*
*                  Under Unix we first try to locate a software to
*                  open the default application. If we can't find it,
*                  we just try to use XPDF
*
*  PARAMETERS:     Sender - The object which requested the action
*
*  RETURNS:        Nothing
*
*******************************************************************}
procedure TMainWindow.ShowHelp(Sender: TObject);
var
  Lang, HelpFileName: string;
begin
  case vConfigurations.Language of
   ID_MENU_PORTUGUESE: Lang := 'PT';
//   ID_MENU_SPANISH: ;
//   ID_MENU_FRENCH: ;
  else
   Lang := 'EN';
  end;

  HelpFileName := vConfigurations.MyDirectory + 'README-' + Lang + '.pdf';

//  HelpFileName := vConfigurations.MyDirectory + 'README-' + Lang + '.fml';

//  vFMLViewerDialog.LoadFromFile(HelpFileName);

//  vFMLViewerDialog.Show;

  LCLIntf.OpenDocument(HelpFileName);
end;

{*******************************************************************
*  TMainWindow.ChangeShowWhenExecuted ()
*
*  DESCRIPTION:
*
*  PARAMETERS:     Sender -
*
*******************************************************************}
procedure TMainWindow.ChangeShowWhenExecuted(Sender: TObject);
begin
  vConfigurations.showWhenExecuted := not vConfigurations.showWhenExecuted;

  UpdateConfigurations;
end;

{*******************************************************************}
{@@
}
{*******************************************************************}
procedure TMainWindow.HandleClosePlugin(Sender: TObject);
begin
  {$IFDEF WINDOWS}
  {$IFDEF USE_PLUGINS}
  if vPlugins.Initialized then vPlugins.Finalize;

  if vPlugins.Loaded then vPlugins.UnloadPlugin;
  {$ELSE}
  Hide;
  {$ENDIF}
  {$ENDIF}
end;

end.