Solution46
LibCommon::CMonitor クラスfinal

モニタクラス [詳解]

#include "CMonitor.h"

LibCommon::CMonitor 連携図
Collaboration graph

公開メンバ関数

virtual bool GetSize (int nIndex, int &nWidth, int &nHeight) const noexcept
 モニタサイズ取得関数 [詳解]
 
virtual bool GetWorkSize (int nIndex, int &nWidth, int &nHeight) const noexcept
 モニタ作業領域サイズ取得関数 [詳解]
 

静的公開メンバ関数

static CMonitorGetInstance () noexcept
 インスタンス取得関数 [詳解]
 

限定公開メンバ関数

 CMonitor () noexcept
 コンストラクタ [詳解]
 
virtual ~CMonitor () noexcept
 デストラクタ [詳解]
 

静的限定公開メンバ関数

static BOOL CALLBACK MonitorEnumProc (HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) noexcept
 モニタ列挙コールバック関数 [詳解]
 

限定公開変数類

int m_nCount
 モニタカウント [詳解]
 
HMONITOR m_hMonitor [MONITOR_MAX]
 モニタハンドル配列 [詳解]
 

静的限定公開変数類

static int const MONITOR_MAX = 256
 最大モニタ数 [詳解]
 
static CMonitor s_cInstance
 静的インスタンス [詳解]
 

非公開メンバ関数

 CMonitor (CMonitor const &)=delete
 
CMonitoroperator= (CMonitor const &)=delete
 

詳解

モニタクラス

モニタクラスです。

注意
シングルトンクラスです。

CMonitor.h37 行目に定義があります。

構築子と解体子

LibCommon::CMonitor::CMonitor ( )
explicitprotectednoexcept

コンストラクタ

コンストラクタです。

引数
なし
戻り値
なし
注意
なし

CMonitor.cpp29 行目に定義があります。

参照先 MonitorEnumProc(), NotifyConstructor.

31  : m_nCount( 0 )
32  , m_hMonitor()
33  {
34  // コンストラクタ実行通知
36 
37  // 処理ブロック
38  do {
39  // モニタハンドルリストを取得する
40  ::EnumDisplayMonitors( nullptr, nullptr, MonitorEnumProc, reinterpret_cast< LPARAM >( this ) );
41  } while ( false );
42  }
#define NotifyConstructor()
コンストラクタ実行通知マクロ
Definition: LibUtility.h:24
static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) noexcept
モニタ列挙コールバック関数
Definition: CMonitor.cpp:119
HMONITOR m_hMonitor[MONITOR_MAX]
モニタハンドル配列
Definition: CMonitor.h:138
int m_nCount
モニタカウント
Definition: CMonitor.h:137

呼び出し関係図:

LibCommon::CMonitor::~CMonitor ( )
protectedvirtualnoexcept

デストラクタ

デストラクタです。

引数
なし
戻り値
なし
注意
なし

CMonitor.cpp46 行目に定義があります。

参照先 NotifyDestructor.

46  {
47  // デストラクタ実行通知
49  }
#define NotifyDestructor()
デストラクタ実行通知マクロ
Definition: LibUtility.h:25
LibCommon::CMonitor::CMonitor ( CMonitor const &  )
privatedelete

関数詳解

bool LibCommon::CMonitor::GetSize ( int  nIndex,
int &  nWidth,
int &  nHeight 
) const
virtualnoexcept

モニタサイズ取得関数

モニタサイズ取得関数です。

引数
[in]nIndexモニタ番号
[out]nWidth水平サイズ参照
[out]nHeight垂直サイズ参照
戻り値
実行結果
  • true 成功
  • false 失敗
注意
なし

CMonitor.cpp55 行目に定義があります。

参照先 m_hMonitor, m_nCount.

55  {
56  // 処理ブロック
57  bool result = false;
58  do {
59  // インデックスを調べる
60  if ( m_nCount <= nIndex ) {
61  // 失敗!
62  break;
63  }
64 
65  // モニタ情報を取得する
66  MONITORINFO sMonitorInfo = { sizeof( MONITORINFO ) };
67  if ( 0 == ::GetMonitorInfoW( m_hMonitor[ nIndex ], &sMonitorInfo ) ) {
68  // 失敗!
69  break;
70  }
71 
72  // モニタサイズを取得する
73  nWidth = ( sMonitorInfo.rcMonitor.right - sMonitorInfo.rcMonitor.left );
74  nHeight = ( sMonitorInfo.rcMonitor.bottom - sMonitorInfo.rcMonitor.top );
75 
76  // 成功!
77  result = true;
78  } while ( false );
79 
80  // 実行結果を返す
81  return result;
82  }
HMONITOR m_hMonitor[MONITOR_MAX]
モニタハンドル配列
Definition: CMonitor.h:138
int m_nCount
モニタカウント
Definition: CMonitor.h:137
bool LibCommon::CMonitor::GetWorkSize ( int  nIndex,
int &  nWidth,
int &  nHeight 
) const
virtualnoexcept

