Solution46
CWndList.cpp
[詳解]
1 //=============================================================================
2 /// @file
3 /// ウィンドウリストクラス実装ファイル
4 ///
5 /// ウィンドウリストクラス実装ファイルです。
6 ///
7 /// $Id: CWndList.cpp 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 managed( push, off )
14 
15 //=============================================================================
16 // インクルードファイル
17 #include <CWndList.h>
18 #include <CJsonConfigAuto.h>
19 #include <LibUtility.h>
20 #include <LibWindowUtility.h>
21 #include <algorithm>
22 
23 //=============================================================================
24 // インクルード実装ファイル
25 #include <CArray.hpp>
26 
27 //=============================================================================
28 // ウィンドウライブラリ名前空間
29 namespace LibWindow {
30  //=========================================================================
31  // ウィンドウリストクラス
32  //=========================================================================
33  // 構築子と解体子
34  //-------------------------------------------------------------------------
35  // コンストラクタ
36  CWndList::CWndList() noexcept
37  // 基底クラスコンストラクタ
38  : CArray()
39  // メンバ変数初期化
40  , m_nCurrent( -1 )
41  {}
42 
43  //-------------------------------------------------------------------------
44  // ムーブコンストラクタ
45  CWndList::CWndList( CWndList&& rcInstance ) noexcept
46  // 基底クラスコンストラクタ
47  : CArray( std::move( rcInstance ) )
48  // メンバ変数初期化
49  , m_nCurrent( rcInstance.m_nCurrent )
50  {}
51 
52  //=========================================================================
53  // 公開関数
54  //-------------------------------------------------------------------------
55  // クリア関数
56  void CWndList::Clear() noexcept {
57  // 巡回する
58  for ( int nIndex = ( m_nCount - 1 ); 0 <= nIndex; --nIndex ) {
59  // エレメントウィンドウポインタを取得する
60  CWndElement* pcElement = m_pBuffer[ nIndex ];
61  if ( nullptr != pcElement ) {
62  // エレメントウィンドウインスタンスを削除する
63  delete pcElement;
64  }
65  }
66 
67  // 基底クラスの関数を実行する
68  CArray::Clear();
69  }
70 
71  //-------------------------------------------------------------------------
72  // エレメントウィンドウリスト作成関数
73  bool CWndList::CreateListWindow( HWND hParent, HMENU hMenu ) noexcept {
74  // 処理ブロック
75  bool result = false;
76  do {
77  // 巡回する
78  for ( int nIndex = 0;; ++nIndex ) {
79  // インデックスを調べる
80  if ( m_nCount <= nIndex ) {
81  // 成功!
82  result = true;
83  break;
84  }
85 
86  // エレメントウィンドウポインタを取得する
87  CWndElement* pcElement = m_pBuffer[ nIndex ];
88  if ( nullptr == pcElement ) {
89  // 失敗!
90  break;
91  }
92  // エレメントウィンドウを作成する
93  else if ( !pcElement->Create( hParent, hMenu ) ) {
94  // 失敗!
95  break;
96  }
97  }
98  } while ( false );
99 
100  // 実行結果を返す
101  return result;
102  }
103 
104  //-------------------------------------------------------------------------
105  // カレントインデックス取得関数
106  int CWndList::GetCurrentIndex() const noexcept {
107  // 処理ブロック
108  int result = -1;
109  do {
110  // 巡回する
111  for ( int nIndex = 0; m_nCount > nIndex; ++nIndex ) {
112  // エレメントウィンドウを取得する
113  CWndElement* pcElement = m_pBuffer[ nIndex ];
114  if ( nullptr != pcElement ) {
115  // インデックスを調べる
116  if ( m_nCurrent == nIndex ) {
117  // 成功!
118  result = nIndex;
119  break;
120  }
121  // 実行結果を調べる
122  else if ( 0 > result ) {
123  // 実行結果を取得する
124  result = nIndex;
125  }
126  }
127  }
128  } while ( false );
129 
130  // 実行結果を返す
131  return result;
132  }
133 
134  //-------------------------------------------------------------------------
135  // カレントインデックス設定関数
136  bool CWndList::SetCurrentIndex( int nIndex ) noexcept {
137  // 処理ブロック
138  bool result = false;
139  do {
140  // インデックスを調べる
141  if ( ( 0 > nIndex ) || ( m_nCount <= nIndex ) ) {
142  // 失敗!
143  break;
144  }
145 
146  // カレントインデックスを設定する
147  m_nCurrent = nIndex;
148 
149  // 成功!
150  result = true;
151  } while ( false );
152 
153  // 実行結果を返す
154  return result;
155  }
156 
157  //-------------------------------------------------------------------------
158  // 表示状態カレントインデックス取得関数
159  int CWndList::GetShowCurrentIndex() const noexcept {
160  // 処理ブロック
161  int result = -1;
162  do {
163  // 巡回する
164  for ( int nIndex = 0; m_nCount > nIndex; ++nIndex ) {
165  // エレメントウィンドウを取得する
166  CWndElement* pcElement = m_pBuffer[ nIndex ];
167  if ( nullptr != pcElement ) {
168  // 表示フラグを調べる
169  if ( pcElement->IsShow() ) {
170  // インデックスを調べる
171  if ( m_nCurrent == nIndex ) {
172  // 成功!
173  result = nIndex;
174  break;
175  }
176  // 実行結果を調べる
177  else if ( 0 > result ) {
178  // 実行結果を取得する
179  result = nIndex;
180  }
181  }
182  }
183  }
184  } while ( false );
185 
186  // 実行結果を返す
187  return result;
188  }
189 
190  //-------------------------------------------------------------------------
191  // 表示状態カレントエレメントウィンドウ取得関数
193  // 処理ブロック
194  CWndElement* result = nullptr;
195  do {
196  // 表示状態カレントインデックスを取得する
197  int nIndex = GetShowCurrentIndex();
198  if ( 0 > nIndex ) {
199  // 失敗!
200  break;
201  }
202 
203  // 成功!
204  result = m_pBuffer[ nIndex ];
205  } while ( false );
206 
207  // 実行結果を返す
208  return result;
209  }
210 
211  //-------------------------------------------------------------------------
212  // カレントエレメントウィンドウ取得関数
214  // 処理ブロック
215  CWndElement* result = nullptr;
216  do {
217  // カレントインデックスを取得する
218  int nIndex = GetCurrentIndex();
219  if ( 0 > nIndex ) {
220  // 失敗!
221  break;
222  }
223 
224  // 成功!
225  result = m_pBuffer[ nIndex ];
226  } while ( false );
227 
228  // 実行結果を返す
229  return result;
230  }
231 
232  //-------------------------------------------------------------------------
233  // エレメントウィンドウ取得関数
234  CWndElement* CWndList::GetElementWindow( HWND hWnd ) const noexcept {
235  // 処理ブロック
236  CWndElement* result = nullptr;
237  do {
238  // 巡回する
239  for ( int nIndex = 0; m_nCount > nIndex; ++nIndex ) {
240  // エレメントウィンドウを取得する
241  CWndElement* pcElement = m_pBuffer[ nIndex ];
242  if ( nullptr != pcElement ) {
243  // ウィンドウハンドルを調べる
244  if ( hWnd == pcElement->GetHandle() ) {
245  // 成功!
246  result = pcElement;
247  break;
248  }
249  }
250  }
251  } while ( false );
252 
253  // 実行結果を返す
254  return result;
255  }
256 
257  //-------------------------------------------------------------------------
258  // エレメントウィンドウリスト構成情報初期化関数
259  bool CWndList::InitElementListConfig( CJsonConfig& rcConfig, CWndElement* ( *pfnCreateElement )(), wchar_t const* pszElementName ) noexcept {
260  // 処理ブロック
261  bool result = false;
262  do {
263  // エレメントウィンドウ名文字列ポインタを調べる
264  if ( nullptr == pszElementName ) {
265  // 失敗!
266  break;
267  }
268  // 新規エレメントウィンドウ作成関数ポインタを調べる
269  else if ( nullptr == pfnCreateElement ) {
270  // 失敗!
271  break;
272  }
273  else {
274  // エレメントウィンドウリストセクションブロック
275  CJsonConfigAuto cConfigAuto( rcConfig, CString().Format( L"%sリスト", pszElementName ) );
276 
277  // エレメントウィンドウ数を取得する
278  int nCount = 0;
279  rcConfig.Get( nCount, KEY_ELEMENT_COUNT );
280 
281  // 巡回する
282  for ( int nIndex = 0;; ++nIndex ) {
283  // インデックスを調べる
284  if ( nCount <= nIndex ) {
285  // カレントインデックスを取得する
286  int nIndex = 0;
287  if ( rcConfig.Get( nIndex, KEY_CURRENT_INDEX ) ) {
288  // インデックスを調べる
289  if ( ( 0 <= nIndex ) && ( m_nCount > nIndex ) ) {
290  // カレントインデックスを設定する
291  m_nCurrent = nIndex;
292  }
293  }
294 
295  // 成功!
296  result = true;
297  break;
298  }
299 
300  // 新規エレメントウィンドウを作成する
301  CWndElement* pcElement = ( *pfnCreateElement )();
302  if ( nullptr != pcElement ) {
303  // エレメントウィンドウ情報セクション処理ブロック
304  CJsonConfigAuto cConfigAuto( rcConfig, SECTION_ELEMENT_INFO, nIndex );
305 
306  // ウィンドウ構成情報を初期化する
307  if ( pcElement->InitConfig( rcConfig ) ) {
308  // エレメントウィンドウリストに追加する
309  if ( Append( pcElement ) ) {
310  // 継続!
311  continue;
312  }
313  }
314  }
315 
316  // エレメントウィンドウを削除する
317  delete pcElement;
318 
319  // 失敗!
320  break;
321  }
322  }
323  } while ( false );
324 
325  // 実行結果を返す
326  return result;
327  }
328 
329  //-------------------------------------------------------------------------
330  // エレメントウィンドウリスト構成情報復元関数
331  bool CWndList::ResumeElementListConfig( CJsonConfig& rcConfig, wchar_t const* pszElementName ) noexcept {
332  // 処理ブロック
333  bool result = false;
334  do {
335  // エレメントウィンドウ名文字列ポインタを調べる
336  if ( nullptr == pszElementName ) {
337  // 失敗!
338  break;
339  }
340  else {
341  // エレメントウィンドウリストセクションブロック
342  CJsonConfigAuto cConfigAuto( rcConfig, CString().Format( L"%sリスト", pszElementName ) );
343 
344  // エレメントウィンドウ名文字列ポインタを調べる
345  if ( nullptr == pszElementName ) {
346  // 失敗!
347  break;
348  }
349  // 巡回する
350  else for ( int nIndex = 0;; ++nIndex ) {
351  // インデックスを調べる
352  if ( m_nCount <= nIndex ) {
353  // 成功!
354  result = true;
355  break;
356  }
357 
358  // エレメントウィンドウを取得する
359  CWndElement* pcElement = m_pBuffer[ nIndex ];
360  if ( nullptr != pcElement ) {
361  // エレメントウィンドウ情報セクション処理ブロック
362  CJsonConfigAuto cConfigAuto( rcConfig, SECTION_ELEMENT_INFO, nIndex );
363 
364  // ウィンドウ構成情報を復元する
365  if ( !pcElement->ResumeConfig( rcConfig ) ) {
366  // 失敗!
367  break;
368  }
369  }
370  }
371 
372  // 成功!
373  result = true;
374  }
375  } while ( false );
376 
377  // 実行結果を返す
378  return result;
379  }
380 
381  //-------------------------------------------------------------------------
382  // エレメントウィンドウリスト構成情報保存関数
383  bool CWndList::SaveElementListConfig( CJsonConfig& rcConfig, wchar_t const* pszElementName ) noexcept {
384  // 処理ブロック
385  bool result = false;
386  do {
387  // エレメントウィンドウ名文字列ポインタを調べる
388  if ( nullptr == pszElementName ) {
389  // 失敗!
390  break;
391  }
392  else {
393  // エレメントウィンドウリストセクションブロック
394  CJsonConfigAuto cConfigAuto( rcConfig, CString().Format( L"%sリスト", pszElementName ), true );
395 
396  // エレメントウィンドウ名文字列ポインタを調べる
397  if ( nullptr == pszElementName ) {
398  // 失敗!
399  break;
400  }
401  // エレメントウィンドウ数を調べる
402  else if ( 0 >= m_nCount ) {
403  // 成功!
404  result = true;
405  }
406  // エレメントウィンドウ数を保存する
407  else if ( rcConfig.Set( m_nCount, KEY_ELEMENT_COUNT ) ) {
408  // カレントインデックスを調べる
409  if ( 0 <= m_nCurrent ) {
410  // カレントインデックスを保存する
411  if ( !rcConfig.Set( m_nCurrent, KEY_CURRENT_INDEX ) ) {
412  // 失敗!
413  break;
414  }
415  }
416 
417  // 巡回する
418  for ( int nIndex = 0;; ++nIndex ) {
419  // インデックスを調べる
420  if ( m_nCount <= nIndex ) {
421  // 成功!
422  result = true;
423  break;
424  }
425 
426  // エレメントウィンドウを取得する
427  CWndElement* pcElement = m_pBuffer[ nIndex ];
428  if ( nullptr != pcElement ) {
429  // エレメントウィンドウ情報セクション処理ブロック
430  CJsonConfigAuto cConfigAuto( rcConfig, SECTION_ELEMENT_INFO, nIndex, true );
431 
432  // ウィンドウ構成情報を保存する
433  if ( !pcElement->SaveConfig( rcConfig ) ) {
434  // 失敗!
435  break;
436  }
437  }
438  }
439  }
440  }
441  } while ( false );
442 
443  // 実行結果を返す
444  return result;
445  }
446 
447  //-------------------------------------------------------------------------
448  // 子エレメントウィンドウリスト情報取得関数
449  bool CWndList::GetChildElementListInfo( CWndPane* pcParent, SChildPaneInfo& rsChildInfo ) noexcept {
450  // 処理ブロック
451  bool result = false;
452  do {
453  // 親ペインウィンドウポインタを調べる
454  if ( nullptr == pcParent ) {
455  // 失敗!
456  break;
457  }
458 
459  // 巡回する
460  for ( int nIndex = 0;; ++nIndex ) {
461  // インデックスを調べる
462  if ( m_nCount <= nIndex ) {
463  // 成功!
464  result = true;
465  break;
466  }
467 
468  // エレメントウィンドウを取得する
469  CWndElement* pcElement = m_pBuffer[ nIndex ];
470  if ( nullptr != pcElement ) {
471  // 子ウィンドウ数をインクリメントする
472  ++rsChildInfo.m_nCount;
473 
474  // 表示フラグを調べる
475  if ( pcElement->IsShow() ) {
476  // 表示状態子ウィンドウ数をインクリメントする
477  ++rsChildInfo.m_nShow;
478  }
479  else {
480  // 非表示状態子ウィンドウ数をインクリメントする
481  ++rsChildInfo.m_nHide;
482  }
483 
484  // 非表示可能状態を調べる
485  if ( pcParent->CanHideChildWindow( pcElement ) ) {
486  // 非表示可能状態子ウィンドウ数をインクリメントする
487  ++rsChildInfo.m_nHideable;
488  }
489 
490  // 削除可能状態を調べる
491  if ( pcParent->CanDeleteChildWindow( pcElement ) ) {
492  // 削除可能状態子ウィンドウ数をインクリメントする
493  ++rsChildInfo.m_nDeletable;
494  }
495 
496  // 子ペインウィンドウ情報を取得する
497  if ( !pcElement->GetChildPaneInfo( rsChildInfo ) ) {
498  // 失敗!
499  break;
500  }
501  }
502  }
503  } while ( false );
504 
505  // 実行結果を返す
506  return result;
507  }
508 
509  //-------------------------------------------------------------------------
510  // エレメントウィンドウリストオーダー番号取得関数
511  int CWndList::GetElementListOrderIndex( CWndPane* pcPane, int* pnOrder ) noexcept {
512  // 処理ブロック
513  int result = -1;
514  do {
515  // 巡回する
516  for ( int nIndex = 0; m_nCount > nIndex; ++nIndex ) {
517  // エレメントウィンドウを取得する
518  CWndElement* pcElement = m_pBuffer[ nIndex ];
519  if ( nullptr != pcElement ) {
520  // ペインウィンドウオーダー番号を取得する
521  int nOrder = pcElement->GetOrderIndex( pcPane, pnOrder );
522  if ( 0 <= nOrder ) {
523  // 成功!
524  result = nOrder;
525  break;
526  }
527  }
528  }
529  } while ( false );
530 
531  // 実行結果を返す
532  return result;
533  }
534 
535  //-------------------------------------------------------------------------
536  // エレメントウィンドウリストオーダー番号ペインウィンドウ取得関数
537  CWndPane* CWndList::GetElementListOrderPane( int* pnOrder ) noexcept {
538  // 処理ブロック
539  CWndPane* result = nullptr;
540  do {
541  // 巡回する
542  for ( int nIndex = 0; m_nCount > nIndex; ++nIndex ) {
543  // エレメントウィンドウを取得する
544  CWndElement* pcElement = m_pBuffer[ nIndex ];
545  if ( nullptr != pcElement ) {
546  // オーダー番号ペインウィンドウを取得する
547  CWndPane* pcPane = pcElement->GetOrderPane( pnOrder );
548  if ( nullptr != pcPane ) {
549  // 成功!
550  result = pcPane;
551  break;
552  }
553  }
554  }
555  } while ( false );
556 
557  // 実行結果を返す
558  return result;
559  }
560 
561  //-------------------------------------------------------------------------
562  // 全エレメントウィンドウリスト表示関数
563  bool CWndList::ShowElementListAll( CWndPane* pcParent, bool bShow ) noexcept {
564  // 処理ブロック
565  bool result = false;
566  do {
567  // 親ペインウィンドウポインタを調べる
568  if ( nullptr == pcParent ) {
569  // 失敗!
570  break;
571  }
572 
573  // 巡回する
574  for ( int nIndex = 0;; ++nIndex ) {
575  // インデックスを調べる
576  if ( m_nCount <= nIndex ) {
577  // 成功!
578  result = true;
579  break;
580  }
581 
582  // エレメントウィンドウを取得する
583  CWndElement* pcElement = m_pBuffer[ nIndex ];
584  if ( nullptr != pcElement ) {
585  // 子ウィンドウを表示する
586  if ( !pcParent->ShowChildWindow( pcElement, bShow ) ) {
587  // 失敗!
588  break;
589  }
590  // 全子ウィンドウを表示する
591  else if ( !pcElement->ShowChildAll( bShow ) ) {
592  // 失敗!
593  break;
594  }
595  }
596  }
597  } while ( false );
598 
599  // 実行結果を返す
600  return result;
601  }
602 
603  //-------------------------------------------------------------------------
604  // 全エレメントウィンドウリスト削除関数
605  bool CWndList::DeleteElementListAll( CWndPane* pcParent ) noexcept {
606  // 処理ブロック
607  bool result = false;
608  do {
609  // 親ペインウィンドウポインタを調べる
610  if ( nullptr == pcParent ) {
611  // 失敗!
612  break;
613  }
614 
615  // 巡回する
616  for ( int nIndex = m_nCount;; --nIndex ) {
617  // インデックスを調べる
618  if ( 0 >= nIndex ) {
619  // 成功!
620  result = true;
621  break;
622  }
623 
624  // エレメントウィンドウを取得する
625  CWndElement* pcElement = m_pBuffer[ nIndex - 1 ];
626  if ( nullptr != pcElement ) {
627  // 全子ウィンドウを削除する
628  if ( !pcElement->DeleteChildAll() ) {
629  // 失敗!
630  break;
631  }
632  // 子ウィンドウを削除する
633  else if ( !pcParent->DeleteChildWindow( pcElement ) ) {
634  // 失敗!
635  break;
636  }
637  }
638  }
639  } while ( false );
640 
641  // 実行結果を返す
642  return result;
643  }
644 
645  //-------------------------------------------------------------------------
646  // エレメントウィンドウ追加関数
647  bool CWndList::AppendElementWindow( HWND hParent, CWndElement* pcElement ) noexcept {
648  // 処理ブロック
649  bool result = false;
650  do {
651  // エレメントウィンドウポインタを調べる
652  if ( nullptr == pcElement ) {
653  // 失敗!
654  break;
655  }
656  // エレメントウィンドウリストに追加する
657  else if ( Append( pcElement ) ) {
658  // ウィンドウを作成する
659  if ( pcElement->Create( hParent ) ) {
660  // カレントエレメントウィンドウを設定する
661  if ( SetCurrentIndex( m_nCount - 1 ) ) {
662  // 成功!
663  result = pcElement;
664  break;
665  }
666  }
667 
668  // エレメントウィンドウリストから削除する
669  RemoveElementWindow( pcElement );
670  }
671 
672  // エレメントウィンドウを削除する
673  delete pcElement;
674  } while ( false );
675 
676  // 実行結果を返す
677  return result;
678  }
679 
680  //-------------------------------------------------------------------------
681  // 新規エレメントウィンドウ追加関数
682  CWndElement* CWndList::AppendNewElementWindow( HWND hParent, CWndElement* ( *pfnCreateElement )() ) noexcept {
683  // 処理ブロック
684  CWndElement* result = nullptr;
685  do {
686  // 親ウィンドウを調べる
687  if ( 0 == ::IsWindow( hParent ) ) {
688  // 失敗!
689  break;
690  }
691  // 新規エレメントウィンドウ作成関数ポインタを調べる
692  else if ( nullptr == pfnCreateElement ) {
693  // 失敗!
694  break;
695  }
696 
697  // 新規エレメントウィンドウを作成する
698  CWndElement* pcElement = pfnCreateElement();
699  if ( nullptr == pcElement ) {
700  // 失敗!
701  break;
702  }
703  // エレメントウィンドウを追加する
704  else if ( AppendElementWindow( hParent, pcElement ) ) {
705  // 成功!
706  result = pcElement;
707  break;
708  }
709 
710  // エレメントウィンドウを削除する
711  delete pcElement;
712  } while ( false );
713 
714  // 実行結果を返す
715  return result;
716  }
717 
718  //-------------------------------------------------------------------------
719  // エレメントウィンドウリストデバッグサブメニュー追加関数
720  bool CWndList::AppendElementListDebugSubMenu( HMENU hMenu, CWndPane* pcParent, wchar_t const* pszElementName, WORD wIdNew ) noexcept {
721  // 処理ブロック
722  bool result = false;
723  do {
724  // メニューハンドルを調べる
725  if ( nullptr == hMenu ) {
726  // 失敗!
727  break;
728  }
729  // 親ペインウィンドウポインタを調べる
730  else if ( nullptr == pcParent ) {
731  // 失敗!
732  break;
733  }
734  // エレメントウィンドウ名文字列ポインタを調べる
735  else if ( nullptr == pszElementName ) {
736  // 失敗!
737  break;
738  }
739 
740  // ペインウィンドウオーダー番号を取得する
741  int nOrder = pcParent->GetOrderIndex();
742  if ( 0 > nOrder ) {
743  // 失敗!
744  break;
745  }
746 
747  // 通知コードを取得する
748  WORD wCode = static_cast< WORD >( nOrder );
749 
750  // サブメニューを作成する
751  HMENU hSubMenu = ::CreatePopupMenu();
752  if ( nullptr == hSubMenu ) {
753  // 失敗!
754  break;
755  }
756 
757  // 巡回する
758  for ( int nIndex = 0;; ++nIndex ) {
759  // インデックスを調べる
760  if ( m_nCount <= nIndex ) {
761  // 新規追加コマンドを調べる
762  if ( 0 != wIdNew ) {
763  // メニュー項目数を調べる
764  if ( 0 < ::GetMenuItemCount( hSubMenu ) ) {
765  // セパレータを追加する
766  ::AppendMenuW( hSubMenu, MF_SEPARATOR, 0, nullptr );
767  }
768 
769  // 新規追加コマンドを追加する
770  UINT uId = MAKELONG( wIdNew, wCode );
771  ::AppendMenuW( hSubMenu, MF_STRING, uId, CString().Format( L"新規%s", pszElementName ) );
772  SetMenuCommandData( hSubMenu, uId, reinterpret_cast< ULONG_PTR >( pcParent->GetHandle() ) );
773  }
774 
775  // メニュー項目数を調べる
776  if ( 0 < ::GetMenuItemCount( hMenu ) ) {
777  // セパレータを追加する
778  ::AppendMenuW( hMenu, MF_SEPARATOR, 0, nullptr );
779  }
780 
781  // サブメニューを追加する
782  ::AppendMenuW( hMenu, MF_POPUP, reinterpret_cast< UINT_PTR >( hSubMenu ), CString().Format( L"%sリスト", pszElementName ) );
783  if ( 0 >= GetEnableMenuCommandCount( hSubMenu ) ) {
784  // サブメニュー項目を無効化する
785  ::EnableMenuItem( hMenu, ( ::GetMenuItemCount( hMenu ) - 1 ), ( MF_BYPOSITION | MFS_DISABLED ) );
786  }
787 
788  // 成功!
789  result = true;
790  break;
791  }
792 
793  // エレメントウィンドウを取得する
794  CWndElement* pcElement = m_pBuffer[ nIndex ];
795  if ( nullptr != pcElement ) {
796  // サブサブメニューを作成する
797  HMENU hSubSubMenu = ::CreatePopupMenu();
798  if ( nullptr == hSubSubMenu ) {
799  // 失敗!
800  break;
801  }
802  // デバッグメニューを追加する
803  else if ( pcElement->AppendDebugMenu( hSubSubMenu ) ) {
804  // サブサブメニュー項目数を調べる
805  if ( 0 < ::GetMenuItemCount( hSubSubMenu ) ) {
806  // ウィンドウタイトルを取得する
807  wchar_t szBuffer[ MAX_PATH ];
808  ::GetWindowTextW( pcElement->GetHandle(), szBuffer, MAX_PATH );
809 
810  // メニュー項目数を調べる
811  if ( 0 < ::GetMenuItemCount( hSubMenu ) ) {
812  // セパレータを追加する
813  ::AppendMenuW( hSubMenu, MF_SEPARATOR, 0, nullptr );
814  }
815 
816  // サブサブメニューを追加する
817  ::AppendMenuW( hSubMenu, MF_POPUP, reinterpret_cast< UINT_PTR >( hSubSubMenu ), szBuffer );
818  if ( 0 >= GetEnableMenuCommandCount( hSubMenu ) ) {
819  // サブサブメニュー項目を無効化する
820  ::EnableMenuItem( hSubMenu, ( ::GetMenuItemCount( hSubMenu ) - 1 ), ( MF_BYPOSITION | MFS_DISABLED ) );
821  }
822  }
823  else {
824  // サブサブメニューを削除する
825  ::DestroyMenu( hSubSubMenu );
826  }
827  }
828  else {
829  // サブサブメニューを削除する
830  ::DestroyMenu( hSubSubMenu );
831  }
832  }
833  }
834 
835  // 実行結果を調べる
836  if ( !result ) {
837  // サブメニューを削除する
838  ::DestroyMenu( hSubMenu );
839  }
840  } while ( false );
841 
842  // 実行結果を返す
843  return result;
844  }
845 
846  //=========================================================================
847  // 静的限定公開文字列定数
848  wchar_t const* const CWndList::SECTION_ELEMENT_INFO = L"ウィンドウ情報";
849  wchar_t const* const CWndList::KEY_ELEMENT_COUNT = L"ウィンドウ数";
850  wchar_t const* const CWndList::KEY_CURRENT_INDEX = L"カレントインデックス";
851 
852  //=========================================================================
853  // テンプレートクラス明示的インスタンス生成宣言
855 }
856 
857 #pragma managed( pop )
static wchar_t const *const KEY_CURRENT_INDEX
カレントインデックスキー文字列
Definition: CWndList.h:359
virtual bool Get(int &rnValue, wchar_t const *pszKey=nullptr, int nIndex=-1) noexcept
整数型設定値取得関数
virtual HWND & GetHandle() noexcept
ウィンドウハンドル取得関数
Definition: CWndBase.h:69
virtual bool ShowChildAll(bool bShow) noexcept
全子ウィンドウ表示関数
Definition: CWndPane.h:543
ウィンドウユーティリティライブラリヘッダファイル
virtual bool Create(HWND hParent=nullptr, HMENU hMenu=nullptr) noexcept override
ウィンドウ作成関数
Definition: CWndPane.cpp:50
virtual int GetShowCurrentIndex() const noexcept
表示状態カレントインデックス取得関数
Definition: CWndList.cpp:159
virtual bool IsShow() noexcept
表示フラグ取得関数
Definition: CWndPane.h:191
virtual bool ResumeElementListConfig(CJsonConfig &rcConfig, wchar_t const *pszElementName) noexcept
エレメントウィンドウリスト構成情報復元関数
Definition: CWndList.cpp:331
virtual CWndElement * GetElementWindow(HWND hWnd) const noexcept
エレメントウィンドウ取得関数
Definition: CWndList.cpp:234
virtual bool CreateListWindow(HWND hParent=nullptr, HMENU hMenu=nullptr) noexcept
エレメントウィンドウリスト作成関数
Definition: CWndList.cpp:73
virtual bool SetCurrentIndex(int nIndex) noexcept
カレントインデックス設定関数
Definition: CWndList.cpp:136
virtual CWndElement * GetShowCurrentElement() const noexcept
表示状態カレントエレメントウィンドウ取得関数
Definition: CWndList.cpp:192
virtual bool Append(CArray const &rcInstance) noexcept
追加関数
Definition: CArray.hpp:393
virtual void Clear() noexcept
クリア関数
Definition: CArray.hpp:209
配列クラス
Definition: CArray.h:33
int m_nCount
要素数
Definition: CArray.h:669
配列クラス実装ヘッダファイル
LIB_WINDOW_API int GetEnableMenuCommandCount(HMENU hMenu) noexcept
メニューコマンド有効数取得関数
virtual bool ResumeConfig(CJsonConfig &rcConfig) noexcept
ウィンドウ構成情報復元関数
Definition: CWndPane.cpp:395
#define LIB_WINDOW_API
ダイナミックライブラリインポート宣言
Definition: LibWindowDef.h:30
virtual CWndPane * GetElementListOrderPane(int *pnOrder) noexcept
エレメントウィンドウリストオーダー番号ペインウィンドウ取得関数
Definition: CWndList.cpp:537
virtual int GetCurrentIndex() const noexcept
カレントインデックス取得関数
Definition: CWndList.cpp:106
virtual bool DeleteChildAll() noexcept
全子ウィンドウ削除関数
Definition: CWndPane.h:556
JSON構成情報クラス
Definition: CJsonConfig.h:31
virtual bool GetChildElementListInfo(CWndPane *pcParent, SChildPaneInfo &rsChildInfo) noexcept
子エレメントウィンドウリスト情報取得関数
Definition: CWndList.cpp:449
virtual bool AppendElementWindow(HWND hParent, CWndElement *pcElement) noexcept
エレメントウィンドウ追加関数
Definition: CWndList.cpp:647
int m_nCurrent
カレントインデックス
Definition: CWndList.h:352
ウィンドウライブラリ名前空間
Definition: CommandIdDef.h:22
virtual bool Set(int nValue, wchar_t const *pszKey=nullptr, int nIndex=-1) noexcept
整数型設定値設定関数
ウィンドウリストクラスヘッダファイル
virtual bool SaveConfig(CJsonConfig &rcConfig) noexcept
ウィンドウ構成情報保存関数
Definition: CWndPane.cpp:419
virtual void Clear() noexcept override
クリア関数
Definition: CWndList.cpp:56
virtual bool InitConfig(CJsonConfig &rcConfig) noexcept
ウィンドウ構成情報初期化関数
Definition: CWndPane.h:336
virtual bool RemoveElementWindow(CWndElement *pcElement) noexcept
エレメントウィンドウ削除関数
Definition: CWndList.h:196
JSON構成情報自動セクションブロッククラス
static wchar_t const *const KEY_ELEMENT_COUNT
エレメントウィンドウ数キー文字列
Definition: CWndList.h:358
virtual bool AppendDebugMenu(HMENU hMenu) noexcept
デバッグメニュー追加関数
Definition: CWndPane.cpp:1055
ウィンドウリストクラス
Definition: CWndList.h:35
文字列クラス
Definition: CString.h:31
virtual bool AppendElementListDebugSubMenu(HMENU hMenu, CWndPane *pcParent, wchar_t const *pszElementName, WORD wIdNew) noexcept
エレメントウィンドウリストデバッグサブメニュー追加関数
Definition: CWndList.cpp:720
static wchar_t const *const SECTION_ELEMENT_INFO
エレメントウィンドウ情報セクション文字列
Definition: CWndList.h:357
virtual bool ShowElementListAll(CWndPane *pcParent, bool bShow) noexcept
全エレメントウィンドウリスト表示関数
Definition: CWndList.cpp:563
Type * m_pBuffer
バッファポインタ
Definition: CArray.h:667
virtual int GetElementListOrderIndex(CWndPane *pcPane, int *pnOrder) noexcept
エレメントウィンドウリストオーダー番号取得関数
Definition: CWndList.cpp:511
virtual CWndElement * GetCurrentElement() const noexcept
カレントエレメントウィンドウ取得関数
Definition: CWndList.cpp:213
LIB_WINDOW_API bool SetMenuCommandData(HMENU hMenu, UINT uId, ULONG_PTR uData) noexcept
メニューコマンドデータ設定関数
virtual bool DeleteElementListAll(CWndPane *pcParent) noexcept
全エレメントウィンドウリスト削除関数
Definition: CWndList.cpp:605
ペインウィンドウクラス
Definition: CWndPane.h:74
virtual CWndElement * AppendNewElementWindow(HWND hParent, CWndElement *(*pfnCreateElement)()) noexcept
新規エレメントウィンドウ追加関数
Definition: CWndList.cpp:682
virtual bool GetChildPaneInfo(SChildPaneInfo &rsChildInfo) noexcept
子ペインウィンドウ情報取得関数
Definition: CWndPane.cpp:497
virtual CWndPane * GetOrderPane(int *pnOrder) noexcept
オーダー番号ペインウィンドウ取得関数
Definition: CWndPane.cpp:551
virtual bool SaveElementListConfig(CJsonConfig &rcConfig, wchar_t const *pszElementName) noexcept
エレメントウィンドウリスト構成情報保存関数
Definition: CWndList.cpp:383
ユーティリティライブラリヘッダファイル
CWndList() noexcept
コンストラクタ
Definition: CWndList.cpp:36
JSON構成情報自動セクションブロッククラスヘッダファイル
子ペインウィンドウ情報構造体
Definition: CWndPane.h:43
virtual bool InitElementListConfig(CJsonConfig &rcConfig, CWndElement *(*pfnCreateElement)(), wchar_t const *pszElementName) noexcept
エレメントウィンドウリスト構成情報初期化関数
Definition: CWndList.cpp:259
virtual int GetOrderIndex(CWndPane *pcPane=nullptr, int *pnOrder=nullptr) noexcept
ペインウィンドウオーダー番号取得関数
Definition: CWndPane.cpp:511