Frequently Answered Questions [Remove Frame]

Questions

Why does FOX look so much like Windows?

Has FOX been ported to the Apple Macintosh?

Which Systems are supported by FOX?

Is FOX `64-bit clean'?

How do I write portable code?

Why do I get an `illegal icon specified' message when I change some Widget's icon?

Compiling FOX as a DLL under VC++ gives me a unresolved external symbol?

When do I call flush(), forceRefresh(), refresh() and update() after a change?

How does layout work, exactly?

When I construct a window at the beginning it works but when I construct it later it doesn't

About numbering Message ID's.

Why Support GIF!

Failing to delete menu panes in owner's destructor.

How does FXStream serialize an FXObject?

Why did FOX choose the message-map based callback paradigm

Why does a AUTOGRAY disable, but not enable the Button?

I get compiler errors in Visual C++ when inclusing FXArray or FXElement

My Motif application complains with messages about failing to allocate colors

File fxpngio.cpp does not compile on IRIX 6.5

Developing FOX Applications under Windows.

Why are there various flavors of running an event loop?

Why do I need to declare a default contructor in my classes?

Which FOX objects do I need to delete to avoid memory leaks?

What's the difference between detach and delete?

Can I use multiple threads in my FOX application?

Can I cross compile FOX on Linux for Windows?

Can I have other colors besides black and white for my cursor?

Why is the SEL_DELETED message sent before the actual deletion?

How do I perform double buffered drawing?

How do I make sure drawing is flicker-free?

Why does the border style not follow what I specify?

What's the deal with default buttons?

Shouldn't fx.h include fxkeys.h?

I have this great idea, but you will need to rewrite all of the FOX library and applications.

How do I monitor activity on sockets?

What do the different version numbers for FOX mean?

Why didn't you fix the problem of the last pixel of a line not being drawn on MS-Windows?

Why doesn't FOX use ASSERTs to check API arguments?

Why can I not paste clipboard data out of a deleted window?

What is valgrind?

When is a member function virtual or not?

Why does a toplevel window have different decorations than I specified?

Why do none of the FXScrollArea derived widgets have a frame?

What is the Legal Status of FOX since your departure from CFD Research?

CFD Research has been very nice to work out an arrangement for the legal status of FOX which is acceptable to all parties. The issues were the continued availability of the FOX Library to CFD Research, and the acknowledgement of copyrights to its author and contributors.

The arrangement is as follows:

  1. CFD Research disclaims all Copyright Interests to the FOX Library.
  2. CFD Research will continue to be able to use the FOX Library under the Lesser GPL license.

What is all this stuff with FXSelector and so on?

When a target receives a message from a widget, it may want to know several things:

Sometimes, a handler may have to send messages back to the sender, for example, in response to a SEL_COMMAND message a message handler may want to obtain the value of the sending widget by sending it a message of type SEL_COMMAND, and message id ID_GETINTVALUE. To build a message out of the type and id parts, you can use the macro: FXSEL(type,id).

For historical reasons, the data type used for the message-id, message-type, as well as the combined selector is FXSelector.

How do I add an icon for Windows Explorer?

You need to create a file, call it "myapp.rc", and then put into it:

  0 ICON DISCARDABLE "myapp16.ico"
  1 ICON DISCARDABLE "myapp32.ico"

Where, obviously, myapp16.ico and myapp32.ico are the icons you want to be associated with your application.

You will also need to convince your resource compiler to compile that, of course.

The TextField stops updating while the cursor is in it?

While a Control is being manipulated by the user, the GUI update (the process by which the widget updates itself from the application state) is turned off.
For most simple controls like Sliders this is done only during the time the mouse has grabbed the slider head.
However, for TextFields the updating is turned off while the TextField is being edited. There is no easy way to detect when the user is "done" with the TextField; but it is clear that the TextField can be updated again when:

Building and using DLL's with FOX under Windows.

When you compile something, the header files can be parsed two ways on Windows. When compiling the FOX library itself as a DLL, the FXAPI macro should be set to FXEXPORT, which itself is set to __declspec(dllexport), (or possibly as something else depending on the compiler and linkage ideosyncracies). When you're compiling your own code which uses the FOX DLL, then FXAPI is defined as FXIMPORT which is then typically set to __declspec(dllimport).

There are two layers of macros so for your own DLL and EXE building you won't have to remember what to do for export or import, you can use the FXEXPORT and FXIMPORT macros. Now, you can NOT use FXAPI. When you build your own library, that library is a importer of the FOX API but an exporter of its own API!

For example, in FXChart new symbol FXCHARTAPI is defined so that when it is compiled it could be import symbols from FOX yet at the same time export its own symbols.

So in a nutshell:

Creating an MDI application.

When you build an MDI application, messages should be routed via the FXMDIClient to an FXMDIChild, and from there, to either FXMDIChild's content window and the FXMDIChild's target. The FXMDIChild's target is typically a document object of some kind.

So, GUI controls basically have FXMDIClient as their target. The FXMDIClient is a kind of delegator, in the sense that when it does not understand a message, it forwards it to its currently active FXMDIChild; if there is no such child, then control is returned to the calling widget with the "unhandled" message return code.

The FXMDIChild similarly does a delegation. It tries the content window first, then its target "document" object.

