This project is read-only.

1. CSelectGoToDc for HRGN is disabled:

Regions are also gdi objects. However they would never be 'selected' in to a device-context realy, An HRGN object could be deleted as long as you feel you won't need it again. Normatively, An HRGN should be 'select into/out from' a DC by calling SelectClipRgn function instead of SelectObject.

2. Gain control access to another GDI object with a CGdiObjMgr object:

During handling one painting procedure, If you plan to use a CGdiObjMgr object manage several objects one by one, rather than create them all that hooked by each own CGdiObjMgr objects and let them wait for their turn, (For example, target to save GDI resource for painting) Place your code like this:
CGdiObjMgr<HPEN> opn;

opn = CreatePen(...);
// Follow this rule you have to:
    HPEN hpnDel = opn;

    opn = [Handle of the other Pen]; // LN 1.
    DeleteObject(hpnDel); // Assume you plan to delete the opn.
Executing LN1 causes the resource related to the Pen object that opn managed back to its default state and automatically reseting any potential DC object-selections.

3. A CGdiObjMgr object can be created before and after the painting procedure being called(even when not be called), But CDCMgr objects can't (except CResCompatibleDCMgr::CDeploy objects).

4. A CGdiObjMgr object can be defined before or after its CSelectGoToDc selecter. However, BEFORE its CSelectGoToDc selector is recommended because the performance will not be down by looping obj-selection-chain.

5. If you don't like GDI object deleted by CGdiObjMgr' destructor(Generaly it shouldn't happen in a well-designed projects; But it may happen in special cases. For example, a dialog-box may take its own font resource that is neither system-default nor explicitly created by user), Declare an inherited class from the CGdiObjMgr class and do things like in Point 2 in the destructor of that inherited class:

Assume the class CYourFntMgr is for Font management:
class CYourFntMgr : public ::nsAssistantEnhX::nsAutoGdiProcessor::CGdiObjMgr<HFONT>
	bool operator = (HFONT hGdiobj)
		return(::nsAssistantEnhX::nsAutoGdiProcessor::CGdiObjMgr<HFONT>::operator = (hGdiobj));

	CYourFntMgr(void):... { ... };
		*this = NULL;

6. Using CDCMgr templates properly:

CPaintClientDCMgr is for BeginPaint/EndPaint;
CClientDCMgr is for GetDC/ReleaseDC;
CCompatibleDCMgr and CResCompatibleDCMgr is for CreateCompatibleDC/DeleteDC;
CDCMoutedMgr is prepared for NATIVE hdc handle! You must NOT use any CDCMgr class in this library as its constructor's parameter!

7. In your code, Don't mess your code the direct GDI/DC API calls with this library. This library is manager(as its name, assistant), not sealer. If you write your own function that accept DC as the parameter(s), don't use HDC as the parameter(s) type, use the original template class type/the CDCBaseMgr template class type that inherited by original template class/the CDCBaseMgr template class' sub-object type that inherited by original template class(by calling SafeExtractInherited()).

Last edited Mar 22, 2011 at 4:55 PM by UnitUniverse, version 8


No comments yet.