0

I've implemented a Property Sheet and several Property Pages that are called from the Main Menu from the MainFrame.cpp spawned from my issue here:

MFC MDI Designing user preferences dialog GUI layout functionality

The code I landed on was:

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
    Other messages...  
    ON_COMMAND(ID_SETTINGS_DIALOG, OnSettingsTools)
    Other messages... 
END_MESSAGE_MAP()

void CMainFrame::OnSettingsTools()
{

    SettingsSheet SettingsSheet(L"Application Settings");

    CSettingsPowerUser      m_PowerUser;
    CSettingsReset          m_Reset;
    CSettingsToolbars       m_Toolbars;
    CSettingsUserWarnings   m_UserWarnings;

    SettingsSheet.AddPage(&m_PowerUser);
    SettingsSheet.AddPage(&m_Reset);
    SettingsSheet.AddPage(&m_Toolbars);
    SettingsSheet.AddPage(&m_UserWarnings);

    //SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs);

    SettingsSheet.DoModal();
}

Yielding:

Settings Sheet/Pages Working

I have included in MainFrame.h

#include <afxpropertysheet.h>

The property sheet is using CMFCPropertySheet in both the .cpp & .h as shown here in its .h file:

class SettingsSheet : public CMFCPropertySheet
{
    DECLARE_DYNAMIC(SettingsSheet)

public:
    SettingsSheet(UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0);
    SettingsSheet(LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0);
    virtual ~SettingsSheet();

protected:
    DECLARE_MESSAGE_MAP()
};

So what the issue here is, you can see that I had to comment out the SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs); because I get an error that says SetLook identifier not found C3861.

If I hover inside the MainForm.h and right click the #include <afxpropertysheet.h> the file opens right up in the IDE and if I search for SetLook it most certainly can find it in the public section of the function.

So I've seen multiple code examples that use that SetLook and one of the tutorials I looked at used it and it works fine as I'm using VS2017.

I realize what a "not found is", but I'm at a loss as to why it's a problem here. It is the only error I am having now and I would like to use that functionality.

Thoughts on what may be going on here?

Update:

Following Dxiv's advice I changed the code to:

SettingsSheet.SetLook(CMFCPropertySheet::PropSheetLook_OneNoteTabs);

It now compiles and runs, but have some odd results, it only shows one property page, and all the rest are AWOL.

Tabs are missing!

Kittmaster
  • 141
  • 8
  • 1
    Try `SettingsSheet.SetLook(...)` instead. Unrelated, but naming variables the same as their type is never a good idea. – dxiv Apr 28 '21 at 23:24
  • I will try that, to your other point, doesn't the `m_` solve that particular issue to maintain clarity? Just out of curiosity, I'm always looking to improve, how would you name those particular variables if it were your code? – Kittmaster Apr 28 '21 at 23:29
  • There is no `m_` in `SettingsSheet SettingsSheet(L"Application Settings");`. Also, and especially in the MFC world, `m_` is generally used for member variables, so defining a local variable `m_Reset` is confusing as well. What naming convention you use is a matter of preference, what's important is that you choose one and stick to it consistently. In this particular case, I would probably name the class `CMySettingsSheet` or something other starting with a `C` to match the MFC style. – dxiv Apr 28 '21 at 23:34
  • I updated the original thread with an unexpected result. I understand what your saying and will make some adjustments. Thank you for the critique! – Kittmaster Apr 28 '21 at 23:40
  • 1
    Do those 'scrollbar arrows' at the top of your sheet do anything? Looks like, for some reason, the tabs have rather large widths. Try clicking the scroll right to get the 'next' page. I'll look into the options for the `PropSheetLook_OneNoteTabs` look style. – Adrian Mole Apr 29 '21 at 00:33
  • I clicked both left and right, nothing changes, almost like they are "jammed". I also added the 2nd argument of `, 150` which is `int` to set the size, nothing changed. – Kittmaster Apr 29 '21 at 00:35
  • Never used that style myself but [here](http://ntcoder.com/bab/mfc-feature-pack-tutorial-part-2-cmfcpropertysheet/) the implication is that you need some kind of icon list (probably a list of bitmaps). Sorry for linking another (dodgy?) online tutorial. – Adrian Mole Apr 29 '21 at 00:45
  • Also, [this msdn blog](https://social.msdn.microsoft.com/Forums/Windowsdesktop/en-US/46190828-8412-4801-b9d1-f64a9a5cc1b4/cmfcpropertysheetpropsheetlookonenotetabs-asserts-in-debug?forum=vcgeneral) suggests issues with the OneNote stuff unless you link MFC as a shared DLL. – Adrian Mole Apr 29 '21 at 00:47
  • I added `SettingsSheet.SetIconsList(IDB_NIBU, 32);` but IDB_NIBU is not found...and that is most likely because I don't have that bitmap....they make a lot of assumptions...and I have `Use of MFC` set as `Use MFC in a Shared DLL` – Kittmaster Apr 29 '21 at 00:55
  • Any other thoughts? I can't seem to find anyone with this similar issue. Not sure if there is something missing on initialization? – Kittmaster Apr 29 '21 at 21:18

1 Answers1

1

I have figured out what the issue was; when I created the dialogs I used the base class of:

CPropertyPage

instead of:

CMFCPropertyPage

I had set the sheet to:

CMFCPropertySheet

and assumed it carried down since it compiled and displayed the tab view correctly, but failed on the other SetLook property options.

Once I adjusted all the dialogs to CMFCPropertyPage, the SetLook started working immediately. So I consider this issue CLOSED.

Kittmaster
  • 141
  • 8