root/MainAddressBookEditDlg.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. CMainAddressBookEditDlg
  2. DoDataExchange
  3. BEGIN_MESSAGE_MAP
  4. OnOK

/*
 * Copyright (C) 2002-2003 chik, s.hiranaka
 * For license terms, see the file COPYING in this directory.
 */

// MainAddressBookEditDlg.cpp : インプリメンテーション ファイル
//

#include "stdafx.h"
#include "pochy.h"
#include "MainAddressBookEditDlg.h"
#include "MainAddressBookDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainAddressBookEditDlg ダイアログ


CMainAddressBookEditDlg::CMainAddressBookEditDlg(CWnd* pParent /*=NULL*/)
        : CDialog(CMainAddressBookEditDlg::IDD, pParent)
{
        //{{AFX_DATA_INIT(CMainAddressBookEditDlg)
                // メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します。
        //}}AFX_DATA_INIT
}


void CMainAddressBookEditDlg::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CMainAddressBookEditDlg)
        DDX_Control(pDX, IDC_MAIN_ADDRESSBOOK_EDIT_OTHER, m_others);
        DDX_Control(pDX, IDC_MAIN_ADDRESSBOOK_EDIT_NAME, m_name);
        DDX_Control(pDX, IDC_MAIN_ADDRESSBOOK_EDIT_ADDRESS, m_address);
        //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMainAddressBookEditDlg, CDialog)
        //{{AFX_MSG_MAP(CMainAddressBookEditDlg)
        //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMainAddressBookEditDlg メッセージ ハンドラ

BOOL CMainAddressBookEditDlg::OnInitDialog() 
{
        CDialog::OnInitDialog();
        
        // TODO: この位置に初期化の補足処理を追加してください
        CString address;
        CString name;
        CString others;

        CMainAddressBookDlg *dlg;
        dlg = (CMainAddressBookDlg *)this->GetParent();

        POSITION pos = dlg->m_lc.GetFirstSelectedItemPosition();
        int item = dlg->m_lc.GetNextSelectedItem(pos);
        m_index = item;
        name = dlg->m_lc.GetItemText(item, 0);
        address = dlg->m_lc.GetItemText(item, 1);
        others = dlg->m_lc.GetItemText(item, 2);

        m_name.SetWindowText(name);
        m_address.SetWindowText(address);
        m_others.SetWindowText(others);

        return TRUE;  // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
                      // 例外: OCX プロパティ ページの戻り値は FALSE となります
}

void CMainAddressBookEditDlg::OnOK() 
{
        // TODO: この位置にその他の検証用のコードを追加してください
        CString name;
        CString address;
        CString others;

        m_name.GetWindowText(name);
        m_address.GetWindowText(address);
        m_others.GetWindowText(others);

        CMainAddressBookDlg *dlg;
        dlg = (CMainAddressBookDlg *)this->GetParent();
        
        dlg->m_lc.SetItem(m_index, 0, LVIF_TEXT, name, NULL, NULL, NULL, NULL);
        dlg->m_lc.SetItem(m_index, 1, LVIF_TEXT, address, NULL, NULL, NULL, NULL);
        dlg->m_lc.SetItem(m_index, 2, LVIF_TEXT, others, NULL, NULL, NULL, NULL);

        CDialog::OnOK();
}

/* [<][>][^][v][top][bottom][index][help] */