home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4327 < prev    next >
Encoding:
Internet Message Format  |  1992-12-18  |  1.8 KB

  1. Path: sparky!uunet!lax.pe-nelson.com!lax!twbrown
  2. From: twbrown@PE-Nelson.COM (Tom W. Brown)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Re: Problems with Clipping Regions
  5. Message-ID: <721@lax.lax.pe-nelson.com>
  6. Date: 17 Dec 92 23:54:39 GMT
  7. References: <1992Dec16.152731.45692@kuhub.cc.ukans.edu> <724545535snz@chrism.demon.co.uk>
  8. Sender: news@lax.pe-nelson.com
  9. Organization: PE-Nelson
  10. Lines: 35
  11.  
  12. In article <724545535snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes:
  13. |> Are you selecting the old clip region before deleting the one you created?
  14. |> Remember, Windows won't let you delete an object that's currently selected
  15. |> in a DC.
  16.  
  17. Unlike the other GDI objects, a copy of the region is placed in the DC so
  18. you won't get an error if you delete the region.
  19.  
  20.  
  21. |> What you should be doing is:
  22. |> 
  23. |>     ClipRegion = CreateRegion( ..... );
  24. |>     OldRegion = SelectObject( hDC, ClipRegion );
  25. |>     .....
  26. |>     SelectObject( hDC, OldRegion );
  27. |>     DeleteObject( ClipRegion );
  28. |> 
  29. |> That should work OK.
  30.  
  31. Nope -- in a fit of perversity someone at Microsoft decided that for
  32. regions, and regions only, the return value from SelectObject() should
  33. _not_ be the old region, but should be a value indicating what type
  34. of region is being installed.
  35.  
  36. You must (as far as I know) use SaveDC/RestoreDC around your own
  37. clipping code in order to ensure that the old region is restored, unless
  38. you know (by virtue of initializing a default DC) what region to put
  39. back in the DC.
  40.  
  41.  
  42. ----------------------------------------------------------------------------
  43. Tom Brown               |  "She turned me into a newt...
  44. PE Nelson Systems       |                                  ... I got better"
  45. twbrown@pe-nelson.com   |                    Monty Python and the Holy Grail
  46. ----------------------------------------------------------------------------
  47.