ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

Can I have parameters of type typeHIRect instead of type typeQDRectangle in my kEventControlBoundsChanged message handler?


Q: Is there anyway I can have parameters of type typeHIRect instead of type typeQDRectangle in my kEventControlBoundsChanged message handler so that I don't have to convert all the time?

A: As a matter of fact, you can, even though it's not been documented yet in the headers. An automatic conversion occurs for the new type typeHIRect introduced in Mac OS X 10.2 (aka Jaguar) so all the Carbon Event message handlers which are getting or setting parameters of type typeQDRectangle (kEventControlGetOptimalBounds, kEventControlGetPartBounds, etc.) can be asked for type typeHIRect instead (and vice versa).

If you had the following code:



Listing 1. Getting typeQDRectangle parameter.


Rect currentBounds;
GetEventParameter(theEvent, kEventParamCurrentBounds, typeQDRectangle,
                  NULL, sizeof(Rect), NULL, &currentBounds);


you can now write instead:



Listing 2. Getting typeHIRect parameter.


HIRect currentHIBounds;
GetEventParameter(theEvent, kEventParamCurrentBounds, typeHIRect,
                  NULL, sizeof(HIRect), NULL, &currentHIBounds);


and you don't need to do the conversion between Rect and HIRect yourself.

Another automatic conversion occurs as well between the types typeQDPoint and typeHIPoint, and, in addition, if a CFBoolean type is added to an event, a request to receive the data as typeBoolean (instead of typeCFType), will be automatically honored


[Apr 03, 2003]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.