Rapid-Q Documentation by William Yu (c)1999-2000 | Appendix A: QFORM

# QFORM Component

  QForm is a standard application Window. You can put any visible control component on a QForm, such as QEdit, QLabel, QButton, etc...
  W = Windows, X = Rapid-Q/XForms, G = Rapid-Q/GTK
  QForm Properties

  Field | Type | Read/Write | Default Value | Support

  AutoScroll | INTEGER | RW | True | W
  | Specify whether scroll bars should appear automatically on the form if it is not large enough to display all of its controls
  BorderStyle | INTEGER | RW | bsSizeable | WXG
  | BorderStyle specifies the appearance and behaviour of the form border. 0 = bsNone -- Not resizeable; no visible border line or caption bar 1 = bsSingle -- Not resizeable; single-line border 2 = bsSizeable -- Standard resizeable border 3 = bsDialog -- Not resizeable; standard dialog box border
  4 = bsToolWindow -- Like bsSingle but with a smaller caption
  5 = bsSizeToolWin -- Like bsSizeable but with a smaller caption
  Caption | STRING | RW |  | WXG
  | Caption is the text that appears as the title of your form.
  ClientHeight | INTEGER | RW |  | WXG
  | The height of the form's client area, ie. the usable area inside the form's border.
  ClientWidth | INTEGER | RW |  | WXG
  | The width of the form's client area, ie. the usable area inside the form's border.
  Color | INTEGER | RW | clBtnFace | W
  | Color of the form.
  Cursor | INTEGER | RW | crDefault | W
  | Cursor that appears when the mouse pointer is over the form.
  Font | QFONT | W |  | W
  | Sets font property. Used for TextOut method.
  FormStyle | INTEGER | RW | fsNormal | W
  | Get or set the form's style. Only fsNormal is supported.
  Handle | INTEGER | R |  | W
  | Get the form's handle for WinAPI calls.
  Height | INTEGER | RW |  | WXG
  | Get or set the form's vertical size (in pixels).
  Hint | STRING | RW |  | W
  | The hint string that appears when the user moves the mouse pointer over the form. It is not displayed unless ShowHint is true.
  IcoHandle | RESOURCE | W |  | W
  | Assign an icon resource handle to appear as the icon for your form. Example:

  > $RESOURCE game_ICO AS "game.ico"
  > DIM Form AS QFORM
  > Form.IcoHandle = game_ICO

  Icon | STRING | W |  | W
  | Assign an icon filename to appear as the icon for your form.
  KeyPreview | INTEGER | RW | False | W
  | Specify whether keyboard events should occur on the form before they occur on the active control. Not all keys will be redirected.
  Left | INTEGER | RW | 0 | WXG
  | Specifies the left edge of the form relative to the desktop screen.
  ModalResult | INTEGER | W |  | W
  | Assigning a value to ModalResult will close the form when it is displayed modally. 0 = mrNone 1 = mrOk 2 = mrCancel 3 = mrAbort
  4 = mrRetry
  5 = mrIgnore
  6 = mrYes
  7 = mrNo
  8 = mrAll
  Parent | QFORM | W |  | W
  | Assigning a parent will remove the second form from the taskbar.
  PopupMenu | QPOPUPMENU | W |  | W
  | Popupmenus are displayed when user right clicks on the form. Example:

  > DIM PopupMenu AS QPOPUPMENU
  > DIM Form AS QFORM
  > Form.PopupMenu = PopupMenu

  ShowHint | INTEGER | RW | False | W
  | If True then the hint popup message can be displayed.
  Top | INTEGER | RW | 0 | WXG
  Visible | INTEGER | RW | False | WXG
  | Specifies the visibility of the form.
  Width | INTEGER | RW | 320 | WXG
  WindowState | INTEGER | RW | wsNormal | W
  | Specifies how the form appears on the screen. 0 = wsNormal -- form appears neither maximized nor minimized 1 = wsMinimized -- form is minimized 2 = wsMaximized -- form is maximized

  QForm Methods

  Method | Type | Description | Params | Support

  AddBorderIcons | SUBI | Add Border Icons | INTEGER, Infinite | W
  | Valid border icons are: 0 = biSystemMenu -- The form icon 1 = biMinimize -- The minimize icon 2 = biMaximized -- The maximize icon 3 = biHelp -- The help icon
  Example:

  > $INCLUDE "RAPIDQ.INC"
  > DIM Form AS QFORM
  > Form.AddBorderIcons(biHelp)

  Center | SUB | Used to center a form | 0 | WXG
  Circle | SUB (x1%, y1%, x2%, y2%, c%, fill%) | Draw & Fill Circle/Ellipse | 6 | W
  Close | SUB | Close form | 0 | WXG
  CopyRect | SUB (D, Image, S) | D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap | 3 | W
  | Example (copies QIMAGE to form at 10,10):

  > DIM Destination AS QRECT
  > DIM Source AS QRECT
  > DIM Image AS QIMAGE
  > Image.BMP = "whatever.bmp"
  > SUB FormPaint (Sender AS QFORM)
  > WITH Destination
  > .Top = 10
  > .Left = 10
  > .Right = .Left+Image.Width
  > .Bottom = .Top+Image.Height
  > END WITH
  > WITH Source
  > .Top = 0
  > .Left = 0
  > .Right = Image.Width
  > .Bottom = Image.Height
  > END WITH
  > Sender.CopyRect(Destination, Image, Source)
  > END SUB
  > DIM Form AS QFORM
  > Form.OnPaint = FormPaint

  DelBorderIcons | SUBI | Remove Border Icons | INTEGER, Infinite | W
  | Valid border icons are: 0 = biSystemMenu -- The form icon 1 = biMinimize -- The minimize icon 2 = biMaximized -- The maximize icon 3 = biHelp -- The help icon
  Example:

  > $INCLUDE "RAPIDQ.INC"
  > DIM Form AS QFORM
  > Form.DelBorderIcons(biMinimize)

  Details:
  Deleting icon may not necessarily remove it from the form's title bar, but the icon will be greyed out.
  Draw | SUB (x%, y%, BMP) | Draw Bitmap on Canvas | 3 | W
  | Details: BMP can be any BMP property from QBitmap, QImage, QImageList, etc. any component with a BMP property is fine. Examples:

  > DIM Image1 AS QIMAGE
  > Image1.BMP = "whatever.bmp"
  > DIM Image2 AS QBITMAP
  > Image2.BMP = "whatever.bmp"
  > SUB FormPaint (Sender AS QFORM)
  > Sender.Draw(0, 0, Image1.BMP)
  > Sender.Draw(50, 50, Image2.BMP)
  > END SUB
  > DIM Form AS QFORM
  > Form.OnPaint = FormPaint

  FillRect | SUB (x1%, y1%, x2%, y2%, c%) | Draws & Fills a rectangle | 5 | W
  HideTitleBar | SUB | Hides Caption | 0 | W
  Line | SUB (x1%, y1%, x2%, y2%, c%) | Draw line on form | 5 | W
  Paint | SUB (x%, y%, c%, borderc%) | Fill Region | 4 | W
  Pset | SUB (x%, y%, c%) | Pixel plot | 3 | W
  Rectangle | SUB (x1%, y1%, x2%, y2%, c%) | Draws a rectangle | 5 | W
  Repaint | SUB | Repaints the entire form | 0 | W
  RoundRect | SUB (x1%, y1%, x2%, y2%, x3%, y3%, c%) | Draws & Fills a rounded rectangle | 7 | W
  ShapeForm | SUB (Filename$|Resource, TransparentColor&) | Shapes form as outline of image | 2 | W
  | Details: The first parameter can either be a filename to the BMP file, or a BMP resource file. The second parameter indicates which color is transparent. Example 1:

  > DIM Form AS QFORM
  > Form.ShapeForm("image.bmp", &HFFFFFF)

  Example 2:

  > $RESOURCE image_BMP AS "image.bmp"
  > DIM Form AS QFORM
  > Form.ShapeForm(image_BMP, &HFFFFFF)

  Show | SUB | Used to show form when hidden | 0 | WX
  ShowModal | FUNCTION AS SHORT | Display form and wait for result | 0 | WXG
  ShowTitleBar | SUB | Displays Caption | 0 | W
  StretchDraw | SUB (Rect AS QRECT, BMP) | Draw BMP and stretch to fit inside Rect | 2 | W
  | Details: BMP can be any BMP property from QBitmap, QImage, QImageList, etc. any component with a BMP property is fine. Examples (Double original size):

  > DIM Image1 AS QIMAGE
  > Image1.BMP = "whatever.bmp"
  > SUB FormPaint (Sender AS QFORM)
  > DIM R AS QRECT
  > R.Left = 0
  > R.Top = 0
  > R.Right = Image1.Width*2
  > R.Bottom = Image1.Height*2
  > Sender.StretchDraw(R Image1.BMP)
  > END SUB
  > DIM Form AS QFORM
  > Form.OnPaint = FormPaint

  TextHeight | FUNCTION (Text$) AS WORD | Returns the height, in pixels, of Text$ string | 1 | W
  TextWidth | FUNCTION (Text$) AS WORD | Returns the width, in pixels, of Text$ string | 1 | W
  TextRect | SUB (Rect AS QRECT, x%, y%, S$, fc%, bc%) | Write text, and clip within region Rect | 6 | W
  TextOut | SUB (x%, y%, s$, fc%, bc%) | Write text to form | 5 | W
  | Details: fc% = foreground color bc% = background color For a transparent background, set bc% parameter to -1

  QForm Events

  Event | Type | Occurs when... | Params | Support

  OnClick | VOID | User clicks on open area of form | 0 | W
  OnClose | SUB (Action AS INTEGER) | Form closes | 1 | W
  OnHint | SUB (Hint AS STRING) | Hint is displayed | 1 | W
  OnKeyDown | SUB (Key AS Word, Shift AS INTEGER) | Key held down | 2 | W
  OnKeyPress | SUB (Key AS BYTE) | User presses a key | 1 | W
  OnKeyUp | SUB (Key AS Word, Shift AS INTEGER) | User releases a key | 2 | W
  OnMouseDown | SUB (Button%, X%, Y%, Shift%) | Mouse button held down | 4 | W
  OnMouseMove | SUB (X%, Y%, Shift%) | Mouse moves | 3 | W
  OnMouseUp | SUB (Button%, X%, Y%, Shift%) | Mouse button is released | 4 | W
  OnPaint | VOID | Form requires repainting | 0 | W
  OnResize | VOID | Form is resized | 0 | W
  OnShow | VOID | Form is displayed | 0 | W
  WndProc | SUB (Hwnd%, Msg%, wParam%, lParam%) | Messages posted/sent to form | 4 | W
  | Only one WndProc per Form is allowed. So if you have multiple forms, only one may be able to receive messages at a time. (Future consideration to correct this)

  QForm Examples

        DIM Form AS QForm
        DIM Button AS QBUTTON

        Button.Parent = Form     '' Add button to form container
        Form.Center
        Form.Caption = "Hello world!"

        IF Form.ShowModal THEN
          PRINT "Return result is TRUE"
        ELSE
          PRINT "Return result is FALSE"
        END IF

  Prev Component | Contents | Next Component