Click here to Skip to main content
12,956,724 members (58,391 online)
Click here to Skip to main content


82 bookmarked
Posted 8 Jan 2001

Bridge Pattern - Bridging the gap between Interface and Implementation

, 8 Jan 2001
This article discusses the Bridge Pattern, what it is, why and when it is needed.
// BridgeView.cpp : implementation of the CBridgeView class

#include "stdafx.h"
#include "Bridge.h"

#include "BridgeDoc.h"
#include "BridgeView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

// CBridgeView


BEGIN_MESSAGE_MAP(CBridgeView, CScrollView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!

// CBridgeView construction/destruction

	// TODO: add construction code here



BOOL CBridgeView::PreCreateWindow(CREATESTRUCT& cs)
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CScrollView::PreCreateWindow(cs);

// CBridgeView drawing

void CBridgeView::OnDraw(CDC* pDC)
	CBridgeDoc* pDoc = GetDocument();

	CImage	* pImage = pDoc->m_pImage;

	if( pImage != NULL )
		CRect	Rect( 0, 0, pImage->GetImageWidth(), pImage->GetImageHeight() );

		pImage->Show( this, ( WPARAM ) & Rect );

// CBridgeView diagnostics

#ifdef _DEBUG
void CBridgeView::AssertValid() const

void CBridgeView::Dump(CDumpContext& dc) const

CBridgeDoc* CBridgeView::GetDocument() // non-debug version is inline
	return (CBridgeDoc*)m_pDocument;
#endif //_DEBUG

// CBridgeView message handlers

void CBridgeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
	CSize		sizeTotal( 1, 1 );
	CImage	* pImage = GetDocument()->m_pImage;

	// Step 1 - Set scroll size
	if( pImage != NULL )
	{ = pImage->GetImageWidth(); = pImage->GetImageHeight();
	SetScrollSizes( MM_TEXT, sizeTotal );
	// Step 2 - Refresh view

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

T. Kulathu Sarma
Switzerland Switzerland
Kulathu Sarma is working as a Technology Manager for GoldAvenue, a company based in Geneva, Switzerland and responsible for supporting e-business initiatives of GoldAvenue in B2B and B2C Sectors. He has been programming in C/C++ for 9 years and actively working on Patterns for the past 5 years.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 9 Jan 2001
Article Copyright 2001 by T. Kulathu Sarma
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid