diff --git a/Makefile b/Makefile index 09cf2ace..9bfae351 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ else ifeq ($(UNAME),Linux) DAEMON_SRC += DaemonLinux.cpp include Makefile.linux else # win32 mingw - DAEMON_SRC += DaemonWin32.cpp Win32/Win32Service.cpp + DAEMON_SRC += DaemonWin32.cpp Win32/Win32Service.cpp Win32/Win32App.cpp WINDIR := True include Makefile.mingw endif diff --git a/Win32/Win32App.cpp b/Win32/Win32App.cpp new file mode 100644 index 00000000..42d7bef8 --- /dev/null +++ b/Win32/Win32App.cpp @@ -0,0 +1,56 @@ +#include +#include "Win32App.h" + + +static LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + } + return DefWindowProc( hWnd, uMsg, wParam, lParam); +} + + int WINAPI WinMain (HINSTANCE hInst, HINSTANCE prev, LPSTR cmdline, int show) + { + // check if tunning already + if (FindWindow (I2PD_WIN32_CLASSNAME, TEXT("Title"))) + { + MessageBox(NULL, TEXT("I2Pd is running already"), TEXT("Warning"), MB_OK); + return 0; + } + // register main window + WNDCLASSEX wclx; + memset (&wclx, 0, sizeof(wclx)); + wclx.cbSize = sizeof(wclx); + wclx.style = 0; + wclx.lpfnWndProc = &WndProc; + wclx.cbClsExtra = 0; + wclx.cbWndExtra = 0; + wclx.hInstance = hInst; + //wclx.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_TRAYICON ) ); + //wclx.hIconSm = LoadSmallIcon( hInstance, IDI_TRAYICON ); + wclx.hCursor = LoadCursor (NULL, IDC_ARROW); + wclx.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wclx.lpszMenuName = NULL; + wclx.lpszClassName = I2PD_WIN32_CLASSNAME; + RegisterClassEx (&wclx); + // create new window + if (!CreateWindow(I2PD_WIN32_CLASSNAME, TEXT("Title"), 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; + } + + // start + // main loop + MSG msg; + while (GetMessage (&msg, NULL, 0, 0 )) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + // atop + // terminate + UnregisterClass (I2PD_WIN32_CLASSNAME, hInst); + return msg.wParam; + } diff --git a/Win32/Win32App.h b/Win32/Win32App.h new file mode 100644 index 00000000..e7c384a9 --- /dev/null +++ b/Win32/Win32App.h @@ -0,0 +1,8 @@ +#ifndef WIN32APP_H__ +#define WIN32APP_H__ + +#include + +#define I2PD_WIN32_CLASSNAME "i2pd main window" + +#endif // WIN32APP_H__