モニタ作業領域サイズ取得関数

モニタ作業領域サイズ取得関数です。

引数
[in]nIndexモニタ番号
[out]nWidth水平サイズ参照
[out]nHeight垂直サイズ参照
戻り値
実行結果
  • true 成功
  • false 失敗
注意
なし

CMonitor.cpp86 行目に定義があります。

参照先 m_hMonitor, m_nCount.

86  {
87  // 処理ブロック
88  bool result = false;
89  do {
90  // インデックスを調べる
91  if ( m_nCount <= nIndex ) {
92  // 失敗!
93  break;
94  }
95 
96  // モニタ情報を取得する
97  MONITORINFO sMonitorInfo = { sizeof( MONITORINFO ) };
98  if ( 0 == ::GetMonitorInfoW( m_hMonitor[ nIndex ], &sMonitorInfo ) ) {
99  // 失敗!
100  break;
101  }
102 
103  // 作業領域サイズを取得する
104  nWidth = ( sMonitorInfo.rcWork.right - sMonitorInfo.rcWork.left );
105  nHeight = ( sMonitorInfo.rcWork.bottom - sMonitorInfo.rcWork.top );
106 
107  // 成功!
108  result = true;
109  } while ( false );
110 
111  // 実行結果を返す
112  return result;
113  }
HMONITOR m_hMonitor[MONITOR_MAX]
モニタハンドル配列
Definition: CMonitor.h:138
int m_nCount
モニタカウント
Definition: CMonitor.h:137
static CMonitor& LibCommon::CMonitor::GetInstance ( )
inlinestaticnoexcept

インスタンス取得関数

インスタンス取得関数です。

引数
なし
戻り値
インスタンス参照
注意
なし

CMonitor.h108 行目に定義があります。

108 { return s_cInstance; }
static CMonitor s_cInstance
静的インスタンス
Definition: CMonitor.h:143
BOOL LibCommon::CMonitor::MonitorEnumProc ( HMONITOR  hMonitor,
HDC  hdcMonitor,
LPRECT  lprcMonitor,
LPARAM  dwData 
)
staticprotectednoexcept

モニタ列挙コールバック関数

モニタ列挙コールバック関数です。

引数
[in]hMonitorディスプレイモニタのハンドル
[in]hdcMonitorモニタに適したデバイスコンテキストのハンドル
[in]lprcMonitorモニタ上の交差部分を表す長方形領域へのポインタ
[in]dwDataEnumDisplayMonitors から渡されたデータ
戻り値
実行結果
  • TRUE 継続する
  • FALSE 中止する
注意
なし

CMonitor.cpp119 行目に定義があります。

参照先 m_hMonitor, m_nCount.

参照元 CMonitor().

119  {
120  // 処理ブロック
121  BOOL result = FALSE;
122  do {
123  // インスタンスポインタを取得する
124  CMonitor*& rpcInstance = reinterpret_cast< CMonitor*& >( dwData );
125  if ( nullptr == rpcInstance ) {
126  // 失敗!
127  break;
128  }
129  // モニタカウントを調べる
130  else if ( MONITOR_MAX <= rpcInstance->m_nCount ) {
131  // 失敗!
132  break;
133  }
134 
135  // モニタハンドルを追加する
136  rpcInstance->m_hMonitor[ rpcInstance->m_nCount++ ] = hMonitor;
137 
138  // 成功!
139  result = TRUE;
140  } while ( false );
141 
142  // 実行結果を返す
143  return result;
144  }
CMonitor() noexcept
コンストラクタ
Definition: CMonitor.cpp:29
int m_nCount
モニタカウント
Definition: CMonitor.h:137

被呼び出し関係図:

CMonitor& LibCommon::CMonitor::operator= ( CMonitor const &  )
privatedelete

メンバ詳解

int const LibCommon::CMonitor::MONITOR_MAX = 256
staticprotected

最大モニタ数

CMonitor.h132 行目に定義があります。

int LibCommon::CMonitor::m_nCount
protected

モニタカウント

CMonitor.h137 行目に定義があります。

参照元 GetSize(), GetWorkSize(), MonitorEnumProc().

HMONITOR LibCommon::CMonitor::m_hMonitor[MONITOR_MAX]
protected

モニタハンドル配列

CMonitor.h138 行目に定義があります。

参照元 GetSize(), GetWorkSize(), MonitorEnumProc().

CMonitor LibCommon::CMonitor::s_cInstance
staticprotected

静的インスタンス

CMonitor.h143 行目に定義があります。

参照元 LibCommon::CLibCommon::GetInstanceHandle().


このクラス詳解は次のファイルから抽出されました: