pulled latest translations from Transifex
[TortoiseGit.git] / src / TortoiseIDiff / TortoiseIDiff.cpp
blob9146494e64a80061777517edb6449a8a276d7924
1 // TortoiseIDiff - an image diff viewer in TortoiseSVN and TortoiseGit
3 // Copyright (C) 2006 - 2007, 2010-2011 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "mainWindow.h"
21 #include "CmdLineParser.h"
22 #include "registry.h"
23 #include "LangDll.h"
24 #include "TortoiseIDiff.h"
25 #include "TaskbarUUID.h"
27 #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
29 // Global Variables:
30 HINSTANCE hInst; // current instance
31 HINSTANCE hResource; // the resource dll
32 HCURSOR curHand;
33 HCURSOR curHandDown;
35 int APIENTRY _tWinMain(HINSTANCE hInstance,
36 HINSTANCE hPrevInstance,
37 LPTSTR lpCmdLine,
38 int nCmdShow)
40 UNREFERENCED_PARAMETER(hPrevInstance);
42 SetDllDirectory(L"");
43 SetTaskIDPerUUID();
44 CRegStdDWORD loc = CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
45 long langId = loc;
47 CLangDll langDLL;
48 hResource = langDLL.Init(_T("TortoiseIDiff"), langId);
49 if (hResource == NULL)
50 hResource = hInstance;
52 CCmdLineParser parser(lpCmdLine);
54 if (parser.HasKey(_T("?")) || parser.HasKey(_T("help")))
56 TCHAR buf[1024];
57 LoadString(hResource, IDS_COMMANDLINEHELP, buf, _countof(buf));
58 MessageBox(NULL, buf, _T("TortoiseIDiff"), MB_ICONINFORMATION);
59 langDLL.Close();
60 return 0;
64 MSG msg;
65 HACCEL hAccelTable;
67 hInst = hInstance;
69 INITCOMMONCONTROLSEX used = {
70 sizeof(INITCOMMONCONTROLSEX),
71 ICC_STANDARD_CLASSES | ICC_BAR_CLASSES | ICC_WIN95_CLASSES
73 InitCommonControlsEx(&used);
75 // load the cursors we need
76 curHand = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
77 curHandDown = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANDOWNCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
79 CMainWindow mainWindow(hResource);
80 mainWindow.SetRegistryPath(_T("Software\\TortoiseGit\\TortoiseIDiffWindowPos"));
81 std::wstring leftfile = parser.HasVal(_T("left")) ? parser.GetVal(_T("left")) : _T("");
82 if ((leftfile.size() == 0)&&(lpCmdLine[0] != 0))
84 leftfile = lpCmdLine;
86 mainWindow.SetLeft(leftfile.c_str(), parser.HasVal(_T("lefttitle")) ? parser.GetVal(_T("lefttitle")) : _T(""));
87 mainWindow.SetRight(parser.HasVal(_T("right")) ? parser.GetVal(_T("right")) : _T(""), parser.HasVal(_T("righttitle")) ? parser.GetVal(_T("righttitle")) : _T(""));
88 if (mainWindow.RegisterAndCreateWindow())
90 hAccelTable = LoadAccelerators(hResource, MAKEINTRESOURCE(IDR_TORTOISEIDIFF));
91 if (!parser.HasVal(_T("left")))
93 PostMessage(mainWindow, WM_COMMAND, ID_FILE_OPEN, 0);
95 if (parser.HasKey(_T("overlay")))
97 PostMessage(mainWindow, WM_COMMAND, ID_VIEW_OVERLAPIMAGES, 0);
99 if (parser.HasKey(_T("fit")))
101 PostMessage(mainWindow, WM_COMMAND, ID_VIEW_FITTOGETHER, 0);
103 if (parser.HasKey(_T("showinfo")))
105 PostMessage(mainWindow, WM_COMMAND, ID_VIEW_IMAGEINFO, 0);
107 // Main message loop:
108 while (GetMessage(&msg, NULL, 0, 0))
110 if (!TranslateAccelerator(mainWindow, hAccelTable, &msg))
112 TranslateMessage(&msg);
113 DispatchMessage(&msg);
116 return (int) msg.wParam;
118 langDLL.Close();
119 DestroyCursor(curHand);
120 DestroyCursor(curHandDown);
121 return 1;