-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
109 lines (93 loc) · 2.28 KB
/
main.cpp
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
#include "qtphonedlg.h"
#include <QtGui/QApplication>
#include <QTextCodec>
/*
int main(int argc, char *argv[])
{
QTextCodec::setCodecForTr(QTextCodec::codecForName("windows-1251"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("windows-1251"));
#ifdef _WIN32
//#ifdef DEBUG
WCHAR title[256];
if(GetConsoleTitle(title,sizeof(title))==0)
{
AllocConsole();
freopen("CONOUT$","wt", stdout);
freopen("CONOUT$","wt", stderr);
freopen("CONIN$","rt", stdin);
GetConsoleTitle(title,sizeof(title));
HWND hConsoleWindow = FindWindow(NULL,title);
ShowWindow(hConsoleWindow,SW_SHOWMINNOACTIVE);
}
//#endif
#endif
QApplication a(argc, argv);
PWLibProcess pwlibProcess;
QtPhoneDlg *w = new QtPhoneDlg;
w->show();
int rc = a.exec();
delete w;
return rc;
}
*/
class MyTest : public PProcess
{
PCLASSINFO(MyTest, PProcess)
public:
MyTest();
~MyTest();
virtual void Main();
};
PCREATE_PROCESS(MyTest);
MyTest::MyTest()
: PProcess("MyTest", "MyTest", 1, 0, AlphaCode, 0)
{
}
MyTest::~MyTest()
{
}
void MyTest::Main()
{
PArgList & args = GetArguments();
int argCount = args.GetCount();
const char **argV = (const char**)calloc(argCount+1, sizeof(const char*));
bool fCreateConsole = false;
for (int i = 0; i < argCount; i++)
{
argV[i] = (const char*)args.GetParameter(i);
if(strcmp(argV[i], "-c")==0)
fCreateConsole = true;
}
argV[argCount] = NULL;
QTextCodec::setCodecForTr(QTextCodec::codecForName("windows-1251"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("windows-1251"));
#ifdef _WIN32
if(fCreateConsole)
{
WCHAR title[256];
if(GetConsoleTitle(title,sizeof(title))==0)
{
AllocConsole();
freopen("CONOUT$","wt", stdout);
freopen("CONOUT$","wt", stderr);
freopen("CONIN$","rt", stdin);
GetConsoleTitle(title,sizeof(title));
HWND hConsoleWindow = FindWindow(NULL,title);
ShowWindow(hConsoleWindow,SW_SHOWMINNOACTIVE);
}
}
#endif
QApplication a(argCount, (char**)argV);
QtPhoneDlg *w = new QtPhoneDlg;
if (QSystemTrayIcon::isSystemTrayAvailable())
{
QApplication::setQuitOnLastWindowClosed(false);
}
else
{
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
w->show();
}
int rc = a.exec();
delete w;
}