OSDN Git Service

Update CWindowsManagerDialog - check some pointers for null and made … (#824) (2)
[winmerge-jp/winmerge-jp.git] / Src / StdAfx.h
1 // stdafx.h : include file for standard system include files,
2 //  or project specific include files that are used frequently, but
3 //      are changed infrequently
4 //
5 /**
6  * @file  Src/StdAfx.h
7  *
8  * @brief Project-wide includes and declarations
9  */
10 #pragma once
11
12 #if defined _M_IX86
13 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
14 #elif defined _M_IA64
15 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
16 #elif defined _M_X64
17 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
18 #else
19 #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
20 #endif
21
22 // On Win XP, with VS2008, do not use default WINVER 0x0600 because of 
23 // some windows structure used in API (on VISTA they are longer)
24 #if !defined(WINVER)
25 #  define WINVER 0x0501
26 #endif /* !defined(WINVER) */
27
28 #define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
29
30 // Common MFC headers
31
32 #include <afxwin.h>         // MFC core and standard components
33 #include <afxext.h>         // MFC extensions
34 #include <afxcmn.h>         // MFC support for Windows Common Controls
35
36 #include <afxtempl.h>       // MFC C++ template collection classes
37 #include <afxpriv.h>        // MFC private declarations (crystal text needs but doesn't include this)
38 #include <afxole.h>         // MFC OLE (COM) support
39
40 #include <atlimage.h>
41
42 // For CSizingControlBar
43 #include "sizecbar.h"
44 #include "scbarg.h"
45
46 #include <string>
47 #include <vector>
48 #include <map>
49 #include <unordered_set>
50 #include <stack>
51 #include <list>
52 #include <array>
53 #include <algorithm>
54 #include <iostream>
55 #include <sstream>
56 #include <memory>
57 #include <functional>
58 #include <cassert>
59 #include <ctime>
60
61 /**
62  * @name User-defined Windows-messages
63  */
64 /* @{ */
65 /// Directory compare thread asks UI (view) update
66 const UINT MSG_UI_UPDATE = WM_USER + 1;
67 /// Request to save panesizes
68 const UINT MSG_STORE_PANESIZES = WM_USER + 2;
69 /// Request to generate file compare report
70 const UINT MSG_GENERATE_FLIE_COMPARE_REPORT = WM_USER + 3;
71 /* @} */
72
73 /// Seconds ignored in filetime differences if option enabled
74 static const UINT SmallTimeDiff = 2;
75
76 #include "UnicodeString.h"
77 #include "MergeApp.h"
78
79         /** @brief Wrapper around CMergeApp::TranslateDialog() */
80 void NTAPI LangTranslateDialog(HWND);
81
82         /** @brief Lang aware version of AfxMessageBox() */
83 int NTAPI LangMessageBox(UINT, UINT nType = MB_OK, UINT nIDHelp = (UINT)-1);
84
85         /** @brief include for the custom dialog boxes, with do not ask/display again */
86 #include "MessageBoxDialog.h"
87
88 #ifdef _MAX_PATH
89 #  undef _MAX_PATH
90 #endif
91 #define _MAX_PATH (260 * sizeof(wchar_t) / sizeof(TCHAR))
92
93 #ifdef MAX_PATH
94 #  undef MAX_PATH
95 #endif
96 #define MAX_PATH (260 * sizeof(wchar_t) / sizeof(TCHAR))
97
98 #ifdef MAX_PATH_FULL
99 #  undef MAX_PATH_FULL
100 #endif
101 #define MAX_PATH_FULL (32767 * sizeof(wchar_t) / sizeof(TCHAR))
102
103 #define WMPROFILE(x) CWinMergeProfile __wmtl__(x)
104
105 class CWinMergeProfile
106 {
107 private:
108         static int level;
109         static CMapStringToPtr map;
110         static LARGE_INTEGER origin;
111         LARGE_INTEGER li[2];
112         LARGE_INTEGER freq;
113         TCHAR funcname[256];
114 public:
115         explicit CWinMergeProfile(LPCTSTR pFuncName) {
116                 TCHAR buf[256];
117                 _stprintf_s(buf, _T("%-*s funcname=%s Start\n"), level, L"", pFuncName);
118                 OutputDebugString(buf);
119                 lstrcpy(funcname, pFuncName);
120                 QueryPerformanceFrequency(&freq);
121                 QueryPerformanceCounter(&li[0]);
122                 if (origin.QuadPart == 0)
123                         origin = li[0];
124                 ++level;
125         }
126         ~CWinMergeProfile() {
127                 QueryPerformanceCounter(&li[1]);
128                 TCHAR buf[256];
129                 level--;
130                 int elapsed = (int)((double)(li[1].QuadPart - li[0].QuadPart) / freq.QuadPart*1000.0*1000.0);
131                 int tim = (int)((double)(li[1].QuadPart - origin.QuadPart) / freq.QuadPart*1000.0*1000.0);
132                 struct stat {
133                         int sum = 0;
134                         int count = 0;
135                 } *pstat;
136                 void *pstatv = nullptr;
137                 if (!map.Lookup(funcname, pstatv))
138                 {
139                         pstat = new stat();
140                         map[funcname] = (void *)pstat;
141                 }
142                 else
143                 {
144                         pstat = reinterpret_cast<stat *>(pstatv);
145                 }
146                 pstat->sum += elapsed;
147                 pstat->count++;
148                 _stprintf_s(buf, _T("%-*s funcname=%s t=%d[us] count=%d sum=%d[us] time=%g[ms]\n"), level, L"", funcname, elapsed, pstat->count, pstat->sum, tim/1000.0);
149                 OutputDebugString(buf);
150         }
151         static void ResetTimer()
152         {
153                 QueryPerformanceCounter(&origin);
154         }
155         static void Terminiate()
156         {
157                 map.RemoveAll();
158         }
159 };