Menu

[r32]: / trunk / src / CommitMonitor.cpp  Maximize  Restore  History

Download this file

107 lines (81 with data), 2.7 kB

  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
// CommitMonitor.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "CommitMonitor.h"
#include "HiddenWindow.h"
#include "MainDlg.h"
#include "apr_general.h"
// Global Variables:
HINSTANCE hInst; // current instance
HANDLE g_mutex = 0;
#define APPNAME_MUTEX _T("CommitMonitor_{3802F59C-BEBD-49b9-A345-F99CBA2FBD0D}")
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
// we need some of the common controls
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LINK_CLASS|ICC_LISTVIEW_CLASSES|ICC_PAGESCROLLER_CLASS
|ICC_PROGRESS_CLASS|ICC_STANDARD_CLASSES|ICC_TAB_CLASSES|ICC_TREEVIEW_CLASSES
|ICC_UPDOWN_CLASS|ICC_USEREX_CLASSES|ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
int argc = 0;
const char* const * argv = NULL;
apr_app_initialize(&argc, &argv, NULL);
setlocale(LC_ALL, "");
// first create a hidden window which serves as our main window for receiving
// the window messages, starts the monitoring thread and handles the icon
// in the tray area.
MSG msg;
HACCEL hAccelTable;
hInst = hInstance;
INITCOMMONCONTROLSEX used = {
sizeof(INITCOMMONCONTROLSEX),
ICC_STANDARD_CLASSES | ICC_BAR_CLASSES
};
InitCommonControlsEx(&used);
//only one instance of this application allowed
g_mutex = ::CreateMutex(NULL, FALSE, APPNAME_MUTEX);
if (g_mutex != NULL)
{
if(::GetLastError()==ERROR_ALREADY_EXISTS)
{
//an instance of this app is already running
HWND hWnd = FindWindow(ResString(hInst, IDS_APP_TITLE), NULL); //try finding the running instance of this app
if (hWnd)
{
UINT COMMITMONITOR_SHOWDLGMSG = RegisterWindowMessage(_T("CommitMonitor_ShowDlgMsg"));
PostMessage(hWnd, COMMITMONITOR_SHOWDLGMSG ,0 ,0); //open the window of the already running app
SetForegroundWindow(hWnd); //set the window to front
}
apr_terminate();
return FALSE;
}
}
CHiddenWindow hiddenWindow(hInst);
if (hiddenWindow.RegisterAndCreateWindow())
{
hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_COMMITMONITOR));
if (true) // for now, start the dialog every time
{
hiddenWindow.ShowDialog();
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(hiddenWindow, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
apr_terminate();
return (int) 0;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.