[Lazarus] OSX: Handles and WindowRefs
Andrew Haines
andrewd207 at aol.com
Sun Jan 11 04:05:02 CET 2009
Duncan Parsons wrote:
> Hi,
>
> I seem to have run into a problem with what is essentially
> nomenclature..
>
> Since LCL has used Delphi as its template, there's a lot of Windows
> based conventions, but that doesn't totally map to other systems.
>
> For instance, TForm.Handle in windows repesents the tag that the OS
> gives to the rectangle I see on screen. I would have thought that each
> underlying widgetset interface would then use this to maintain some
> consistency at a higher level, eg on OSX, this would be filled with the
> WindowRef that OSX uses. However, I cannot see this happening (unless
> I'm looking in the wrong place). TCarbonWindow has a fWindowRef field
> and property that references it, but this is at widgetset level, and so
> not visible to TForm.
>
> I see the HandleAllocated and GetReferenceAllocated code lying around,
> but they don't seem to tell me what I'm after. What I'd like to know is
> if I have a function in OSX that is asking for a form's WindowRef, do I
> pass it self.Handle, or is there something else I should be using. At
> the moment it is not working as I would hope. For instance calling
> GetWindowAttributes(WindowRef(self.Handle),myAttributes) gives me an
> exception each time.
>
> Any ideas on what I should be looking for?
>
> ATB, DSP
>
Afaik in the Carbon interface TWincontrol.Handle can be typecast to
TCarbonWidget (declared in CarbonDef) which has the property "Widget" of
type HiViewRef.
so
var
AHiView: HiViewRef;
begin
...
AHiView := TCarbonWidget(Form1.Handle).Widget);
...
end;
Hope this helps,
Andrew
More information about the Lazarus
mailing list