home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / ctlhtmlc / ctlhtml.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-11  |  3.5 KB  |  124 lines

  1. /*---------------------------------------------------------------------------*\
  2.  | CtlHTML DemoView.cpp - CtlHTML(tm) Control Library Test Program           |
  3.  |                        Windmill Point Software, Alburg, VT 05440          |
  4.  |                        Copyright (c) 1999, Windmill Point Software        |
  5.  |                        All Rights Reserved.                               |
  6. \*---------------------------------------------------------------------------*/
  7.  
  8. #include "stdafx.h"
  9. #include "CtlHTML Demo.h"
  10. #include "CtlHTML DemoDoc.h"
  11. #include "CtlHTML DemoView.h"
  12. #include "..\CtlHtml.h"
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CCtlHTMLDemoView
  22.  
  23. IMPLEMENT_DYNCREATE(CCtlHTMLDemoView, CFormView)
  24.  
  25. BEGIN_MESSAGE_MAP(CCtlHTMLDemoView, CFormView)
  26.     //{{AFX_MSG_MAP(CCtlHTMLDemoView)
  27.     ON_WM_SIZE()
  28.     //}}AFX_MSG_MAP
  29.    ON_WM_CTLCOLOR()
  30. END_MESSAGE_MAP()
  31.  
  32. CCtlHTMLDemoView::CCtlHTMLDemoView()
  33.     : CFormView(CCtlHTMLDemoView::IDD)
  34. {
  35.     //{{AFX_DATA_INIT(CCtlHTMLDemoView)
  36.     //}}AFX_DATA_INIT
  37. }
  38.  
  39. CCtlHTMLDemoView::~CCtlHTMLDemoView()
  40. {
  41. }
  42.  
  43. void CCtlHTMLDemoView::DoDataExchange(CDataExchange* pDX)
  44. {
  45.     CFormView::DoDataExchange(pDX);
  46.     //{{AFX_DATA_MAP(CCtlHTMLDemoView)
  47.     //}}AFX_DATA_MAP
  48. }
  49.  
  50. BOOL CCtlHTMLDemoView::PreCreateWindow(CREATESTRUCT& cs)
  51. {
  52.     return CFormView::PreCreateWindow(cs);
  53. }
  54.  
  55. void CCtlHTMLDemoView::OnInitialUpdate()
  56. {
  57.     CFormView::OnInitialUpdate();
  58. //    GetParentFrame()->RecalcLayout();
  59. //    ResizeParentToFit();
  60.  
  61.    CWnd *pStatic;
  62.    CRect clientRect, controlRect;
  63.    CSize controlSize;
  64.  
  65.    // adjust the text control size to be the width of the parent dialog, minus the border
  66.    if ((pStatic = GetDlgItem(IDC_TEXT)) != 0)
  67.    {
  68.       GetWindowRect(&clientRect);
  69.       pStatic->GetWindowRect(&controlRect);
  70.       controlSize.cx = clientRect.Width()  - 2 * (controlRect.left - clientRect.left);
  71.       controlSize.cy = clientRect.Height() - 2 * (controlRect.top  - clientRect.top);
  72.       pStatic->SetWindowPos(0, 0, 0, controlSize.cx, controlSize.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
  73.    }
  74.  
  75.    // subclass the dialog
  76.    CtlHTMLSubclassDialog(m_hWnd);
  77. }
  78.  
  79. HBRUSH CCtlHTMLDemoView::OnCtlColor (CDC *pDC, CWnd *pWnd, UINT nCtlColor)
  80. {
  81.    return GetSysColorBrush(COLOR_WINDOW);
  82. }
  83.  
  84. void CCtlHTMLDemoView::OnSize(UINT nType, int cx, int cy) 
  85. {
  86.     CFormView::OnSize(nType, cx, cy);
  87.  
  88.    CWnd *pStatic;
  89.    CRect clientRect, controlRect;
  90.    CSize controlSize;
  91.  
  92.    // adjust the text control size to be the width of the parent dialog, minus the border
  93.    if ((pStatic = GetDlgItem(IDC_TEXT)) != 0)
  94.    {
  95.       GetWindowRect(&clientRect);
  96.       pStatic->GetWindowRect(&controlRect);
  97.       controlSize.cx = clientRect.Width()  - 2 * (controlRect.left - clientRect.left);
  98.       controlSize.cy = clientRect.Height() - 2 * (controlRect.top  - clientRect.top);
  99.       pStatic->SetWindowPos(0, 0, 0, controlSize.cx, controlSize.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
  100.       pStatic->GetClientRect(&controlRect);
  101.    }
  102. }
  103.  
  104. #ifdef _DEBUG
  105.  
  106. void CCtlHTMLDemoView::AssertValid() const
  107. {
  108.     CFormView::AssertValid();
  109. }
  110.  
  111. void CCtlHTMLDemoView::Dump(CDumpContext& dc) const
  112. {
  113.     CFormView::Dump(dc);
  114. }
  115.  
  116. CCtlHTMLDemoDoc* CCtlHTMLDemoView::GetDocument() // non-debug version is inline
  117. {
  118.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCtlHTMLDemoDoc)));
  119.     return (CCtlHTMLDemoDoc*)m_pDocument;
  120. }
  121.  
  122. #endif //_DEBUG
  123.  
  124.