root/SettingGeneralDlg.cpp
/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- CSettingGeneralDlg
- DoDataExchange
- BEGIN_MESSAGE_MAP
- OnSelchangeTab
- OnOK
/*
* Copyright (C) 2002-2003 chik, s.hiranaka
* For license terms, see the file COPYING in this directory.
*/
// SettingGeneralDlg.cpp : インプリメンテーション ファイル
//
#include "stdafx.h"
#include "pochy.h"
#include "SettingGeneralDlg.h"
#include "SettingGeneralAppearanceDlg.h"
#include "SettingGeneralOtherDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSettingGeneralDlg ダイアログ
CSettingGeneralDlg::CSettingGeneralDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSettingGeneralDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSettingGeneralDlg)
// メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します。
//}}AFX_DATA_INIT
}
void CSettingGeneralDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSettingGeneralDlg)
DDX_Control(pDX, IDC_SETTING_GENERAL_TAB, m_tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSettingGeneralDlg, CDialog)
//{{AFX_MSG_MAP(CSettingGeneralDlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_SETTING_GENERAL_TAB, OnSelchangeTab)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSettingGeneralDlg メッセージ ハンドラ
BOOL CSettingGeneralDlg::OnInitDialog()
{
CDialog::OnInitDialog();
TC_ITEM item; //タブアイテム構造体
//タブコントロールに項目の追加
item.mask = TCIF_TEXT;
item.pszText = "色・フォント"; //タブの見出し文字列の設定
m_tab.InsertItem(0, &item); //タブコントロールに項目を挿入
item.pszText = "その他";
m_tab.InsertItem(1, &item);
// タブコントロールを親ウィンドウとして各タブページを作成
m_appearance_dlg.Create(IDD_SETTING_GENERAL_APPEARANCE, &m_tab);
m_other_dlg.Create(IDD_SETTING_GENERAL_OTHER, &m_tab);
//初期表示状態の設定
m_appearance_dlg.SetWindowPos(&wndTop, 2, 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
m_other_dlg.SetWindowPos(&wndTop, 2, 20, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
m_appearance_dlg.ShowWindow(SW_SHOW);
m_other_dlg.ShowWindow(SW_HIDE);
return TRUE; // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
// 例外: OCX プロパティ ページの戻り値は FALSE となります
}
void CSettingGeneralDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
int index = m_tab.GetCurSel(); //切り替え前のTabのIndex番号
//選択されたTabのみ表示する。
switch(index){
case 0:
m_appearance_dlg.ShowWindow(SW_SHOW);
m_other_dlg.ShowWindow(SW_HIDE);
break;
case 1:
m_appearance_dlg.ShowWindow(SW_HIDE);
m_other_dlg.ShowWindow(SW_SHOW);
break;
}
*pResult = 0;
}
void CSettingGeneralDlg::OnOK()
{
CPochyApp* app = (CPochyApp*)AfxGetApp();
CMainFrame *mf = (CMainFrame *)app->m_pMainWnd;
// folderviewの背景色
app->WriteProfileInt("FolderViewColor","BkColorR",GetRValue(m_appearance_dlg.m_fv_bg_cr));
app->WriteProfileInt("FolderViewColor","BkColorG",GetGValue(m_appearance_dlg.m_fv_bg_cr));
app->WriteProfileInt("FolderViewColor","BkColorB",GetBValue(m_appearance_dlg.m_fv_bg_cr));
mf->m_pTreeV->GetTreeCtrl().SetBkColor(m_appearance_dlg.m_fv_bg_cr);
// summaryviewの背景色
app->WriteProfileInt("SummaryViewColor","BkColorR",GetRValue(m_appearance_dlg.m_sv_bg_cr));
app->WriteProfileInt("SummaryViewColor","BkColorG",GetGValue(m_appearance_dlg.m_sv_bg_cr));
app->WriteProfileInt("SummaryViewColor","BkColorB",GetBValue(m_appearance_dlg.m_sv_bg_cr));
mf->m_pListV->GetListCtrl().SetBkColor(m_appearance_dlg.m_sv_bg_cr);
mf->m_pListV->GetListCtrl().SetTextBkColor(m_appearance_dlg.m_sv_bg_cr);
// textviewの背景色
app->WriteProfileInt("TextViewColor","BkColorR",GetRValue(m_appearance_dlg.m_tv_bg_cr));
app->WriteProfileInt("TextViewColor","BkColorG",GetGValue(m_appearance_dlg.m_tv_bg_cr));
app->WriteProfileInt("TextViewColor","BkColorB",GetBValue(m_appearance_dlg.m_tv_bg_cr));
mf->m_pTextV->GetRichEditCtrl().SetBackgroundColor(FALSE, m_appearance_dlg.m_tv_bg_cr);
// multipartviewの背景色
mf->m_pMultiV->GetListCtrl().SetBkColor(m_appearance_dlg.m_tv_bg_cr);
mf->m_pMultiV->GetListCtrl().SetTextBkColor(m_appearance_dlg.m_tv_bg_cr);
mf->m_pMultiV->GetListCtrl().RedrawWindow();
// editviewとattachedfileviewの背景色
app->WriteProfileInt("EditViewColor","BkColorR",GetRValue(m_appearance_dlg.m_ev_bg_cr));
app->WriteProfileInt("EditViewColor","BkColorG",GetGValue(m_appearance_dlg.m_ev_bg_cr));
app->WriteProfileInt("EditViewColor","BkColorB",GetBValue(m_appearance_dlg.m_ev_bg_cr));
for(int i=0; i<app->m_draft_array.GetSize(); i++){
app->m_draft_array.GetAt(i)->m_pEditV->GetRichEditCtrl().SetBackgroundColor(FALSE, m_appearance_dlg.m_ev_bg_cr);
app->m_draft_array.GetAt(i)->m_pListV2->GetListCtrl().SetBkColor(m_appearance_dlg.m_ev_bg_cr);
app->m_draft_array.GetAt(i)->m_pListV2->GetListCtrl().RedrawWindow();
}
// folderviewのテキスト色
app->WriteProfileInt("FolderViewColor","TxtColorR",GetRValue(m_appearance_dlg.m_fv_font_cr));
app->WriteProfileInt("FolderViewColor","TxtColorG",GetGValue(m_appearance_dlg.m_fv_font_cr));
app->WriteProfileInt("FolderViewColor","TxtColorB",GetBValue(m_appearance_dlg.m_fv_font_cr));
mf->m_pTreeV->GetTreeCtrl().SetTextColor(m_appearance_dlg.m_fv_font_cr);
// summaryviewのテキスト色
app->WriteProfileInt("SummaryViewColor","TxtColorR",GetRValue(m_appearance_dlg.m_sv_font_cr));
app->WriteProfileInt("SummaryViewColor","TxtColorG",GetGValue(m_appearance_dlg.m_sv_font_cr));
app->WriteProfileInt("SummaryViewColor","TxtColorB",GetBValue(m_appearance_dlg.m_sv_font_cr));
mf->m_pListV->GetListCtrl().SetTextColor(m_appearance_dlg.m_sv_font_cr);
// textviewのテキスト色
app->WriteProfileInt("TextViewColor","TxtColorR",GetRValue(m_appearance_dlg.m_tv_font_cr));
app->WriteProfileInt("TextViewColor","TxtColorG",GetGValue(m_appearance_dlg.m_tv_font_cr));
app->WriteProfileInt("TextViewColor","TxtColorB",GetBValue(m_appearance_dlg.m_tv_font_cr));
// textviewのヘッダ表示色
app->WriteProfileInt("TextViewHdColor","TxtColorR",GetRValue(m_appearance_dlg.m_tv_head_cr));
app->WriteProfileInt("TextViewHdColor","TxtColorG",GetGValue(m_appearance_dlg.m_tv_head_cr));
app->WriteProfileInt("TextViewHdColor","TxtColorB",GetBValue(m_appearance_dlg.m_tv_head_cr));
// multipartviewのテキスト色
mf->m_pMultiV->GetListCtrl().SetTextColor(m_appearance_dlg.m_tv_font_cr);
mf->m_pMultiV->GetListCtrl().RedrawWindow();
// editviewとattachedfileviewのテキスト色
app->WriteProfileInt("EditViewColor","TxtColorR",GetRValue(m_appearance_dlg.m_ev_font_cr));
app->WriteProfileInt("EditViewColor","TxtColorG",GetGValue(m_appearance_dlg.m_ev_font_cr));
app->WriteProfileInt("EditViewColor","TxtColorB",GetBValue(m_appearance_dlg.m_ev_font_cr));
for(i=0; i<app->m_draft_array.GetSize(); i++){
app->m_draft_array.GetAt(i)->m_pListV2->GetListCtrl().SetTextColor(m_appearance_dlg.m_ev_font_cr);
app->m_draft_array.GetAt(i)->m_pListV2->GetListCtrl().SetTextBkColor(m_appearance_dlg.m_ev_bg_cr);
app->m_draft_array.GetAt(i)->m_pListV2->GetListCtrl().RedrawWindow();
}
// 各画面の更新
mf->m_pTreeV->GetTreeCtrl().RedrawWindow();
mf->m_pListV->GetListCtrl().RedrawWindow();
mf->m_pTextV->GetRichEditCtrl().RedrawWindow();
// 外部エディタの設定を更新
CString buf;
m_other_dlg.m_editor_path.GetWindowText(buf);
app->WriteProfileString("Editor", "Path", buf);
buf.Empty();
// デフォルトアカウント設定を更新
m_other_dlg.m_def_account.GetWindowText(buf);
app->WriteProfileString("DefaultMailBox", "boxname", buf);
// 自動受信の間隔設定を更新
CString minute;
m_other_dlg.m_autofetch_minute.GetWindowText(minute);
if(minute.SpanExcluding("0123456789").IsEmpty()){
app->WriteProfileInt("AutoFetch", "minute", atoi(minute));
}
// fontの変更
mf->m_pTextV->SetFontEx(m_appearance_dlg.m_tv_lf);
// mf->m_pTextV->SetFontColorAndLink();
app->WriteProfileBinary("TextViewFont", "LogFont", (LPBYTE)&m_appearance_dlg.m_tv_lf, sizeof(LOGFONT));
for(i=0; i < app->m_draft_array.GetSize(); i++){
app->m_draft_array[i]->m_pEditV->SetFontEx(m_appearance_dlg.m_ev_lf);
// app->m_draft_array[i]->m_pEditV->SetFontColorAndLink();
}
app->WriteProfileBinary("EditViewFont", "LogFont", (LPBYTE)&m_appearance_dlg.m_ev_lf, sizeof(LOGFONT));
CDialog::OnOK();
}