[fpc-devel] types in xlib unit
Graeme Geldenhuys
graemeg.lists at gmail.com
Thu Oct 4 08:51:46 CEST 2007
On 03/10/2007, Felipe Monteiro de Carvalho
<felipemonteiro.carvalho at gmail.com> wrote:
>
> It's an opaque structure. You know it's a record, but you don't know
> what is inside it =)
Lovely!! That idea can only come from a C developer. :) The reason
Object Pascal is my preferred language - a lot less ambiguous.
> In the end always a pointer to the structure will be used (wither by
> really using a pointer or a var parameter), and it is not created or
> released on your side of the program, so you don't need to know it's
> contents or size or anything else.
Well, XOpenIM() and XCreateIC() functions returns or takes the record
structure, not a pointer to the structure. This is what confused me,
because if I don't know what is inside the structure, how do I know if
it was successfully created? Hence the reason I redefined the
XOpenIM() and XCreateIC() functions to take pointer types to TXIM and
TXIC. I can then test the pointer returned to see if the function call
was successful or not. See example below.
Is there another way of handling this and testing if such functions
where successful?
// for correct keyboard handling
InputMethod := XOpenIM(FDisplay, nil, nil, nil);
if InputMethod = nil then
<raise some exception here...>
InputContext := XCreateIC(InputMethod, [XNInputStyle, XIMPreeditNothing or
XIMStatusNothing, 0]);
if InputContext = nil then
<raise some exception here...>
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list