Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Marquee Progress Control Pin
Eric Olstad25-Oct-10 8:10
Eric Olstad25-Oct-10 8:10 
QuestionGetting response from aspx page Pin
Pryabu8-Apr-10 20:35
Pryabu8-Apr-10 20:35 
AnswerRe: Getting response from aspx page Pin
eusto9-Apr-10 2:28
eusto9-Apr-10 2:28 
AnswerRe: Getting response from aspx page Pin
daveyerwin9-Apr-10 13:55
daveyerwin9-Apr-10 13:55 
GeneralRe: Getting response from aspx page Pin
Pryabu11-Apr-10 18:08
Pryabu11-Apr-10 18:08 
GeneralRe: Getting response from aspx page Pin
daveyerwin12-Apr-10 12:59
daveyerwin12-Apr-10 12:59 
QuestionScrolling size on zooming Pin
Anu_Bala8-Apr-10 18:31
Anu_Bala8-Apr-10 18:31 
AnswerRe: Scrolling size on zooming Pin
kylur9-Apr-10 9:15
kylur9-Apr-10 9:15 
Anu,

Try this:

// header file: "MyScrollView.h"

#pragma once

class CDoc;
class CMyScrollView : public CScrollView
{
	DECLARE_DYNCREATE(CMyScrollView)
	DECLARE_MESSAGE_MAP()

public:
	CMyScrollView();
	virtual ~CMyScrollView();

	CDoc* GetDocument();

protected:
	virtual void OnDraw(CDC* pDC);
	virtual void OnInitialUpdate();

private:
	int Height;
	int Width;
	CBitmap* Bitmap;
	CDC* MemDC;
};


// implementation file: "MyScrollView.cpp"
#include "stdafx.h"
#include "MyScrollView.h"

IMPLEMENT_DYNCREATE(CMyScrollView, CScrollView)
BEGIN_MESSAGE_MAP(CMyScrollView, CScrollView)
END_MESSAGE_MAP()

CMyScrollView::CMyScrollView() : 
	Bitmap(new CBitmap), Width(1000), Height(200), MemDC(new CDC)
{
	MemDC->CreateCompatibleDC(NULL);
}

CMyScrollView::~CMyScrollView()
{
	delete Bitmap;
	delete MemDC;
}

CDoc* CMyScrollView::GetDocument()
{ return (CDoc*)m_pDocument; }

void CMyScrollView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();
	
	GetParentFrame()->SetWindowText("CMyScrollView");

	CClientDC dc(this);
	Bitmap->CreateCompatibleBitmap(&dc, Width, Height);
	Bitmap->SetBitmapDimension(Width, Height);

	CBitmap* OldBitmap = MemDC->SelectObject(Bitmap);

	MemDC->PatBlt(0, 0, Width, Height, BLACKNESS);
	CPen WhitePen(PS_SOLID, 1, RGB(255,255,255));
	CPen* 	OldPen = MemDC->SelectObject(&WhitePen);
	MemDC->MoveTo(0, 0);				// ie top left
	MemDC->LineTo(Width, Height);		// ie bottom right
	MemDC->MoveTo(Width, 0);			// ie top right
	MemDC->LineTo(0, Height);			// ie bottom left
	MemDC->SelectObject(OldPen);

	CPen RedPen(PS_SOLID, 1, RGB(255,0,0));
	OldPen = MemDC->SelectObject(&RedPen);
	MemDC->Rectangle(0,0,10,10);		// red rect in top left
	MemDC->SelectObject(OldPen);

	CPen GreenPen(PS_SOLID, 1, RGB(0,255,0));
	OldPen = MemDC->SelectObject(&GreenPen);
	MemDC->Ellipse(Width-20, Height-20, Width, Height);	// green circle bottom right
	MemDC->SelectObject(OldPen);

	CRect Rect(0,Height-20,20,Height);
	CBrush Brush(RGB(0,0,255));
	MemDC->FillRect(Rect, &Brush);		// blue rect in bottom left

	MemDC->SelectObject(OldBitmap);

	SetScrollSizes(MM_TEXT, CSize(Width, Height));
	ResizeParentToFit(TRUE);
}

void CMyScrollView::OnDraw(CDC* pDC)		// works!
{
	if (Bitmap)
	{
		pDC->SetStretchBltMode( COLORONCOLOR );

		CBitmap* OldBitmap = MemDC->SelectObject(Bitmap);

		pDC->BitBlt( // l, t, w, h
			0, 0, Width, Height,
			MemDC, 
			0, 0,
			SRCCOPY);

		MemDC->SelectObject(OldBitmap);
	}
}

QuestionHow do I use std::stringstream to format data to a string like sprintf "%02d"[modified] Pin
akira328-Apr-10 17:51
akira328-Apr-10 17:51 
AnswerRe: How do I use std::stringstream to printf "%02d" Pin
KingsGambit8-Apr-10 18:36
KingsGambit8-Apr-10 18:36 
AnswerRe: How do I use std::stringstream to printf "%02d" Pin
Gwenio8-Apr-10 18:38
Gwenio8-Apr-10 18:38 
QuestionHow to use a Dialog Template as an item in another Dialog. Pin
Bram van Kampen8-Apr-10 15:06
Bram van Kampen8-Apr-10 15:06 
AnswerRe: How to use a Dialog Template as an item in another Dialog. Pin
cmk8-Apr-10 15:53
cmk8-Apr-10 15:53 
QuestionLPWSTR / Win32 Pin
Fareed Rizkalla8-Apr-10 7:10
Fareed Rizkalla8-Apr-10 7:10 
AnswerRe: LPWSTR / Win32 Pin
PJ Arends8-Apr-10 7:47
professionalPJ Arends8-Apr-10 7:47 
AnswerRe: LPWSTR / Win32 Pin
CPallini8-Apr-10 9:43
mveCPallini8-Apr-10 9:43 
AnswerRe: LPWSTR / Win32 Pin
Joe Woodbury8-Apr-10 10:57
professionalJoe Woodbury8-Apr-10 10:57 
GeneralRe: LPWSTR / Win32 Pin
Emilio Garavaglia8-Apr-10 21:15
Emilio Garavaglia8-Apr-10 21:15 
GeneralRe: LPWSTR / Win32 Pin
CPallini8-Apr-10 21:24
mveCPallini8-Apr-10 21:24 
GeneralRe: LPWSTR / Win32 Pin
Emilio Garavaglia8-Apr-10 21:42
Emilio Garavaglia8-Apr-10 21:42 
GeneralRe: LPWSTR / Win32 Pin
CPallini8-Apr-10 21:57
mveCPallini8-Apr-10 21:57 
GeneralRe: LPWSTR / Win32 Pin
Fareed Rizkalla8-Apr-10 22:26
Fareed Rizkalla8-Apr-10 22:26 
GeneralRe: LPWSTR / Win32 Pin
Eugen Podsypalnikov8-Apr-10 23:09
Eugen Podsypalnikov8-Apr-10 23:09 
GeneralRe: LPWSTR / Win32 Pin
Fareed Rizkalla8-Apr-10 23:25
Fareed Rizkalla8-Apr-10 23:25 
GeneralRe: LPWSTR / Win32 Pin
Eugen Podsypalnikov8-Apr-10 23:32
Eugen Podsypalnikov8-Apr-10 23:32 

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.