问题
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