1 // TortoiseIDiff - an image diff viewer in TortoiseSVN and TortoiseGit
3 // Copyright (C) 2006 - 2007, 2010-2012 - 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.
20 #include "mainWindow.h"
21 #include "CmdLineParser.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='*'\"")
30 HINSTANCE hInst
; // current instance
31 HINSTANCE hResource
; // the resource dll
35 int APIENTRY
_tWinMain(HINSTANCE hInstance
,
36 HINSTANCE
/*hPrevInstance*/,
42 CRegStdDWORD loc
= CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
46 hResource
= langDLL
.Init(_T("TortoiseIDiff"), langId
);
47 if (hResource
== NULL
)
48 hResource
= hInstance
;
50 CCmdLineParser
parser(lpCmdLine
);
52 if (parser
.HasKey(_T("?")) || parser
.HasKey(_T("help")))
55 LoadString(hResource
, IDS_COMMANDLINEHELP
, buf
, _countof(buf
));
56 MessageBox(NULL
, buf
, _T("TortoiseIDiff"), MB_ICONINFORMATION
);
67 INITCOMMONCONTROLSEX used
= {
68 sizeof(INITCOMMONCONTROLSEX
),
69 ICC_STANDARD_CLASSES
| ICC_BAR_CLASSES
| ICC_WIN95_CLASSES
71 InitCommonControlsEx(&used
);
73 // load the cursors we need
74 curHand
= (HCURSOR
)LoadImage(hInst
, MAKEINTRESOURCE(IDC_PANCUR
), IMAGE_CURSOR
, 0, 0, LR_DEFAULTSIZE
);
75 curHandDown
= (HCURSOR
)LoadImage(hInst
, MAKEINTRESOURCE(IDC_PANDOWNCUR
), IMAGE_CURSOR
, 0, 0, LR_DEFAULTSIZE
);
77 std::unique_ptr
<CMainWindow
> mainWindow(new CMainWindow(hResource
));
78 mainWindow
->SetRegistryPath(_T("Software\\TortoiseGit\\TortoiseIDiffWindowPos"));
79 std::wstring leftfile
= parser
.HasVal(_T("left")) ? parser
.GetVal(_T("left")) : _T("");
80 if ((leftfile
.empty()) && (lpCmdLine
[0] != 0))
84 mainWindow
->SetLeft(leftfile
.c_str(), parser
.HasVal(_T("lefttitle")) ? parser
.GetVal(_T("lefttitle")) : _T(""));
85 mainWindow
->SetRight(parser
.HasVal(_T("right")) ? parser
.GetVal(_T("right")) : _T(""), parser
.HasVal(_T("righttitle")) ? parser
.GetVal(_T("righttitle")) : _T(""));
86 if (mainWindow
->RegisterAndCreateWindow())
88 hAccelTable
= LoadAccelerators(hResource
, MAKEINTRESOURCE(IDR_TORTOISEIDIFF
));
89 if (!parser
.HasVal(_T("left")))
91 PostMessage(*mainWindow
, WM_COMMAND
, ID_FILE_OPEN
, 0);
93 if (parser
.HasKey(_T("overlay")))
95 PostMessage(*mainWindow
, WM_COMMAND
, ID_VIEW_OVERLAPIMAGES
, 0);
97 if (parser
.HasKey(_T("fit")))
99 PostMessage(*mainWindow
, WM_COMMAND
, ID_VIEW_FITTOGETHER
, 0);
101 if (parser
.HasKey(_T("showinfo")))
103 PostMessage(*mainWindow
, WM_COMMAND
, ID_VIEW_IMAGEINFO
, 0);
105 // Main message loop:
106 while (GetMessage(&msg
, NULL
, 0, 0))
108 if (!TranslateAccelerator(*mainWindow
, hAccelTable
, &msg
))
110 TranslateMessage(&msg
);
111 DispatchMessage(&msg
);
114 return (int) msg
.wParam
;
117 DestroyCursor(curHand
);
118 DestroyCursor(curHandDown
);