Seite 1 von 1

BeitragVerfasst: Sa 28. Jun 2008, 16:40
Author: taz
Hi,

In the merge project I'm working on, there was a room for same checkbox on 2 option pages. Since I invested some time in this I thought a code sample that might be useful for others is in place.

@CPPgSecurity::OnApply
Code: Alles auswählen
...
    if (!thePrefs.filterserverbyip && IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER)!=0)
        bIPFilterSettingsChanged = true;

// By Taz - sync with IDC_FILTERSERVERBYIPFILTER on PPgMOD2
//    thePrefs.filterserverbyip = IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER)!=0;
    if (::IsWindowVisible(m_hWnd)){
        thePrefs.filterserverbyip = (IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER)!=0);
        if(thePrefs.filterserverbyip)
            theApp.emuledlg->preferenceswnd->m_wndMOD2.CheckDlgButton(IDC_FILTERSERVERBYIPFILTER, 1);
        else
            theApp.emuledlg->preferenceswnd->m_wndMOD2.CheckDlgButton(IDC_FILTERSERVERBYIPFILTER, 0);
    }
    else if (!::IsWindowVisible(theApp.emuledlg->preferenceswnd->m_wndMOD2.m_hWnd) &&
            (IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER) != theApp.emuledlg->preferenceswnd->m_wndMOD2.IsDlgButtonChecked(IDC_FILTERSERVERBYIPFILTER))){
// revert to default value
                CheckDlgButton(IDC_FILTERSERVERBYIPFILTER, 1);
                thePrefs.filterserverbyip = true;
    }
// <------- sync with IDC_FILTERSERVERBYIPFILTER on PPgMOD2

    if (bIPFilterSettingsChanged)
        theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers();
...


and a small change @PreferencesDlg.h

Code: Alles auswählen
// Contrib - SlideBar
//class CPreferencesDlg : public CTreePropSheet
class CPreferencesDlg : public PREF_PARENT_CLASS
// <-------- SlideBar

{

// By Taz - ASF
    friend class CPPgMOD2;
    friend class CPPgSecurity;
// <------- ASF

    DECLARE_DYNAMIC(CPreferencesDlg)

public:
...


Bild