Creating a new Settings page

Creating a new Settings page

Here you go. A nice ‘tutorial’ on creating new Settings pages. I know I’ve removed the help file bit, but it isn’t neccesary. (I know, the formatting is terrible, but I don’t feel like fixing it.)


1) Include the header file to PropertiesDlg.cpp

#include “NewPage.h”


2) In the same file, in PropertiesDlg::PropertiesDlg(HWND parent, …) { }, add:

pages[n++] = new NewPage(s);


3) In PropertiesDlg.h, change the number on this line:

enum { numPages = 14 };

Just change the number to how many Settings-pages you have.

4) In DCPlusPlus.vcproj, add these lines:



5) In the NewPage.cpp, add at the top:
#include “stdafx.h”
#include “../client/DCPlusPlus.h”
#include “Resource.h”

#include “NewPage.h”
#include “CommandDlg.h”

#include “../client/SettingsManager.h”

6) Add:
LRESULT NewPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
PropPage::translate((HWND)(*this), texts); // ‘texts’ here is a static TextItem array. Omit if desired.
PropPage::read((HWND)*this, items, 0, 0); // ‘items’ here is a static Item array. Omit if desired.

// Do specialized reading here
return TRUE;

7) Add:
void NewPage::write() {
PropPage::write((HWND)*this, items, 0, 0); // ‘items’ here is a static Item array, the very same variable as on 6). Omit if desired.

8.1) If you want to have text in your page, add:
PropPage::TextItem NewPage::texts[] = {
{ 0, ResourceManager::SETTINGS_AUTO_AWAY } // Pretty much used everywhere else… You can might aswell include it.
Remember that you have to have the ‘texts’ array included.

8.2) If you want to have items in your page, add:
PropPage::Item NewPage::items[] = {
{ IDC_SOME_ITEM, SettingsManager::SOME_TEXT_BLAH, PropPage::T_INT },
{ 0, 0, PropPage::T_END }
Depending on the item, use T_INT or T_STRING.

Well, you get the hang of it there.

9) In NewPage.h, add:
#ifndef NEWPAGE_H
#define NEWPAGE_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <atlcrack.h>
#include “PropPage.h”
#include “ExListViewCtrl.h”

class NewPage : public CPropertyPage<IDD_NEWPAGE>, public PropPage
NewPage(SettingsManager *s) : PropPage(s) {
m_psp.dwFlags |= PSP_HASHELP;

virtual ~NewPage() {


LRESULT onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

// Common PropPage interface
PROPSHEETPAGE *getPSP() { return (PROPSHEETPAGE *)*this; }
virtual void write();


static Item items[]; // If you want it that is…
static TextItem texts[]; // If you want it that is…

#endif //NEWPAGE_H

10) Last, you need to add it to resource.h:

#define IDD_NEWPAGE 123
11) Add SETTING_NEWPAGE to StringDefs.h.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: