[dasher: 10/43] Win32: Try to clean up headers by RMing WinHelper.h (part of WinCommon.h)



commit ab70ec927f9399de4940e0678390754b24799de4
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Thu Jun 9 19:30:24 2011 +0100

    Win32: Try to clean up headers by RMing WinHelper.h (part of WinCommon.h)

 Src/Win32/Common/DasherEncodingToCP.h |    1 -
 Src/Win32/Common/WinCommon.h          |   59 ++++++++++++++++++++++++++++---
 Src/Win32/Common/WinHelper.cpp        |    2 -
 Src/Win32/Common/WinHelper.h          |   61 ---------------------------------
 Src/Win32/Common/WinUTF8.cpp          |    1 -
 Src/Win32/Widgets/Panel.h             |    2 +-
 Src/Win32/WinMain.cpp                 |    3 +-
 7 files changed, 55 insertions(+), 74 deletions(-)
---
diff --git a/Src/Win32/Common/DasherEncodingToCP.h b/Src/Win32/Common/DasherEncodingToCP.h
index 39bc766..ba80505 100644
--- a/Src/Win32/Common/DasherEncodingToCP.h
+++ b/Src/Win32/Common/DasherEncodingToCP.h
@@ -10,7 +10,6 @@
 #define __DasherEncodingToCP_h__
 
 #include "../../DasherCore/DasherTypes.h"
-#include "WinHelper.h"
 
 UINT EncodingToCP(Dasher::Opts::AlphabetTypes Encoding);
 
diff --git a/Src/Win32/Common/WinCommon.h b/Src/Win32/Common/WinCommon.h
index 2b53865..94de0ba 100644
--- a/Src/Win32/Common/WinCommon.h
+++ b/Src/Win32/Common/WinCommon.h
@@ -1,4 +1,4 @@
-// Common.h
+// WinCommon.h
 //
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -9,7 +9,7 @@
 #ifndef __WinCommon_h__
 #define __WinCommon_h__
 
-#pragma message("Compiling WinCommon.h.........................")
+//#pragma message("Compiling WinCommon.h.........................")
 
 #define NOMINMAX
 #define WIN32_LEAN_AND_MEAN     // Excludes rarely-used stuff from the Windows headers
@@ -25,26 +25,73 @@
 #include <limits>
 
 // Use common controls
+/*
+  ACL: Used to have separate header file WinHelper.h in addition to this, which
+  wrapped the #include  of commctrl.h with the following "#ifdef OriginalWin95"
+  sections. I'm including them here in case they are needed, along with comment:
+
+  Initialise Common Controls library. If we want this to work with Windows 95
+  with no extra dll's or versions of IE installed, we define OriginalWin95 and
+  play games with macros. Having said that, almost all Windows systems should
+  have the required DLL for new common control features (either with the system
+  or with IE). If not it is an easy upgrade from:
+    http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
+
+  IAM 08/2002
+*/
+#ifdef OriginalWin95
+#define _WIN32_IE_TMP _WIN32_IE
+#undef _WIN32_IE
+#define _WIN32_IE 0x0100
+#endif
+
 #include <commctrl.h>
+//ACL and also the following...
+#ifdef OriginalWin95
+#undef _WIN32_IE
+#define _WIN32_IE _WIN32_IE_TMP
+#undef _WIN32_IE_TMP
+#endif
+
+#ifdef OriginalWin95
+#undef CP_UTF8                  // as we can't use it
+#endif
+//ACL end moved from WinHelper.h
 
 #include "../../Common/Common.h"
 
 // windows.h provides the "generic" character type TCHAR.
-#include "tchar.h"              // this adds some useful macros
+//ACL apparently TCHAR is "wchar_t" (=16bit) if unicode is enabled, else "char".
+//We seem to use it interchangeably with wchar, so presumably will only compile
+// with unicode!
+
+//There is no "tchar.h", so commenting out:
+// #include "tchar.h"              // this adds some useful macros
+//...there _is_ a <tchar.h>, but if we don't need it...?
 
 // Sometimes it is much easier to use strings, for which we have Tstring.
 #include <string>
+//ACL given unicode, this defines Tstring as equivalent to std::wstring...
 typedef std::basic_string < TCHAR > Tstring;
 
 #include "../../Common/NoClones.h"
 
 #include "WinUTF8.h"
-#include "WinHelper.h"
+
+// Some global helpers. In all my applications there is just one instance,
+// or one important one, and WinHelper::hInstApp saves passing it around endlessly
+namespace WinHelper {
+  extern HINSTANCE hInstApp;
+  void LastWindowsError();
+  void InitCommonControlLib();
+  void GetUserDirectory(Tstring * Output);      // Both thof these will always
+  void GetAppDirectory(Tstring * Output);       // return a trailing "\"
+}
+
 #include "WinLocalisation.h"
 
 #if DASHER_WIN32 <= 1300
 namespace stdext = std;
 #endif
 
-
-#endif /* #ifndef __WinHelper_h__ */
+#endif /* #ifndef __WinCommon_h__ */
diff --git a/Src/Win32/Common/WinHelper.cpp b/Src/Win32/Common/WinHelper.cpp
index 9fe29ce..da03360 100644
--- a/Src/Win32/Common/WinHelper.cpp
+++ b/Src/Win32/Common/WinHelper.cpp
@@ -8,8 +8,6 @@
 
 #include "WinCommon.h"
 
-#include "WinHelper.h"
-
 // Track memory leaks on Windows to the line that new'd the memory
 #ifdef _WIN32
 #ifdef _DEBUG
diff --git a/Src/Win32/Common/WinUTF8.cpp b/Src/Win32/Common/WinUTF8.cpp
index b8fda14..597ac78 100644
--- a/Src/Win32/Common/WinUTF8.cpp
+++ b/Src/Win32/Common/WinUTF8.cpp
@@ -9,7 +9,6 @@
 #include "WinCommon.h"
 
 #include "WinUTF8.h"
-#include "WinHelper.h"
 
 // Track memory leaks on Windows to the line that new'd the memory
 #ifdef _WIN32
diff --git a/Src/Win32/Widgets/Panel.h b/Src/Win32/Widgets/Panel.h
index 2fcca9f..e43b14a 100644
--- a/Src/Win32/Widgets/Panel.h
+++ b/Src/Win32/Widgets/Panel.h
@@ -1,4 +1,4 @@
-#include "../WinHelper.h"
+#include <windows.h>
 
 class Panel {
 public:
diff --git a/Src/Win32/WinMain.cpp b/Src/Win32/WinMain.cpp
index 20a6ed1..72fefb4 100644
--- a/Src/Win32/WinMain.cpp
+++ b/Src/Win32/WinMain.cpp
@@ -13,7 +13,6 @@
 // #include "vld/vld.h"
 // #endif 
 
-#include "Common/WinHelper.h"
 #include "DasherWindow.h"
 
 #include <commctrl.h>
@@ -89,4 +88,4 @@ VOID CALLBACK WEProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG i
   if(g_pDasherWindow)
     g_pDasherWindow->HandleWinEvent(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime);
 }
-#endif
\ No newline at end of file
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]