mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
initial commit of Win32App
This commit is contained in:
parent
a5576ddbf3
commit
6383fc3575
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ else ifeq ($(UNAME),Linux)
|
||||||
DAEMON_SRC += DaemonLinux.cpp
|
DAEMON_SRC += DaemonLinux.cpp
|
||||||
include Makefile.linux
|
include Makefile.linux
|
||||||
else # win32 mingw
|
else # win32 mingw
|
||||||
DAEMON_SRC += DaemonWin32.cpp Win32/Win32Service.cpp
|
DAEMON_SRC += DaemonWin32.cpp Win32/Win32Service.cpp Win32/Win32App.cpp
|
||||||
WINDIR := True
|
WINDIR := True
|
||||||
include Makefile.mingw
|
include Makefile.mingw
|
||||||
endif
|
endif
|
||||||
|
|
56
Win32/Win32App.cpp
Normal file
56
Win32/Win32App.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#include <string.h>
|
||||||
|
#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;
|
||||||
|
}
|
8
Win32/Win32App.h
Normal file
8
Win32/Win32App.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef WIN32APP_H__
|
||||||
|
#define WIN32APP_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define I2PD_WIN32_CLASSNAME "i2pd main window"
|
||||||
|
|
||||||
|
#endif // WIN32APP_H__
|
Loading…
Reference in a new issue