Click here to Skip to main content
Click here to Skip to main content

Using CResizablePage In a CFormView

By , 16 Apr 2001
 

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)

About the Author

John Simmons / outlaw programmer
Software Developer (Senior)
United States United States
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 1groupCSawant12 Jul '09 - 1:25 
.................
Generalcformview ..... please .. please .. hepl me !sussAnonymous7 Jul '03 - 18:49 
i have created an apliction in cformview. by pressing a button i want to create a window(view window) with scroll bars and i have to display data in the view window. after i have verified the data i want to close the view window. I have to go back to the formviw. how can i implement this?
very urgently needed the answer
GeneralAdding Controls Dynamically to CFormViewmemberMuhammad Yousaf7 May '03 - 8:43 
I want to make a application that supports form creation(a form editor), like in MS Access or in VC++ Dialog Editor, like the VB form editor. i want to add controls dynamically to CFormView . and want to give the user the ability to move, resize or select the control in design mode. Please if any one can help me i would be very greatfull to him/her.
GeneralFit a dialog into a View of a WindowmemberAnonymous17 Apr '02 - 8:27 
I have a fixed size dialog.
 
I have list of tree items on the left view and when I click one of the nodes I want to display the dialog in the right view
 
with the condition that if the size of the dialog is bigger than the view then I'll have to provide the scroll bars to navigate.
 
I don't want to change the size of the dialogs at all.
 
My dialogs are all modal dialogs. I'm using splitter window to create two separate view.
 
Left side is the tree view and right side is the form view.
 
I want all my controls in the dialog in tact.
 
My view on the right side is a form view.
 
Can you provide some help regarding this.
 
Thanks
QuestionDemo Broken?memberStephen Woods1 Apr '02 - 19:13 
I have built the demo but it doesn't seem to work. A lot of code is commented out???
 
Stephen Woods
Reserve Bank of Australia
Sydney NSW Australia
GeneralMemory Leaksmemberrstewart271044 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 LeaksmemberMatt Philmon4 Dec '00 - 17:02 
Just fix your CFormviewView destructor to clean up it's DataSheet:
 
CFormviewView::~CFormviewView()
{
DeleteDataSheet();
}

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 17 Apr 2001
Article Copyright 2000 by John Simmons / outlaw programmer
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid