|
// MyCell - version 1.0
// Written by Yanxueming <yanxm2003@hotmail.com>
// Copyright (C) 2006-2006
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
#pragma once
class DeleteGdiObjPolicy
{
protected:
void DelGdiObject(HGDIOBJ obj)
{
DeleteObject(obj);
}
};
class DeleteGdiObjDummyPolicy
{
protected:
void DelGdiObject(HGDIOBJ obj)
{
}
};
template<class GdiObjDelPolicy=DeleteGdiObjPolicy>
class GdiSelectObject : public GdiObjDelPolicy
{
HDC hDC_;
HGDIOBJ oldObj_;
public:
GdiSelectObject(HDC hDC,HGDIOBJ hObj):hDC_(hDC)
{
oldObj_=::SelectObject(hDC,hObj);
}
void SelectObject(HGDIOBJ hObj)
{
GdiObjDelPolicy::DelGdiObject(::SelectObject(hDC_,oldObj_));
oldObj_=::SelectObject(hDC_,hObj);
}
~GdiSelectObject()
{
GdiObjDelPolicy::DelGdiObject(::SelectObject(hDC_,oldObj_));
}
};
typedef GdiSelectObject<DeleteGdiObjDummyPolicy> GdiSelectObjectPlain;
typedef GdiSelectObject<> GdiSelectObjectAutoDel;
class GDISetROP2
{
HDC hDC_;
int fnDrawMode_;
public:
GDISetROP2(HDC hdc,int fnDrawMode):hDC_(hdc)
{
fnDrawMode_=SetROP2(hDC_,fnDrawMode);
}
~GDISetROP2()
{
SetROP2(hDC_,fnDrawMode_);
}
};
|
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.
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.