CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.
Biz Resources
Network Security Services
VoIP
CRM Software

jobs.internet.com

internet.commerce
Partners & Affiliates
Find Software
Free Business Cards
Career Education
Promotional Golf
Compare Prices
Dental Insurance
Domain registration
Shop
Computer Deals
Boat Donations
Shop Online
Home Improvement
Calling Cards
Memory Upgrades


RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Windows & Dialogs >> Dialog

Project Management Guide: Developing a Web Site. Best Practices, Tips and Strategies. Download Exclusive eBook Now.

Creating a View in Dialog (An easy way).
Rating:

Z Mohamed Mustafa (view profile)
February 19, 2002


(continued)

Access FREE HP Server Solutions Tools:
Access FREE HP Server Solutions Tools:
Whitepaper:
Continuous Real-time Data Protection and Disaster Recovery

Whitepaper:
Virtualization--It's Not Just for Enterprises Anymore

Whitepaper:
Rightsizing Blades for the Mid-market

Whitepaper:
VMware Infrastructure 3--Planning



Download these IBM resources today!
e-Kit: IBM Rational Systems Development Solution
With systems teams under so much pressure to develop products faster, reduce production costs, and react to changing business needs quickly, communication and collaboration seem to get lost. Now, theres a way to improve product quality and communication.

Webcast: Asset Reuse Strategies for Success--Innovate Don't Duplicate!
Searching for, identifying, updating, using and deploying software assets can be a difficult challenge.

eKit: Rational Build Forge Express
Access valuable resources to help you increase staff productivity, compress development cycles and deliver better software, fast.

Download: IBM Data Studio v1.1
Effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life.

eKit: Rational Asset Manager
Learn how to do more with your reusable assets, learn how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse.

Environment developed: VC6 Win 2K]

To create a view you normally follow the Microsoft's Document template model. (i.e) Single document template or multi doc template. You can pass three runtime classes to the constructors:

CSingleDocTemplate( UINT nIDResource,
                    CRuntimeClass* pDocClass,
                    CRuntimeClass* pFrameClass,
                    CRuntimeClass* pViewClass );

OR

CMultiDocTemplate( UINT nIDResource,
                   CRuntimeClass* pDocClass,
                   CRuntimeClass* pFrameClass,
                   CRuntimeClass* pViewClass );

When the document template is added, frame (child for MDI , main frame for SDI), document, and a view is created dynamically and added to the application's document template list.

But some times you may need to create a view without using the default document template classes. For instance, if you are to create a view in dialog, you can not use the regular way of document template. In those cases you can use the following method:

BOOL CVwindlgDlg::OnInitDialog()
{

     ...

  CCreateContext pContext;
  /**
  * Note:CDialig derived pointer is converted to
  * CWnd pointer (a common base class for CDialog and CFrameWnd).
  * Thus casting it back to CFrameWnd is also easy.
  */
  CWnd* pFrameWnd = this;

  pContext.m_pCurrentDoc = new CMyDocument;
  pContext.m_pNewViewClass = RUNTIME_CLASS(CMyVw);
  CMyVw *pView =
     (CMyVw *) ((CFrameWnd*)pFrameWnd)->CreateView(&pContext);
  ASSERT(pView);
  pView->ShowWindow(SW_NORMAL);
  /**
  * After a view is created, resize that to
  * have the same size as the dialog.
  */
  CRect rectWindow;
  GetWindowRect(rectWindow);
  /**
  * Leave a little space for border and title...
  */
  rectWindow.right += 15;
  rectWindow.top   -= 10;
  pView->MoveWindow(rectWindow);
  CString str(AfxGetApp()->m_lpCmdLine);
  /**
  * Note: "CMyVw" is a CHTMLView derived class to add some
  *       spice to the view, I have provided a HTML page
  *       to which it navigates when the dialog is up.
  */
  char strPath[255];
  ::GetCurrentDirectory(255,(LPSTR)(LPCSTR)strPath);
  strcat(strPath,"\\defaultpage.html");
  pView->Navigate(strPath);

         ....

  return TRUE;  // return TRUE  unless you set the
                // focus to a control
}

Downloads

Download demo project - 6 KB
Download source - 38 KB

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

Five Trends for Application Development. Download Your Complimentary Report. Exclusive. Act Now.
Developing Intelligent Communications? Visit the Avaya DevConnect Center on DevX.
Whitepaper: Enterprise Information Integration--Deployment Best Practices for Low-Cost Implementation
Flash Demo: Learn how IBM Information Server Blade is easy to manage, highly scalable and efficient.
Generate Complete .NET Web Apps in Minutes . Download Iron Speed Designer today.


RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
Can draw using old pDC-> but not with GDI+ . Why ? - Mike Pliam (03/02/2007)
Re : 2 little improvements - Sharukh (01/25/2005)
2 little improvements - activeapp (07/09/2004)
If your application don't have document class... - Wonjae Jang (03/05/2004)
Re: how to add CDocument class to a Dialog - Legacy CodeGuru (02/10/2004)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES