Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cWinApp.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_CWinApp_H
6 #define _INC_CWinApp_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "cWinResource.h"
12 #include "../System/cAppRes.h"
13 #include "../System/cAppConfig.h"
14 #include "../Scriptable/IScriptableObj.h"
16 
17 namespace GrayLib
18 {
20  {
24 
25  public:
26  virtual void ProcessMessage(MSG& msg);
27  HRESULT ProcessMessages(TIMESYSD_t tMax = 10);
28 
29  static cWinMessagePump* GRAYCALL get_MessagePump(); // Get main message pump.
30  };
31 
32 #if ! defined(_MFC_VER)
33  class cWndHandle;
34 
36  : public cAppImpl // cSingletonStatic
37  , public cWinResMod
38  , public cAppConfigX
39  , public cWinMessagePump
40  {
47 
48  typedef cAppImpl SUPER_t;
49 
50  public:
52 
53  // Passed into cAppConfigX
55 
56 #ifdef _WIN32
57  const FILECHAR_t* m_pszRegistryKey;
58  cWndHandle* m_pMainWnd;
59  SHOWWINDOW_t m_nCmdShow;
60 #endif
61 
62  public:
63  CWinApp(const FILECHAR_t* pszAppName = nullptr);
64  virtual ~CWinApp();
65 
66  static inline bool isSingleCreated()
67  {
68  if (!SUPER_t::isSingleCreated())
69  return false;
70  return IS_TYPE_OF(CWinApp, SUPER_t::get_Single());
71  }
72  static inline CWinApp* get_Single() // type cast cSingleton
73  {
75  return get_SingleCast<CWinApp>();
76  }
77  static inline CWinApp& I()
78  {
80  return *get_Single();
81  }
82 
83  virtual bool isValidCheck() const noexcept // memory allocation and structure definitions are valid.
84  {
85  // if (!CObject::isValidCheck()) return false;
86  if (!IS_TYPE_OF(CWinApp, this)) // structure definitions are valid..
87  return false;
88  return true;
89  }
90 
91  virtual BOOL InitInstance() override;
92  virtual bool OnTickApp() override;
93 
94  APP_EXITCODE_t Main(HINSTANCE hInstance, SHOWWINDOW_t nCmdShow);
95  };
96 
97 #define AfxGetApp() cSingletonStatic<cAppImpl>::get_SingleCast<CWinApp>() // up-cast the singleton from cSingletonStatic
98 #endif // ! _MFC_VER
99 
100 };
101 #endif // _INC_CWinApp_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IS_TYPE_OF(t, p)
Definition: PtrCast.h:23
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cWinApp.h:40
const FILECHAR_t * m_pszProfileName
the path to the profile specific to this app. (else use m_pszRegistryKey)
Definition: cWinApp.h:54
static CWinApp * get_Single()
Definition: cWinApp.h:72
virtual bool isValidCheck() const noexcept
Definition: cWinApp.h:83
cStringF m_pszHelpFilePath
The path to the application's Help file. (if any) (MFC name)
Definition: cWinApp.h:51
static CWinApp & I()
Definition: cWinApp.h:77
static bool isSingleCreated()
Definition: cWinApp.h:66
Definition: cAppConfig.h:19
Definition: cWinApp.h:20
Definition: cWinResource.h:19
Definition: cWndHandle.h:26
Definition: cAppImpl.h:21
Definition: cMesh.h:22
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22