aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/BibleCS/sword.cpp
blob: a79b38bf8a8be79111983bde3360b36dabd99963 (plain) (blame)
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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SplashPage.h"
#include <winreg.h>
#include <dir.h>
#include "sword.h"

USERES("sword.res");
USEFORM("mainfrm.cpp", Form1);
USEFORM("AboutBoxfrm.cpp", AboutBox);
USEFORM("bookmarkfrm.cpp", bookmarkForm);
USEFORM("newbmfilefrm.cpp", NewBMfrm);
USEFORM("optionfrm.cpp", Optionsfrm);
USEFORM("searchfrm.cpp", searchForm);
USEUNIT("biblecsmgr.cpp");
USEFORM("ModInstForm.cpp", ModInstFrm);
USEFORM("vrslstfrm.cpp", VerseListForm);
USEFORM("editentryfrm.cpp", EditEntryForm);
USEFORM("versesel.cpp", VerseSelFrm);
USELIB("swordlib.lib");
USEFORM("RangeMaintFrm.cpp", RangeMaintForm);
USEFORM("ModVisFrm.cpp", ModVisForm);
USEUNIT("..\..\swdisprtfchap.cpp");
USEUNIT("..\..\swdisprtf.cpp");
USEFORM("DevOfTheDay.cpp", DevOfTheDay2);
USEFORM("SplashPage.cpp", SplashPg);
USEFORM("FontSel.cpp", FontSelFrm);
USEOBJ("rxlib\Rxcombos.obj");
USEOBJ("rxlib\Vclutils.obj");
USEOBJ("rxlib\Rxcconst.obj");
USEOBJ("rxlib\Rxconst.obj");
USEFORM("StudyProfessor.cpp", Form3);
USELIB("..\..\..\..\..\icu-sword\as_is\win32\borland\icudatab.lib");
USEOBJ("rxlib\RxRichEd.obj");
USEOBJ("rxlib\Maxmin.obj");
USEUNIT("TModuleFonts.cpp");
USEFORM("rtfhintfrm.cpp", RTFHintForm);
USEUNIT("RxRichEditX.cpp");
USEFORM("PreviewForm.cpp", PreviewForm);
USEFORM("PrintFrm.cpp", PrintForm);
USEOBJ("TntUnicodeControls\Unicode.obj");
USEOBJ("TntUnicodeControls\TntControls.obj");
USEOBJ("TntUnicodeControls\TntForms.obj");
USEOBJ("TntUnicodeControls\TntStdCtrls.obj");
USEOBJ("TntUnicodeControls\TntClasses.obj");
USELIB("..\..\..\..\..\icu-sword\as_is\win32\borland\icucommon.lib");
USELIB("..\..\..\..\..\icu-sword\as_is\win32\borland\icui18n.lib");
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

	   LONG result;

	   try {
			 HKEY hkey;
			 HWND otherInst;

			 // see if there's a previous instance running
			 otherInst = ::FindWindow(NULL, "The SWORD Project for Windows");
			 // if so, and we have an argument, send the argument to the other instance
			 if (*lpCmdLine) {
				if (otherInst && *lpCmdLine) {
					result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\OpenVerse", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
					result = RegSetValueEx(hkey, NULL, 0, REG_SZ, lpCmdLine, strlen(lpCmdLine) + 1);
					result = RegCloseKey(hkey);

					PostMessage(otherInst, WM_VERSE, NULL, NULL);
					return 0;
				}

				// TODO 5: if we have a cmdline argument, figure we have to change directories.  BAD, FIX.
				result = Application->ExeName.Length();
				char * dir = new char[result + 1];
				strcpy (dir, Application->ExeName.c_str());
				for (;result > 0 && dir[result] != '\\'; result--) {
					dir[result] = 0;
				}
				chdir(dir);
				delete [] dir;
			}

			 // adjust the registry for our private protocol using the current path
			 result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
			 result = RegSetValueEx(hkey, NULL, 0, REG_SZ, "URL:SWORD Protocol", strlen("URL:SWORD Protocol") + 1);
			 result = RegSetValueEx(hkey, "URL Protocol", 0, REG_SZ, "", 1);
			 result = RegCloseKey(hkey);
			 result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\DefaultIcon", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
			 result = RegSetValueEx(hkey, NULL, 0, REG_SZ, Application->ExeName.c_str(), Application->ExeName.Length() + 1);
			 result = RegCloseKey(hkey);
			 AnsiString opencommand = Application->ExeName + " \"%1\"";
			 result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\shell\\open\\command", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
			 result = RegSetValueEx(hkey, NULL, 0, REG_SZ, opencommand.c_str(), opencommand.Length() + 1);
			 result = RegCloseKey(hkey);


		/*
			 // don't override Logos' setting if it exists
			 result = RegOpenKeyEx(HKEY_CLASSES_ROOT, "libronixdls", 0, KEY_READ | KEY_WRITE, &hkey);
                if (!result) {
                        char* libStr = new char[32];
                        unsigned long libSize = 32;
                        result = RegQueryValueEx(hkey, NULL, NULL, NULL, libStr, &libSize);
                        if (!result) {
                                if (strstr(libStr, "SWORD")) {
                                        result = 1;
                                }
                        }
                }
                if (result) {
                        result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "libronixdls", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
                        result = RegSetValueEx(hkey, NULL, 0, REG_SZ, "URL:SWORD Protocol", strlen("URL:SWORD Protocol") + 1);
                        result = RegSetValueEx(hkey, "URL Protocol", 0, REG_SZ, "", 1);
                        result = RegCloseKey(hkey);
                        result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "libronixdls\\DefaultIcon", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
                        result = RegSetValueEx(hkey, NULL, 0, REG_SZ, Application->ExeName.c_str(), Application->ExeName.Length() + 1);
                        result = RegCloseKey(hkey);
                        AnsiString opencommand = Application->ExeName + " \"%1\"";
                        result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "libronixdls\\shell\\open\\command", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
                        result = RegSetValueEx(hkey, NULL, 0, REG_SZ, opencommand.c_str(), opencommand.Length() + 1);
                        result = RegCloseKey(hkey);
                }
		*/
        }
	catch (Exception &exception) {
		Application->ShowException(&exception);
	}

	try {
		Application->Initialize();
		Application->Title = "The SWORD Project";
		SplashPg = new TSplashPg(static_cast<void*>(NULL));
		SplashPg->Show();
		Application->ProcessMessages();
		Application->CreateForm(__classid(TForm1), &Form1);
		Application->CreateForm(__classid(TAboutBox), &AboutBox);
		Application->CreateForm(__classid(TbookmarkForm), &bookmarkForm);
		Application->CreateForm(__classid(TNewBMfrm), &NewBMfrm);
		Application->CreateForm(__classid(TOptionsfrm), &Optionsfrm);
		Application->CreateForm(__classid(TsearchForm), &searchForm);
		Application->CreateForm(__classid(TModInstFrm), &ModInstFrm);
		Application->CreateForm(__classid(TVerseListForm), &VerseListForm);
		Application->CreateForm(__classid(TEditEntryForm), &EditEntryForm);
		Application->CreateForm(__classid(TVerseSelFrm), &VerseSelFrm);
		Application->CreateForm(__classid(TRangeMaintForm), &RangeMaintForm);
		Application->CreateForm(__classid(TModVisForm), &ModVisForm);
		Application->CreateForm(__classid(TDevOfTheDay2), &DevOfTheDay2);
		Application->CreateForm(__classid(TForm3), &Form3);
		Application->CreateForm(__classid(TRTFHintForm), &RTFHintForm);
		Application->CreateForm(__classid(TPreviewForm), &PreviewForm);
		Application->CreateForm(__classid(TPrintForm), &PrintForm);
		Application->Run();
		delete SplashPg;
	}
	catch (Exception &exception) {
		Application->ShowException(&exception);
	}
	return 0;
}
//---------------------------------------------------------------------------