[fxruby-users] Create on FXDialogBox

Jeroen van der Zijp jeroen at fox-toolkit.org
Wed Sep 17 11:25:47 EDT 2008

On Wednesday 17 September 2008, Thilko Richter wrote:
> Hello,
> just a matter of understanding: As far as I have understand, I have to
> call create() on every widget that I construct during runtime of my
> application to create the server side ressources. After revisiting my
> code, I found some widgets where I have forgotten to call create() ;-)
>  - but - I dont know why, the widgets in the dialogbox are shown. I
> could not explain me this behauviour, it this maybe done in the
> execute() method of the FXDialogBox?

In principle, yes!  Each widget is first constructed, then created (realized).

When you construct a widget, you're essentially just filling in a C++ data structure,
and initializing it with particular member data.

When you create() it, a resource is allocated for it in the system (X11 or GDI); for
example, when you create a window, a HWND will be associated with the C++ class, and
when you create an image, a DIB will be associated, and so on.

Now, all widgets are typically connected in a widget-tree, and since create() recurses
downward through this widget-tree, calling create() in FXApp will effectively realize
all the resources in one fell swoop.  If you never construct any other widgets later
on, then this single call to create() will suffice.

However, not-trivial applications will likely at the very least bring up some dialog
boxes, so these must be created explicitly after being constructed.

As a convenience, for the common case for modal dialogs, the execute() api will also
call create() along the way, and thus you won't have to call it explicitly in that

In other cases, create() must be called explicitly.  Keeping in mind that create()
recurses through the widget hierarchy, and creates every REACHABLE resource from
this hierachy, it is enough to call create() only on the top-most widget of your 

	Hope this helps,

			- Jeroen

More information about the fxruby-users mailing list