Skip to content

Commit

Permalink
・リストコントロールパネルの定義
Browse files Browse the repository at this point in the history
・リストコントロールの定義
  • Loading branch information
bg1bgst333 committed May 4, 2017
1 parent eddbc7c commit fc88e60
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 6 deletions.
Binary file modified Debug/VizCommand.exe
Binary file not shown.
Binary file modified Release/VizCommand.exe
Binary file not shown.
29 changes: 29 additions & 0 deletions VizCommand/ListControl.cpp
@@ -0,0 +1,29 @@
// ヘッダのインクルード
// 独自のヘッダ
#include "ListControl.h" // リストコントロールクラス

// コンストラクタCListControl()
CListControl::CListControl() : CCustomControl() {

}

// デストラクタ~CListControl()
CListControl::~CListControl() {

}

// ウィンドウ作成関数Create(lpctszClassName省略)
BOOL CListControl::Create(LPCTSTR lpctszWindowName, DWORD dwStyle, int x, int y, int iWidth, int iHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance) {

// ウィンドウの作成.
return CCustomControl::Create(_T("SysListView32"), lpctszWindowName, dwStyle, x, y, iWidth, iHeight, hWndParent, hMenu, hInstance); // CCustomControl::Createでウィンドウを作成し, その戻り値をreturnで返す.

}

// ウィンドウ破棄関数Destroy
void CListControl::Destroy() {

// 自分のウィンドウも破棄.
CWindow::Destroy(); // CWindow::Destroyで自身のウィンドウも破棄.

}
21 changes: 21 additions & 0 deletions VizCommand/ListControl.h
@@ -0,0 +1,21 @@
// 二重インクルード防止
#pragma once // #pragma onceで二重インクルード防止.

// 独自のヘッダ
#include "CustomControl.h" // カスタムコントロールクラス

// リストコントロールクラスCListControl
class CListControl : public CCustomControl {

// publicメンバ
public:

// コンストラクタ・デストラクタ
CListControl(); // コンストラクタCListControl()
virtual ~CListControl(); // デストラクタ~CListControl()

// メンバ関数
virtual BOOL Create(LPCTSTR lpctszWindowName, DWORD dwStyle, int x, int y, int iWidth, int iHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance); // ウィンドウ作成関数Create(lpctszClassName省略)
virtual void Destroy(); // ウィンドウ破棄関数Destroy

};
79 changes: 79 additions & 0 deletions VizCommand/ListControlPanel.cpp
@@ -0,0 +1,79 @@
// ヘッダのインクルード
// 独自のヘッダ
#include "ListControlPanel.h" // リストコントロールパネルクラス
// 既定のヘッダ
#include <commctrl.h> // コモンコントロール

// ウィンドウクラス登録関数RegisterClass
BOOL CListControlPanel::RegisterClass(HINSTANCE hInstance) {

// ユーザコントロールとして登録.
return CUserControl::RegisterClass(hInstance, _T("ListControlPanel")); // CUserControl::RegisterClassでウィンドウクラス"ListControlPanel"を登録.

}

// コンストラクタCListControlPanel
CListControlPanel::CListControlPanel() : CUserControl() {

// メンバの初期化
m_pListControl = NULL; // m_pListControlをNULLで初期化.

}

// デストラクタ~CListControlPanel()
CListControlPanel::~CListControlPanel() {

// メンバの終了処理.
Destroy(); // Destroyで破棄.

}

// ウィンドウ作成関数Create
BOOL CListControlPanel::Create(LPCTSTR lpctszWindowName, DWORD dwStyle, int x, int y, int iWidth, int iHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance) {

// ユーザコントロールで作成.
m_nId = hMenu;
return CUserControl::Create(_T("ListControlPanel"), lpctszWindowName, dwStyle, x, y, iWidth, iHeight, hWndParent, m_nId, hInstance); // CUserControl::Createでウィンドウクラス"ListControlPanel"なウィンドウを作成.

}

// ウィンドウ破棄関数Destroy
void CListControlPanel::Destroy() {

// 子ウィンドウの破棄.
if (m_pListControl != NULL) {
m_pListControl->Destroy(); // m_pListControlのウィンドウを破棄.
delete m_pListControl; // deleteで解放.
m_pListControl = NULL; // NULLで埋める.
}

// 自分のウィンドウも破棄.
CWindow::Destroy(); // CWindow::Destroyで自身のウィンドウも破棄.

}

// ウィンドウ作成時のハンドラOnCreate.
int CListControlPanel::OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) {

// 子リストコントロールの生成.
m_pListControl = new CListControl(); // CListControlオブジェクトを作成し, ポインタをm_pListControlに格納.
m_pListControl->Create(_T(""), WS_BORDER | WS_VSCROLL | WS_HSCROLL | LVS_ICON, PADDING, PADDING, m_iWidth - (PADDING * 2), m_iHeight - (PADDING * 2), hwnd, m_nId + 100, lpCreateStruct->hInstance); // m_pListControl->Createでリストコントロール作成.

// 成功なので0を返す.
return 0;

}

// ウィンドウサイズが変更された時のハンドラOnSize.
void CListControlPanel::OnSize(UINT nType, int cx, int cy) {

// 実際のウィンドウサイズを格納.
m_iWidth = cx; // m_iWidthにcxをセット.
m_iHeight = cy; // m_iHeightにcyをセット.

// 子ウィンドウのリサイズ
if (m_pListControl != NULL) {
m_pListControl->MoveWindow(PADDING, PADDING, m_iWidth - (PADDING * 2), m_iHeight - (PADDING * 2));
}

}
32 changes: 32 additions & 0 deletions VizCommand/ListControlPanel.h
@@ -0,0 +1,32 @@
// 二重インクルード防止
#pragma once // #pragma onceで二重インクルード防止.

// 独自のヘッダ
#include "UserControl.h" // ユーザコントロールクラス
#include "ListControl.h" // リストコントロールクラス

// リストコントロールパネルクラスCListControlPanel
class CListControlPanel : public CUserControl {

// publicメンバ
public:

// publicメンバ変数
CListControl *m_pListControl; // CListControl *型ポインタm_pListControl.
HMENU m_nId; // HMENU型リソースID, m_nId.

// publicメンバ関数
// staticメンバ関数
static BOOL RegisterClass(HINSTANCE hInstance); // ウィンドウクラス登録関数RegisterClass

// コンストラクタ・デストラクタ
CListControlPanel(); // コンストラクタCListControlPanel
virtual ~CListControlPanel(); // デストラクタ~CListControlPanel()

// メンバ関数
virtual BOOL Create(LPCTSTR lpctszWindowName, DWORD dwStyle, int x, int y, int iWidth, int iHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance); // ウィンドウ作成関数Create
virtual void Destroy(); // ウィンドウ破棄関数Destroy
virtual int OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct); // ウィンドウ作成時のハンドラOnCreate.
virtual void OnSize(UINT nType, int cx, int cy); // ウィンドウサイズが変更された時のハンドラOnSize.

};
5 changes: 5 additions & 0 deletions VizCommand/MainApplication.cpp
Expand Up @@ -29,8 +29,13 @@ BOOL CMainApplication::InitInstance(HINSTANCE hInstance, LPTSTR lpCmdLine, int n
// エディットボックスパネルクラスの登録
//CEditBoxPanel::RegisterClass(hInstance); // CEditBoxPanel::RegisterClassでエディットボックスパネルクラスの登録.
//CScalableEditBoxPanel::RegisterClass(hInstance, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); // CScalableEditBoxPanel::RegisterClassで背景ブラシがLTGRAY_BRUSHなスカラブルエディットボックスパネルクラスの登録.

// コンソールクラスの登録
CConsole::RegisterClass(hInstance); // CConsole::RegisterClassでコンソールクラスの登録.

// リストコントロールパネルクラスの登録
CListControlPanel::RegisterClass(hInstance); // CListControlPanel::RegisterClassでリストコントロールパネルクラスの登録.

// メインウィンドウオブジェクトの生成
m_pMainWindow = new CMainWindow(); // CMainWindowオブジェクトを作成し, アドレスをm_pMainWindowに格納.

Expand Down
17 changes: 15 additions & 2 deletions VizCommand/MainWindow.cpp
Expand Up @@ -31,6 +31,7 @@ CMainWindow::CMainWindow() : CBasicWindow() {
//m_pScalableEditBoxPanel = NULL; // m_pScalableEditBoxPanelをNULLにセット.
m_pStreamConsole = NULL; // m_pStreamConsoleをNULLで初期化.
m_pConsole = NULL; // m_pConsoleをNULLにセット.
m_pListControlPanel = NULL; // m_pListControlPanelをNULLにセット.

}

Expand All @@ -54,6 +55,11 @@ BOOL CMainWindow::Create(LPCTSTR lpctszWindowName, DWORD dwStyle, int x, int y,
void CMainWindow::Destroy() {

// 子ウィンドウの破棄.
if (m_pListControlPanel != NULL) {
m_pListControlPanel->Destroy();
delete m_pListControlPanel;
m_pListControlPanel = NULL;
}
if (m_pConsole != NULL) {
m_pConsole->Destroy();
delete m_pConsole;
Expand Down Expand Up @@ -95,13 +101,17 @@ void CMainWindow::Destroy() {
int CMainWindow::OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) {

// ストリームコンソールの作成.
m_pStreamConsole = new CStreamConsole(); // CStreamConsoleオブジェクトを作成し, ポインタをm_pStreamConsoleに格納.
m_pStreamConsole->Create(_T(""), WS_VSCROLL, 0, 0, m_iWidth, m_iHeight, hwnd, (HMENU)IDC_STREAMCONSOLE, lpCreateStruct->hInstance); // m_pStreamConsole->Createでストリームコンソールを作成.
//m_pStreamConsole = new CStreamConsole(); // CStreamConsoleオブジェクトを作成し, ポインタをm_pStreamConsoleに格納.
//m_pStreamConsole->Create(_T(""), WS_VSCROLL, 0, 0, m_iWidth, m_iHeight, hwnd, (HMENU)IDC_STREAMCONSOLE, lpCreateStruct->hInstance); // m_pStreamConsole->Createでストリームコンソールを作成.

// ウィンドウリストコントロールの作成.
//m_pWindowListControl = new CWindowListControl(); // CWindowListControlオブジェクトを作成し, ポインタをm_pWindowListControlに格納.
//m_pWindowListControl->Create(_T(""), WS_VSCROLL, 0, 0, m_iWidth, m_iHeight, hwnd, (HMENU)IDC_WINDOWLISTCONTROL1, lpCreateStruct->hInstance); // m_pWindowListControl->Createでウィンドウリストコントロールを作成.

// リストコントロールの作成.
m_pListControlPanel = new CListControlPanel(); // CListControlPanelオブジェクトを作成し, m_pListControlPanelに格納.
m_pListControlPanel->Create(_T(""), 0, 0, 0, m_iWidth, m_iHeight, hwnd, (HMENU)IDC_WINDOWLISTITEM_CHILD_ID_START, lpCreateStruct->hInstance); // m_pListControlPanel->Createでリストコントロールパネルを作成.

#if 0

// アイテムを挿入.
Expand Down Expand Up @@ -219,5 +229,8 @@ void CMainWindow::OnSize(UINT nType, int cx, int cy) {
if (m_pStreamConsole != NULL) {
m_pStreamConsole->MoveWindow(PADDING, PADDING, cx - (PADDING * 2), cy - (PADDING * 2)); // 3pxなら2倍の6pxサイズが小さくならなければならない.
}
if (m_pListControlPanel != NULL) {
m_pListControlPanel->MoveWindow(PADDING, PADDING, cx - (PADDING * 2), cy - (PADDING * 2)); // 3pxなら2倍の6pxサイズが小さくならなければならない.
}

}
10 changes: 6 additions & 4 deletions VizCommand/MainWindow.h
Expand Up @@ -9,6 +9,7 @@
//#include "ScalableEditBoxPanel.h" // スカラブルエディットボックスパネルクラス
#include "Console.h" // コンソールクラス
#include "StreamConsole.h" // ストリームコンソールクラス
#include "ListControlPanel.h" // リストコントロールパネルクラス
#include "resource.h" // リソース

// メインウィンドウクラスCMainWindow
Expand All @@ -18,11 +19,12 @@ class CMainWindow : public CBasicWindow {
public:

// publicメンバ変数
//CWindowListControl *m_pWindowListControl; // CWindowListControl *型ウィンドウリストコントロールオブジェクトポインタm_pWindowListControl
//CScalableEditBox *m_pScalableEditBox; // CScalableEditBox *型スカラブルエディットボックスオブジェクトポインタm_pScalableEditBox
//CWindowListControl *m_pWindowListControl; // CWindowListControl *型ウィンドウリストコントロールオブジェクトポインタm_pWindowListControl
//CScalableEditBox *m_pScalableEditBox; // CScalableEditBox *型スカラブルエディットボックスオブジェクトポインタm_pScalableEditBox
//CScalableEditBoxPanel *m_pScalableEditBoxPanel; // CScalableEditBoxPanel *型スカラブルエディットボックスパネルオブジェクトポインタm_pScalableEditBoxPanel
CStreamConsole *m_pStreamConsole; // CStreamConsole *型ストリームコンソールオブジェクトポインタm_pStreamConsole
CConsole *m_pConsole; // CConsole *型コンソールオブジェクトポインタm_pConsole
CStreamConsole *m_pStreamConsole; // CStreamConsole *型ストリームコンソールオブジェクトポインタm_pStreamConsole
CConsole *m_pConsole; // CConsole *型コンソールオブジェクトポインタm_pConsole
CListControlPanel *m_pListControlPanel; // CListControlPanel *型リストコントロールパネルオブジェクトポインタm_pListControlPanel

// publicメンバ関数
// staticメンバ関数
Expand Down
Binary file modified VizCommand/VizCommand.rc
Binary file not shown.
4 changes: 4 additions & 0 deletions VizCommand/VizCommand.vcxproj
Expand Up @@ -154,6 +154,8 @@
<ClCompile Include="CustomControl.cpp" />
<ClCompile Include="EditBox.cpp" />
<ClCompile Include="EditBoxPanel.cpp" />
<ClCompile Include="ListControl.cpp" />
<ClCompile Include="ListControlPanel.cpp" />
<ClCompile Include="MainApplication.cpp" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="PictureBox.cpp" />
Expand All @@ -177,6 +179,8 @@
<ClInclude Include="CustomControl.h" />
<ClInclude Include="EditBox.h" />
<ClInclude Include="EditBoxPanel.h" />
<ClInclude Include="ListControl.h" />
<ClInclude Include="ListControlPanel.h" />
<ClInclude Include="MainApplication.h" />
<ClInclude Include="MainWindow.h" />
<ClInclude Include="PictureBox.h" />
Expand Down

0 comments on commit fc88e60

Please sign in to comment.