Solution46
CMonitor.h
[詳解]
1 //=============================================================================
2 /// @file
3 /// モニタクラスヘッダファイル
4 ///
5 /// モニタクラスヘッダファイルです。
6 ///
7 /// $Id: CMonitor.h 245 2019-03-20 15:03:41Z admin $
8 /// $Date: 2019-03-21 00:03:41 +0900 (2019/03/21 (木)) $
9 /// $Author: admin $
10 ///
11 /// @attention なし
12 
13 #pragma once
14 #pragma managed( push, off )
15 
16 //=============================================================================
17 // インクルードファイル
18 #include <LibCommonDef.h>
19 
20 //=============================================================================
21 // マクロ定義
22 #define MonitorInstance() LibCommon::CMonitor::GetInstance() ///< インスタンス取得マクロ
23 #define MonitorCount() MonitorInstance().Count() ///< モニタ数取得マクロ
24 #define MonitorSize(...) MonitorInstance().GetSize(__VA_ARGS__) ///< モニタサイズ取得マクロ
25 #define MonitorWorkSize(...) MonitorInstance().GetWorkSize(__VA_ARGS__) ///< モニタ作業領域サイズ取得マクロ
26 
27 //=============================================================================
28 // 共通ライブラリ名前空間
29 namespace LibCommon {
30  //=========================================================================
31  /// モニタクラス
32  ///
33  /// モニタクラスです。
34  ///
35  /// @attention シングルトンクラスです。
36  ///
37  class LIB_COMMON_API CMonitor final {
38  //=====================================================================
39  // 構築子と解体子
40  protected:
41  //---------------------------------------------------------------------
42  /// コンストラクタ
43  ///
44  /// コンストラクタです。
45  ///
46  /// @param なし
47  /// @return なし
48  /// @attention なし
49  ///
50  explicit CMonitor() noexcept;
51 
52  //---------------------------------------------------------------------
53  /// デストラクタ
54  ///
55  /// デストラクタです。
56  ///
57  /// @param なし
58  /// @return なし
59  /// @attention なし
60  ///
61  virtual ~CMonitor() noexcept;
62 
63  //=====================================================================
64  // 公開関数
65  public:
66  //---------------------------------------------------------------------
67  /// モニタサイズ取得関数
68  ///
69  /// モニタサイズ取得関数です。
70  ///
71  /// @param[in] nIndex モニタ番号
72  /// @param[out] nWidth 水平サイズ参照
73  /// @param[out] nHeight 垂直サイズ参照
74  /// @return 実行結果
75  /// - true 成功
76  /// - false 失敗
77  /// @attention なし
78  ///
79  virtual bool GetSize( int nIndex, int& nWidth, int& nHeight ) const noexcept;
80 
81  //---------------------------------------------------------------------
82  /// モニタ作業領域サイズ取得関数
83  ///
84  /// モニタ作業領域サイズ取得関数です。
85  ///
86  /// @param[in] nIndex モニタ番号
87  /// @param[out] nWidth 水平サイズ参照
88  /// @param[out] nHeight 垂直サイズ参照
89  /// @return 実行結果
90  /// - true 成功
91  /// - false 失敗
92  /// @attention なし
93  ///
94  virtual bool GetWorkSize( int nIndex, int& nWidth, int& nHeight ) const noexcept;
95 
96  //=====================================================================
97  // インライン静的公開関数
98  public:
99  //---------------------------------------------------------------------
100  /// インスタンス取得関数
101  ///
102  /// インスタンス取得関数です。
103  ///
104  /// @param なし
105  /// @return インスタンス参照
106  /// @attention なし
107  ///
108  inline static CMonitor& GetInstance() noexcept { return s_cInstance; }
109 
110  //=====================================================================
111  // 静的限定公開関数
112  protected:
113  //---------------------------------------------------------------------
114  /// モニタ列挙コールバック関数
115  ///
116  /// モニタ列挙コールバック関数です。
117  ///
118  /// @param[in] hMonitor ディスプレイモニタのハンドル
119  /// @param[in] hdcMonitor モニタに適したデバイスコンテキストのハンドル
120  /// @param[in] lprcMonitor モニタ上の交差部分を表す長方形領域へのポインタ
121  /// @param[in] dwData EnumDisplayMonitors から渡されたデータ
122  /// @return 実行結果
123  /// - TRUE 継続する
124  /// - FALSE 中止する
125  /// @attention なし
126  ///
127  static BOOL CALLBACK MonitorEnumProc( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData ) noexcept;
128 
129  //=====================================================================
130  // 静的限定公開定数
131  protected:
132  static int const MONITOR_MAX = 256; ///< 最大モニタ数
133 
134  //=====================================================================
135  // 限定公開変数
136  protected:
137  int m_nCount; ///< モニタカウント
138  HMONITOR m_hMonitor[ MONITOR_MAX ]; ///< モニタハンドル配列
139 
140  //=====================================================================
141  // 静的限定公開変数
142  protected:
143  static CMonitor s_cInstance; ///< 静的インスタンス
144 
145  //=====================================================================
146  // 削除関数
147  private:
148  CMonitor( CMonitor const& ) = delete;
149  CMonitor& operator=( CMonitor const& ) = delete;
150  };
151 }
152 
153 #pragma managed( pop )
static CMonitor & GetInstance() noexcept
インスタンス取得関数
Definition: CMonitor.h:108
static CMonitor s_cInstance
静的インスタンス
Definition: CMonitor.h:143
共通ライブラリ定義ヘッダファイル
共通ライブラリ名前空間
Definition: CArray.h:23
モニタクラス
Definition: CMonitor.h:37
#define LIB_COMMON_API
ダイナミックライブラリインポート宣言
Definition: LibCommonDef.h:44
int m_nCount
モニタカウント
Definition: CMonitor.h:137