Click here to Skip to main content
15,867,756 members
Articles / Desktop Programming / MFC
Article

Using CResizablePage In a CFormView

Rate me:
Please Sign up or sign in to vote.
3.07/5 (18 votes)
16 Apr 2001CPOL 102.8K   2.1K   27   7
Technique for utilizing a CResizablePage in a CFormView-derived class

Introduction - A Little Background

My first exposure to Paolo Messina's code for creating a resizable dialog box involved a CPopertySheet embedded in a dialog box which (of course) contained one or more (dynamically added) property pages. The app itself was already well along in the development cycle, but it still wasn't difficult at all to add the support from CResizable*.* that I needed.

Due to the nature of the property sheet, I didn't need the CResizableSheet code, but I did make use of the other two components (CResizableDialog and CResizablePage).

The Task At Hand

Over the last couple of months, my boss has been developing an application with a splitter view containing a CTreeView, a couple of CListViews, and a CFormView containing a tab control with several tabs that each contain a list control.

As you all know, when a view is resized to be smaller than the data/object it contains, the pane automatically displays scroll bars so that you can scroll the desired portion into view. The formview pane had the nasty habit of scrolling the entire pane when such an event occurs, and this has the side affect (in our case) of scrolling the tab titles out of the visible pane.

To remedy this situation, I used the embedded property sheet technique that I had used in my other application, and instead of using a tab control, I used individual CResizablePage objects to represent the tabs.

When using a property sheet, you have the benefit of a self-induced border around the tab control. While this is handy on a dialog box, it's a royal pain with a CWnd on a formview, especially our formview. The fix was to offset the page enough to where the list control on the tabs filled the entire pane, thus emulating the pane scroll bars.

I guess the long and short of it is that the formview looks like a tabbed list view, and the tabs don't scroll off the pane when the scroll bars (if any) are manipulated.

I've included a demo (the same one I gave my boss) of the technique I used.

I don't remember where I got the code for the embedded property sheet, but it sure has come in handy in a number of instances.

Lastly, many tanks to Paolo for the CResizable*.* classes. They've been the most useful set of classes I've used in many, many years.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Paddedwall Software
United States United States
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.

My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.

Comments and Discussions

 
GeneralMy vote of 1 Pin
CSawant12-Jul-09 1:25
CSawant12-Jul-09 1:25 
Generalcformview ..... please .. please .. hepl me ! Pin
Anonymous7-Jul-03 18:49
Anonymous7-Jul-03 18:49 
GeneralAdding Controls Dynamically to CFormView Pin
Muhammad Yousaf7-May-03 8:43
Muhammad Yousaf7-May-03 8:43 
GeneralFit a dialog into a View of a Window Pin
17-Apr-02 8:27
suss17-Apr-02 8:27 
QuestionDemo Broken? Pin
Stephen Woods1-Apr-02 19:13
Stephen Woods1-Apr-02 19:13 
GeneralMemory Leaks Pin
4-Dec-00 16:02
suss4-Dec-00 16:02 
First of all, good job on the demo. Cool | :cool:

Second, I received memory leaks after I extracted, compiled, and ran the code through the debugger. Eek! | :eek:

-> One thing I noticed (which is probably causing the leaks) is that your ~CResizablePage() and ~CTabDataSheet() destructors are not being invoked when the application closes.

Below is the output from the debug session so that you may plug your leaks:

Loaded 'C:\WINDOWS\SYSTEM\OLEAUT32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLEPRO32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\MSVCRT20.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLE32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLEDLG.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\WINSPOOL.DRV', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\SHELL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMCTL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\SHLWAPI.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMDLG32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\ADVAPI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\GDI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\USER32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\KERNEL32.DLL', no matching symbolic information found.
CDlgPHCA::DeleteDataSheet()
CTabDataSheet::CTabDataSheet()
Detected memory leaks!
Dumping objects ->
plex.cpp(31) : {654} normal block at 0x014B2870, 124 bytes long.
Data: < )K > 00 00 00 00 00 00 00 00 00 00 00 00 20 29 4B 01
C:\Projects\formview\ResizablePage.cpp(165) : {653} normal block at 0x014B2920, 44 bytes long.
Data: < > 18 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00
plex.cpp(31) : {579} normal block at 0x014B2980, 124 bytes long.
Data: < 0*K > 00 00 00 00 00 00 00 00 00 00 00 00 30 2A 4B 01
C:\Projects\formview\ResizablePage.cpp(165) : {578} normal block at 0x014B2A30, 44 bytes long.
Data: <( > 28 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00
plex.cpp(31) : {525} normal block at 0x014B2A90, 124 bytes long.
Data: < K > 00 00 00 00 00 00 00 00 00 00 00 00 A0 11 4B 01
C:\Projects\formview\ResizablePage.cpp(165) : {524} normal block at 0x014B11A0, 44 bytes long.
Data: < > 90 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00
plex.cpp(31) : {91} normal block at 0x014B2F70, 124 bytes long.
Data: < K > 00 00 00 00 00 00 00 00 00 00 00 00 C0 10 4B 01
C:\Projects\formview\ResizablePage.cpp(165) : {90} normal block at 0x014B10C0, 44 bytes long.
Data: << > 3C 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00
dlgprop.cpp(947) : {75} normal block at 0x014B1440, 160 bytes long.
Data: <( @ s > 28 00 00 00 81 00 00 00 00 00 40 00 F0 0C 73 00
array_p.cpp(110) : {74} normal block at 0x014B1510, 20 bytes long.
Data: < C: C: D: E: > 04 43 3A 01 F8 43 3A 01 EC 44 3A 01 E0 45 3A 01
strcore.cpp(118) : {72} normal block at 0x014B00E0, 29 bytes long.
Data: < Main> 01 00 00 00 10 00 00 00 10 00 00 00 4D 61 69 6E
C:\Projects\formview\formviewView.cpp(163) : {71} client block at 0x013A4260, subtype 0, 1384 bytes long.
a CTabDataSheet object at $013A4260, 1384 bytes long
Object dump complete.
The thread 0xFFFA5F43 has exited with code 0 (0x0).
The program 'C:\Projects\formview\Debug\formview.exe' has exited with code 0 (0x0).
GeneralRe: Memory Leaks Pin
Matt Philmon4-Dec-00 17:02
Matt Philmon4-Dec-00 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.