CombineRgn not working

橙三吉。 提交于 2019-12-25 01:43:37

问题


I have two region say rgn1 and rgn2. I wanted to combine both of them using CombineRgn function. So I write -

if CombineRgn(rgnMain,rgn1,rgn2,RGN_OR) = error then
         ShowMessage('error'); 

Its giving return value as ERROR.

I have tested that rgn1 and rgn2 are correct region.
Thank You.


回答1:


Have you also initialised rgnMain? Somewhat counterintuitively (but as described in the documentation for CombineRgn()) the destination/output region must exist in order to receive the required combination of the two input regions, but it can be an entirely empty region:

rgnMain := CreateRectRgn(0, 0, 0, 0);
if CombineRgn(rgnMain, rgn1, rgn2, RGN_OR) ... then
  // etc

If you wish to avoid having to create an entirely separate region then it is acceptable and possible to specify one of the input regions as the destination region (by definition an input region must be an existing, valid region so this avoids having to separately initialise a new destination region):

if CombineRgn(rgn1, rgn1, rgn2, RGN_OR) ... then
  // etc


来源:https://stackoverflow.com/questions/3090645/combinergn-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!