Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » GDI » General » Downloads
 
Add your own
alternative version

Barry's Screen Capture

, 11 Jan 2003
An article showing methods of screen capture
capit_demo.zip
CapIT.exe
capit_src.zip
CapIT.dsp
CapIT.dsw
RES
CapITDoc.ico
CapIT.ico
Toolbar.bmp
Camera.ico
Thumbs.db
// CapITView.h : interface of the CCapITView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CAPITVIEW_H__8B113E12_CDDB_414F_B9B9_B035CE18283C__INCLUDED_)
#define AFX_CAPITVIEW_H__8B113E12_CDDB_414F_B9B9_B035CE18283C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#define PW_WINDOW        1 
#define PW_CLIENT        2 

#define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left) 
#define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top) 


class CCapITView : public CScrollView
{
protected: // create from serialization only
	CCapITView();
	DECLARE_DYNCREATE(CCapITView)

// Attributes
public:
	CCapITDoc* GetDocument();

	BOOL gbIsCaptured;
	BOOL gbDrawImage;

	CWnd* oldCap;
	HCURSOR m_hcurOld;

	HBITMAP     ghBitmap;
	HPALETTE    ghPal;
	BOOL        gbNewRect;
	CPoint      gpStartPoint;
	CPoint      gpEndPoint;
	CRect       grCapRect;

	CRect       grRcPrev;
	BOOL        gbIsMarking;
	BOOL       	gbCaptureMode;

	CWnd*       gCaptureWnd;

	BOOL        m_bHookSetup;

	CWnd*       gMainWnd;

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCapITView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	protected:
	virtual void OnInitialUpdate(); // called first time after construct
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	//}}AFX_VIRTUAL

// Implementation
public:
	void CaptureDesktop();
	void ClearCapture();
	void CaptureClient();
	void CaptureControl();
	void CaptureWindow();
	void UpdateCaptureStatus(BOOL bCaptured);
	
	void SetupHookProc();
    static void UpdateStatusbar(COLORREF cr, BOOL bShowCodes , BOOL bShowPosition);
	void CaptureClientArea(CWnd* wnd);
	void WindowCapture(HWND wnd);
	virtual ~CCapITView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	int PalEntriesOnDevice(HDC hDC);
	HDIB ChangeBitmapFormat(HBITMAP hBitmap, WORD wBitCount, DWORD dwCompression, HPALETTE hPal, HWND hwnd);
	HANDLE AllocRoomForDIB(BITMAPINFOHEADER bi, HBITMAP hBitmap , HWND hwnd);
	HPALETTE GetSystemPalette(HWND hwnd);
	WORD PaletteSize (VOID FAR * pv);
	WORD DibNumColors (VOID FAR * pv);

	WORD SaveDIB(HDIB hDib, LPSTR lpFileName);
	void ReallyGetClientRect(CWnd* wnd , LPRECT lpRect);
	void SetupScrollBars(CWnd* wnd , WORD cxBitmap, WORD cyBitmap);
	void DoSize(CWnd* wnd , HBITMAP ghBitmap);
	BOOL PaintBitmap(HDC hDC, LPRECT lpDCRect, HBITMAP hDDB ,  LPRECT lpDDBRect, HPALETTE hPal);
	HBITMAP CopyScreenToBitmap(LPRECT lpRect);
	HBITMAP CopyWindowToBitmap(CWnd* wnd , HWND hWnd, WORD fPrintArea );


// Generated message map functions
protected:
	//{{AFX_MSG(CCapITView)
	afx_msg void OnCaptureChanged(CWnd *pWnd);
	afx_msg void OnDestroy();
	afx_msg void OnSaveFile();
	afx_msg void OnUpdateSaveFile(CCmdUI* pCmdUI);
	afx_msg void OnColorcode();
	afx_msg void OnUpdateColorcode(CCmdUI* pCmdUI);
	afx_msg void OnTrackpos();
	afx_msg void OnUpdateTrackpos(CCmdUI* pCmdUI);

	afx_msg void OnClear();
	afx_msg void OnUpdateClear(CCmdUI* pCmdUI);

	afx_msg void OnHideWindow();
	
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in CapITView.cpp
inline CCapITDoc* CCapITView::GetDocument()
   { return (CCapITDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CAPITVIEW_H__8B113E12_CDDB_414F_B9B9_B035CE18283C__INCLUDED_)

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.

License

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

Share

About the Author

Barretto VN

India India
Nothing to boast about

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 12 Jan 2003
Article Copyright 2003 by Barretto VN
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid