Controls


Controls are child windows, usually used to get input from or send output to the user. Windows comes with a wide selection of controls built in, and more are available from third parties. Future versions of WinX will even allow you to create your own custom controls. Keep in mind that there are other technologies for controls. ActiveX is also popular and new .net based technologies are being introduced with Vista. .net and XBlite are completely incompatable. ActiveX is based on COM, although you could make it work, it would be far from simple.

Controls are created in WinX with the WinXAdd... functions. The controls that are supported by WinX can be manipulated with the relevant WinX functions and will trigger the relevant callbacks. You can use controls not directly supported by WinX using the WinXAddControl function and registering a message handler to receive message from that control. Communication with the control will requure the SendMessage function (documented in the Win32 API docs).

You will notice that the WinXAdd... functions provide to way to set the position and dimensions of the control. This is done by the parent window's sizing routine. Usually, this will be the Auto Sizer. Unless you are providing your own controlSizer callback function, make sure to add every control you create to the Auto Sizer or it won't be even be visible. The reason for this system is to make it easier to position controls relative to each other, and to make sure the controls are moved and sized correctly when the window is resized.

Control Navigation

The dialog box interface allows the user to navigate between controls using the keyboard. It is disabled by default. To enable it, use the WinXEnableDialogInterface function. The downside to using the dialog box interface is that it eats up certain key presses which your application may want to process.

What are those ids for?

When you create a new control, you give WinX an id constant, why? Well, it would be a pain to have to store up handles to all the controls you create. Win32 gives you a simpler way, the GetDlgItem function. This function takes a handle to a window (the docs call it a handle to a dialog box, but its the same thing) and the id of a control. It returns the handle to the control. Use this function well, it is much more reliable than storing up handles to controls.

Using visual styles

New versions of Windows (versions since XP) include a primitive form of skinning known as visual styles. In order to create controls which follow the user's visual style, you have to include a manifest in your resource file. The manifest is a simple XML file. See the sample files for examples of how manifests work.

Related Links

Animation Controls
Button Controls
Check Button Controls
Combo Box Controls
Edit Controls
Group Controls
List Box Controls
List View Controls
Progress Controls
Radio Buttons Controls
Static Controls
Tab Controls
Tracker Controls
Treeview Controls
WinX Splitter Controls

WinXEnableDialogInterface
Auto Sizer
controlSizer (callback)
WinXAddControl
WinXRegMessageHandler