File: magnifier.dpr

package info (click to toggle)
vmg 3.8.1-3
  • 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 (145 lines) | stat: -rw-r--r-- 4,330 bytes parent folder | download | duplicates (7)
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
{
magnifier.dpr

Project file and main source file

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
}
program lente;

{*******************************************************************
*  Compatibility preprocessor code to allow the project to be compiled
* both on the Free Pascal Compiler and on Borland Delphi
*******************************************************************}
{$IFDEF FPC}
  {$MODE DELPHI}{$H+}
{$ENDIF}

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

{*******************************************************************
*  RC and RES Resource files are Windows only
*  Separate files for Delphi and FPC avoids the need to rebuild it
*******************************************************************}
{$IFDEF Windows}
  {$IFDEF FPC}
    {$R fpcmagnifier.rc}
  {$ELSE}
    {$R magnifier.res}
  {$ENDIF}
{$ENDIF}

uses
{$IFDEF FPC}
  Interfaces,
{$ENDIF}
{$IFDEF Windows}
  Windows,
{$ENDIF}
  Forms,
  glass in 'glass.pas',
  constants in 'constants.pas',
  appsettings in 'appsettings.pas',
  app in 'app.pas',
  about in 'about.pas',
  plugins in 'plugins.pas',
  translationsvmg in 'translationsvmg.pas',
  configdlg in 'configdlg.pas',
//  lazfmlviewer in 'lazfmlviewer.pas',
//  fmlscan in 'fmldriver.pas',
  plugininfo, startform;

{@@
  Application Main Procedure

  This procedure is executed as soon as the program is executed
}
var
  AHandle, Semaphore: Cardinal;
  lResult, lStartForm: Boolean;
begin
  lStartForm := False;

  {*******************************************************************
  *  Verifies if another instance is already running by using semaphores
  *******************************************************************}
  {$IFDEF Windows}
    Semaphore := OpenSemaphore(EVENT_ALL_ACCESS, False, szAppTitle);

    // No one is holding the semaphore, so let's create one
    if Semaphore = 0 then
     Semaphore := CreateSemaphore(nil, 3, 3, szAppTitle)
    else
    begin
      AHandle := FindWindow(nil, szAppTitle);
      SendMessage(AHandle, MYWM_SHOWGLASS, 0, 0);
      Exit;
    end;
  {$ENDIF}

  {*******************************************************************
  *  Program initialization
  *
  *  The order in which these methods are called is very important
  *******************************************************************}
  Application.Initialize;
  Application.CreateForm(TMainWindow, vMainWindow);
  Application.CreateForm(TAboutWindow, vAboutWindow);
  Application.CreateForm(TConfigDialog, vConfigDialog);
//  Application.CreateForm(TFMLViewerDialog, vFMLViewerDialog);
  {$IFDEF Windows} // Start up screen on the first run in Windows
  lStartForm := vConfigurations.firstRun;
  if lStartForm then
  begin
    Application.CreateForm(TvStartWindow, vStartWindow);
    vStartWindow.Show();
  end;
  {$ENDIF}

  {*******************************************************************
  *  Features that need to be initialized at software startup are
  * processed here
  *******************************************************************}

  // The Dynamic mode only works on Windows, so force that here
  {$IFNDEF Win32}
  vConfigurations.UsePlugins := False;
  {$ENDIF}

  Application.ShowMainForm := False;

  // Initializes HotKeys
  vMainWindow.UpdateHotKey(nil);

  // If the user selected to auto-start, handle this case here
  if vConfigurations.showWhenExecuted and (not lStartForm) then
    vMainWindow.ExecuteLens(nil);
  { Enters the Message Loop }
  Application.Run;

  { Finalization - Release the semaphore for future instances }
  {$IFDEF Windows}
    if Semaphore <> 0 then CloseHandle(Semaphore);
  {$ENDIF}
end.