Since we do not know which FXMDIChild is going to be active, it is important to ensure that all message ID's are unique if you have different types of FXMDIChild widgets.

For example, an application may have a 3D viewer in one FXMDIChild and a text view in another FXMDIChild. We don't want messages intended for a 3D viewer to be connected to a wrong handler when the text view FXMDIChild is active.

So, I recommend a common base class for your various FXMDIChild subclasses, and to define all message ID's in there. Then various subclasses of this base class map whatever ID's they need to specific handlers.

If you also have a Document class as target of the FXMDIChild windows, then number the messages the Document deals with starting from the ID_LAST of the FXMDIChild base class widget in your application. See below:

  // MDI Child base class
  class MyMDIChildBase : public FXMDIChild {
  ...
  enum {
    ID_FIRST=3000,      // High number away from any ID's defined in widgets
    ...
    messages defined for all subclasses of MyMDIChildBase
    ...
    ID_LAST
    };
  ...
  };


  // Custom document class
  class MyDocument : public FXObjecvt {
  ...
  enum {
    ID_FIRST=MyMDIChildBase::ID_LAST,
    ...
    ID_LAST
    };
  ...
  };

This is convenient. For example, a "Cut Selection" message could have radically different implementations in the various subclasses, yet be invoked from the same single menu.

When a particular FXMDIChild is active, some message ID's will be mapped to a handler, and some will not be.

FOX can take advantage of this fact by allowing you to specify the AUTOGRAY or AUTOHIDE flags on certain controls. For example, if you were to specify BUTTON_AUTOGRAY on a toolbar button, the button is automatically grayed out when no corresponding handler is found in the currently active FXMDIChild, or when there is no open document at all.

BUTTON_AUTOHIDE works similarly, except that in this case the button will be hidden instead of simply grayed out.

When you use BUTTON_AUTOGRAY, it is of course going to be necessary to implement the SEL_UPDATE handler as well as the usual SEL_COMMAND handler, so that you can enable the button. You can enable the button by means of a message, so that your handler won't have to know what kind of widget the sender was.

Example:

  // Undo last command
  long MyDocument::onCmdUndo(FXObject*,FXSelector,void*){
    /// perform the command for undo
    return 1;
    }


  // Sensitize undo widget; the ID_ENABLE message
  // enables the sender [presumably a widget of some sort]
  // We don't need to know what kind of widget the sender is,
  // so we can actually use this handler for sensitizing toolbar
  // buttons as well as the corresponding pulldown menu commands.
  long MyDocument::onUpdUndo(FXObject* sender,FXSelector,void*){
    sender->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_ENABLE),NULL);
    return 1;
    }

  // Example: pulldown menu command
  new FXMenuCommand(editmenu,"&Undo",undoicon,clientarea,MyDocument::ID_UNDO,MENU_AUTOGRAY);

  // Example: toolbar command
  new FXButton(maintoolbar,"\tUndo",undoicon,clientarea,MyDocument::ID_UNDO,BUTTON_AUTOGRAY|BUTTON_TOOLBAR|FRAME_RAISED);

Of course there may be a few cases where you may need to perform a wholesale update of the user interface when the user switches FXMDIChild windows or documents. Some major widgets with lots of content should probably not be updated using the SEL_UPDATE mechanism.

There are two ways; first is the SEL_CHANGED from FXMDIClient; a better way, and the recommended one, is to catch the SEL_SELECTED and SEL_DESELECTED messages from FXMDIChild:

  // Switched to new active document
  long MyDocument::onChildActivate(FXObject*,FXSelector,void* ptr){
    if(!ptr || ((FXMDIChild*)ptr)->getTarget()!=this) activateDocument();
    return 1;
    }


  // Switched from old active documents
  long MyDocument::onChildDeactivate(FXObject*,FXSelector,void* ptr){
    if(!ptr || ((FXMDIChild*)ptr)->getTarget()!=this) deactivateDocument();
    return 1;
    }

The void* in these messages reflects the OLD FXMDIChild window that was active before the switch. The code above takes care of the case where there are multiple FXMDIChild windows which may have a common document, and we would of course only want to update the GUI controls when we switch documents, not when we switch between FXMDIChild windows of the same document.

The implementation of activateDocument() will be responsible for setting up the GUI controls with data pertaining to the document. Likewise, deactivateDocument() should tear down the user interface and leave widgets in their pristine state [as if there were no document].

MS-Windows GDI handle limits.

MS-Windows has finite limits on GDI handles; the maximum number of HWND handles in the entire system is determined by 16-bit handle values. There is also a maximum number of bitmap handles.

These limits manifest themselves when calls to create() are failing by throwing an exception.
Windows NT, 2K, and XP probably have higher limits than Windows 95, Windows 98, and Windows ME.

It is therefore important to make sure that resources are deleted as soon as they're no longer needed. Since its pretty fast to create resources, its best to delay creation of windows and icons until they're actually needed.

In particular, dialogs should "own" their icons, and delete them in the dialog's destructor. Try to construct dialogs only when they're actually brought on-screen, and try to delete them when the interaction with them is done.

Note that un-created() icons and images do not use any handles in the system, so refrain from calling create() on icons or images if all you want to do is load and manipulate the image's pixel data. You only need to call create() when images are to be drawn into or used as sources for drawing (like e.g. drawing onto widgets).

Copyright © 1997-2005 Jeroen van der Zijp