[archived content]
Dfl /

Controls

  • To move the control, use the location property; to change the size of the

control, use the size property; or to do both at once, use the bounds property:

myCtrl.bounds = Rect(x, y, width, height);

There are also separate properties: left, top, width and height.

  • Using the handle property will cause the handle of the control to be

immediately created if not already created.

  • To add an item to a ListBox or ComboBox, use the items collection:
myListBox.items.add("item");

See examples/listbox.d and examples/combo.d

  • Set ListBox property integralHeight to false if docking or setting its size

in a layout event.

  • To add a context menu (right-click menu), set the contextMenu property to a

new ContextMenu and add MenuItem`s. Some controls will have a default context menu, such as TextBox.

Forms

  • If you are setting both the formBorderStyle and clientSize, be sure to always set

the formBorderStyle first because it can cause the client size to change.

  • To add a shortcut, use the addShortcut member:
myForm.addShortcut(Keys.CONTROL | Keys.N, &shortcut_ctrlN);

An exception will be thrown if that shortcut key was already added. See examples/shortcut.d

  • To manually set the location of the Form, you will need to set the

startPosition property to FormStartPosition.MANUAL and use the location or bounds property.

  • To add a menu bar, set the menu property to a new MainMenu and add MenuItem`s.

See examples/client.d and examples/dnote.d

  • To add a default button, one that is "clicked" when the user presses enter,

set the acceptButton property to a Button or a class that implements IButtonControl.

  • To add a cancel button, one that is "clicked" when the user presses Esc,

set the cancelButton property to a Button or a class that implements IButtonControl.

Application

  • To enable XP visual styles, call Application.enableVisualStyles() in the main

function, before creating any controls. This function will do nothing if the styles are not supported.

  • To disable the default exception dialog, add a handler to event

Application.threadException.

Other

  • An example message box is
msgBox(formOwner, "Display text", "Caption", MsgBoxButtons.OK, MsgBoxIcon.INFORMATION);
  • To create a system tray icon, use the NotifyIcon class.

See examples/tray.d

  • EventArgs are not guaranteed to be valid after the event handler finishes.
  • Use Control.invoke() to execute a delegate in the thread that the Control was

created in. The first parameter is the delegate to call in the other thread, the second parameter is the args to pass to that delegate, and the return value is what was returned from the delegate.

Page last modified on August 01, 2005, at 08:54 AM