-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImgVw.h
75 lines (60 loc) · 1.79 KB
/
ImgVw.h
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
#pragma once
#include "ImgVwWindow.h"
#include "resource.h"
#include <Windows.h>
#include <shellapi.h>
#define LOGIMGVW 0
#if _DEBUG && LOGIMGVW
#define LOGIMGVWPATH L"C:\\Temp\\ImgVw_"
#include "DebugHelper.h"
#endif
class ImgVw
{
public:
static INT Run(HINSTANCE hInstance, INT nShowCmd);
private:
ImgVw() { }
};
inline INT ImgVw::Run(HINSTANCE hInstance, INT nShowCmd)
{
INT argscount;
const auto args = CommandLineToArgvW(GetCommandLine(), &argscount);
std::vector<std::wstring> argsvector;
for (INT i = 0; i < argscount; ++i)
{
argsvector.push_back(args[i]);
}
LocalFree(args);
#if _DEBUG && LOGIMGVW
TimestampLogger logger(LOGIMGVWPATH + TimestampLogger::GetTimestampString(TRUE) + L".log", TRUE);
#endif
if (SUCCEEDED(CoInitialize(NULL)))
{
InitCommonControls();
const Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
const auto imgvwwindow = ImgVwWindow::Create(hInstance, argsvector);
if (imgvwwindow != nullptr)
{
ShowWindow(imgvwwindow->hwnd(), nShowCmd);
const auto hacc = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_IMGVW));
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
#if _DEBUG && LOGIMGVW
logger.WriteLine(DebugHelper::FormatWindowMessage(msg));
#endif
if (!TranslateAccelerator(imgvwwindow->hwnd(), hacc, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
DestroyAcceleratorTable(hacc);
}
Gdiplus::GdiplusShutdown(gdiplusToken);
CoUninitialize();
}
return 0;
}