|
|
|
@ -11,7 +11,11 @@
@@ -11,7 +11,11 @@
|
|
|
|
|
#define ID_TRAY_ICON 2050 |
|
|
|
|
#define WM_TRAYICON (WM_USER + 1) |
|
|
|
|
|
|
|
|
|
void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem) |
|
|
|
|
namespace i2p |
|
|
|
|
{ |
|
|
|
|
namespace win32 |
|
|
|
|
{ |
|
|
|
|
static void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem) |
|
|
|
|
{ |
|
|
|
|
HMENU hPopup = CreatePopupMenu(); |
|
|
|
|
InsertMenu (hPopup, 0, MF_BYPOSITION | MF_STRING, ID_ABOUT, "About..."); |
|
|
|
@ -33,7 +37,7 @@ void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
@@ -33,7 +37,7 @@ void ShowPopupMenu (HWND hWnd, POINT *curpos, int wDefaultItem)
|
|
|
|
|
DestroyMenu(hPopup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AddTrayIcon (HWND hWnd) |
|
|
|
|
static void AddTrayIcon (HWND hWnd) |
|
|
|
|
{ |
|
|
|
|
NOTIFYICONDATA nid; |
|
|
|
|
memset(&nid, 0, sizeof(nid)); |
|
|
|
@ -47,7 +51,7 @@ void AddTrayIcon (HWND hWnd)
@@ -47,7 +51,7 @@ void AddTrayIcon (HWND hWnd)
|
|
|
|
|
Shell_NotifyIcon(NIM_ADD, &nid ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void RemoveTrayIcon (HWND hWnd) |
|
|
|
|
static void RemoveTrayIcon (HWND hWnd) |
|
|
|
|
{ |
|
|
|
|
NOTIFYICONDATA nid; |
|
|
|
|
nid.hWnd = hWnd; |
|
|
|
@ -106,15 +110,15 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
@@ -106,15 +110,15 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|
|
|
|
return DefWindowProc( hWnd, uMsg, wParam, lParam); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE prev, LPSTR cmdline, int show) |
|
|
|
|
bool StartWin32App () |
|
|
|
|
{ |
|
|
|
|
// check if tunning already
|
|
|
|
|
if (FindWindow (I2PD_WIN32_CLASSNAME, TEXT("i2pd"))) |
|
|
|
|
{ |
|
|
|
|
MessageBox(NULL, TEXT("I2Pd is running already"), TEXT("Warning"), MB_OK); |
|
|
|
|
return 0; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// register main window
|
|
|
|
|
auto hInst = GetModuleHandle(NULL); |
|
|
|
|
WNDCLASSEX wclx; |
|
|
|
|
memset (&wclx, 0, sizeof(wclx)); |
|
|
|
|
wclx.cbSize = sizeof(wclx); |
|
|
|
@ -134,24 +138,25 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
@@ -134,24 +138,25 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|
|
|
|
if (!CreateWindow(I2PD_WIN32_CLASSNAME, TEXT("i2pd"), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 250, 150, NULL, NULL, hInst, NULL)) |
|
|
|
|
{ |
|
|
|
|
MessageBox(NULL, "Failed to create main window", TEXT("Warning!"), MB_ICONERROR | MB_OK | MB_TOPMOST); |
|
|
|
|
return 1; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* // init
|
|
|
|
|
char * argv[] = { (char *)"i2pd" }; |
|
|
|
|
Daemon.init(sizeof (argv)/sizeof (argv[0]), argv); |
|
|
|
|
// start
|
|
|
|
|
Daemon.start ();*/ |
|
|
|
|
// main loop
|
|
|
|
|
int RunWin32App () |
|
|
|
|
{ |
|
|
|
|
MSG msg; |
|
|
|
|
while (GetMessage (&msg, NULL, 0, 0 )) |
|
|
|
|
{ |
|
|
|
|
TranslateMessage (&msg); |
|
|
|
|
DispatchMessage (&msg); |
|
|
|
|
} |
|
|
|
|
/* // atop
|
|
|
|
|
Daemon.stop ();*/ |
|
|
|
|
// terminate
|
|
|
|
|
UnregisterClass (I2PD_WIN32_CLASSNAME, hInst); |
|
|
|
|
return msg.wParam; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void StopWin32App () |
|
|
|
|
{ |
|
|
|
|
UnregisterClass (I2PD_WIN32_CLASSNAME, GetModuleHandle(NULL)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|