Article View: comp.os.ms-windows.programmer.misc
Article #2002Re: Problems with Clipping Regions
From: Tom W. Brown
Date: Thu, 17 Dec 1992 23:54
Date: Thu, 17 Dec 1992 23:54
35 lines
1920 bytes
1920 bytes
In article <724545535snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes: |> Are you selecting the old clip region before deleting the one you created? |> Remember, Windows won't let you delete an object that's currently selected |> in a DC. Unlike the other GDI objects, a copy of the region is placed in the DC so you won't get an error if you delete the region. |> What you should be doing is: |> |> ClipRegion = CreateRegion( ..... ); |> OldRegion = SelectObject( hDC, ClipRegion ); |> ..... |> SelectObject( hDC, OldRegion ); |> DeleteObject( ClipRegion ); |> |> That should work OK. Nope -- in a fit of perversity someone at Microsoft decided that for regions, and regions only, the return value from SelectObject() should _not_ be the old region, but should be a value indicating what type of region is being installed. You must (as far as I know) use SaveDC/RestoreDC around your own clipping code in order to ensure that the old region is restored, unless you know (by virtue of initializing a default DC) what region to put back in the DC. ---------------------------------------------------------------------------- Tom Brown | "She turned me into a newt... PE Nelson Systems | ... I got better" twbrown@pe-nelson.com | Monty Python and the Holy Grail ----------------------------------------------------------------------------
Technical Details
Message-ID:
<721@lax.lax.pe-nelson.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrownReferences:
<1992Dec16.152731.45692@kuhub.cc.ukans.edu> <724545535snz@chrism.demon.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!lax.pe-nelson.com!lax!twbrown From: twbrown@PE-Nelson.COM (Tom W. Brown) Newsgroups: comp.os.ms-windows.programmer.misc Subject: Re: Problems with Clipping Regions Message-ID: <721@lax.lax.pe-nelson.com> Date: 17 Dec 92 23:54:39 GMT References: <1992Dec16.152731.45692@kuhub.cc.ukans.edu> <724545535snz@chrism.demon.co.uk> Sender: news@lax.pe-nelson.com Organization: PE-Nelson Lines: 35