Click here to Skip to main content
15,896,915 members
Articles / Multimedia / GDI

GDI Leak Detector - A special debugger to detect and locate GDI leaks

Rate me:
Please Sign up or sign in to vote.
2.79/5 (20 votes)
5 May 2014CPOL1 min read 223.5K   1.5K   31  
A special debugger to detect and locate GDI leaks, with source code.
// GdiLeakDetectorDlg.h
//

#pragma once

#include <map>
#include <vector>
#include "MyEdit.h"
#include "LineNumEdit.h"

// CGdiLeakDetectorDlg
class CGdiLeakDetectorDlg : public CDialog
{
public:
	CGdiLeakDetectorDlg(CWnd* pParent = NULL);
	~CGdiLeakDetectorDlg();

	enum { IDD = IDD_GDILEAKDETECTOR_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);


protected:
	HICON m_hIcon;
	std::map<DWORD, std::vector<char*> > m_HandleInfo;
	CString m_FileName;
	CMyEdit m_ExeFileEdit;
	CLineNumEdit m_LineNumEdit;

	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedBrowsefile();
	afx_msg void OnNMClickLeaklist(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnLbnDblclkCallstack();
	afx_msg void OnBnClickedSave();
	afx_msg LRESULT OnKickIdle(WPARAM wParam, LPARAM ICount);
	afx_msg LRESULT OnGoLine(WPARAM, LPARAM);
	DECLARE_MESSAGE_MAP()
private:
	void ShowDebugString(LPCTSTR message);
	BOOL CreateRemoteThread(HANDLE hProcess);
	void GetLeakList();
	void ShowLeakList();
	void ShowFile(const CString & fileName, int lineNum);
};

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
China China
I am a student from Shanghai Tongji University.

Comments and Discussions