Skip to content

Commit

Permalink
・ウィンドウリストアイテムを取得して中に子エディットボックスを作成する
Browse files Browse the repository at this point in the history
  • Loading branch information
miura committed Apr 27, 2017
1 parent 14fe9c6 commit bda7e04
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 7 deletions.
Binary file modified Debug/ObjeqtNote.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions ObjeqtNote/MainMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ CMainMenuBar::CMainMenuBar(HWND hWnd) : CMenuBar(hWnd){

}

// "新規"選択時の独自ハンドラOnFileNew.
void CMainMenuBar::OnFileNew() {

// メインウィンドウオブジェクトの取得
CMainWindow *pMainWindow = dynamic_cast<CMainWindow *>(CWindow::m_mapWindowMap[m_hWnd]); // CWindow::m_mapWindowMap[m_hWnd]でpMainWindowを取得.(途中dynamic_castしている.)
if (pMainWindow != NULL) { // キャスト成功.

// 1番目のアイテムを取得.
CWindowListItem * pItem = pMainWindow->m_pWindowListControl->Get(1); // pMainWindow->m_pWindowListControl->Getで1番目を取得.
if (pItem != NULL) {
if (pMainWindow->m_pEditBox == NULL) {
// エディットボックスをアイテムの子ウィンドウにする.
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(m_hWnd, GWL_HINSTANCE); // GetWindowLongでhInstanceを取得.
pMainWindow->m_pEditBox = new CEditBox(); // エディットボックス作成.
pMainWindow->m_pEditBox->Create(_T(""), WS_BORDER, 30, 10, 100, 30, pItem->m_hWnd, (HMENU)IDC_EDITBOX1, hInstance);
}
}

}

}

// "開く"選択時の独自ハンドラOnFileOpen.
void CMainMenuBar::OnFileOpen() {

Expand Down
1 change: 1 addition & 0 deletions ObjeqtNote/MainMenuBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CMainMenuBar : public CMenuBar {
CMainMenuBar(HWND hWnd); // コンストラクタCMainMenuBar(HWND hWnd)

// メンバ関数
virtual void OnFileNew(); // "新規"選択時の独自ハンドラOnFileNew.
virtual void OnFileOpen(); // "開く"選択時の独自ハンドラOnFileOpen.
virtual void OnFileSaveAs(); // "名前を付けて保存"選択時の独自ハンドラOnFileSaveAs.

Expand Down
8 changes: 4 additions & 4 deletions ObjeqtNote/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ CMainWindow::CMainWindow() : CStandardWindow() {
CMainWindow::~CMainWindow() {

// メンバの終了処理.
if (m_pEditBox != NULL) { // ウィンドウリストアイテムの子エディットボックスを先に終了処理する.
delete m_pEditBox; // deleteでm_pEditBoxを解放.
m_pEditBox = NULL; // m_pEditBoxをNULLで埋める.
}
Destroy(); // Destroyで破棄.
if (m_pPictureBox != NULL) {
delete m_pPictureBox; // deleteでm_pPictureBoxを解放.
m_pPictureBox = NULL; // m_pPictureBoxをNULLで埋める.
}
if (m_pEditBox != NULL) {
delete m_pEditBox; // deleteでm_pEditBoxを解放.
m_pEditBox = NULL; // m_pEditBoxをNULLで埋める.
}
if (m_pUserControl != NULL) {
delete m_pUserControl; // deleteでm_pUserControlを解放.
m_pUserControl = NULL; // m_pUserControlをNULLで埋める.
Expand Down
Binary file modified ObjeqtNote/ObjeqtNote.rc
Binary file not shown.
10 changes: 9 additions & 1 deletion ObjeqtNote/WindowListControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ BOOL CWindowListControl::Insert(LPCTSTR lpctszWindowName, int iIndex, int iHeigh

}

// アイテム削除Remove
// アイテム削除関数Remove
BOOL CWindowListControl::Remove(int iIndex) {

// アイテムズパネルのRemoveを呼ぶ.
return m_pWindowListItemsPanel->Remove(iIndex); // m_pWindowListItemsPanel->Removeで削除.

}

// アイテム取得関数Get
CWindowListItem * CWindowListControl::Get(int iIndex) {

// iIndex番目を返す.
return m_pWindowListItemsPanel->Get(iIndex); // m_pWindowListItemsPanel->GetでiIndex番目を返す.

}

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

Expand Down
3 changes: 2 additions & 1 deletion ObjeqtNote/WindowListControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class CWindowListControl : public CUserControl {
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 BOOL Insert(LPCTSTR lpctszWindowName, int iIndex, int iHeight, HINSTANCE hInstance); // アイテム挿入関数Insert
virtual BOOL Remove(int iIndex); // アイテム削除Remove
virtual BOOL Remove(int iIndex); // アイテム削除関数Remove
virtual CWindowListItem *Get(int iIndex); // アイテム取得関数Get
virtual int OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct); // ウィンドウ作成時のハンドラOnCreate.
virtual void OnPaint(); // ウィンドウの描画を要求された時のハンドラOnPaint.
virtual void OnHScroll(UINT nSBCode, UINT nPos); // 水平方向スクロールバーイベント時のハンドラOnHScroll.
Expand Down
17 changes: 17 additions & 0 deletions ObjeqtNote/WindowListItemsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ BOOL CWindowListItemsPanel::Remove(int iIndex) {

}

// アイテム取得関数Get
CWindowListItem * CWindowListItemsPanel::Get(int iIndex) {

// iIndex番目の要素を返す.
int i = 0; // iを0に初期化.
std::list<CWindowListItem *>::iterator itor = m_lstWindowList.begin(); // イテレータ.
while (itor != m_lstWindowList.end()) {
if (i == iIndex) {
return (*itor);
}
i++;
itor++;
}
return NULL;

}

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

Expand Down
3 changes: 2 additions & 1 deletion ObjeqtNote/WindowListItemsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class CWindowListItemsPanel : public CUserControl {
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 BOOL Insert(LPCTSTR lpctszWindowName, int iIndex, int iHeight, HINSTANCE hInstance); // アイテム挿入関数Insert
virtual BOOL Remove(int iIndex); // アイテム削除Remove
virtual BOOL Remove(int iIndex); // アイテム削除関数Remove
virtual CWindowListItem *Get(int iIndex); // アイテム取得関数Get
virtual int OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct); // ウィンドウ作成時のハンドラOnCreate.
virtual void OnPaint(); // ウィンドウの描画を要求された時のハンドラOnPaint.

Expand Down
Binary file modified Release/ObjeqtNote.exe
Binary file not shown.

0 comments on commit bda7e04

Please sign in to comment.