' Rapid-Q by William Yu (c)1999-2000 . ' ================================================================================ ' Upload_il_tuo_script_su_Rapidq.it ' 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 INTEGER, W Icons Infinite 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 0 WXG center a form Circle SUB (x1%, y1%, x2%, Draw & 6 W y2%, c%, fill%) Fill Circle/ Ellipse Close SUB Close form 0 WXG CopyRect SUB (D, Image, S) D and S are 3 W QRECTs, Image can be a QImage, QCanvas, or QBitmap 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 INTEGER, W Icons Infinite 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 3 W on Canvas 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%, Draws & 5 W y2%, c%) Fills a rectangle HideTitleBar SUB Hides Caption 0 W Line SUB (x1%, y1%, x2%, Draw line on 5 W y2%, c%) form Paint SUB (x%, y%, c%, Fill Region 4 W borderc%) Pset SUB (x%, y%, c%) Pixel plot 3 W Rectangle SUB (x1%, y1%, x2%, Draws a 5 W y2%, c%) rectangle Repaint SUB Repaints the 0 W entire form RoundRect SUB (x1%, y1%, x2%, Draws & 7 W y2%, x3%, y3%, c%) Fills a rounded rectangle ShapeForm SUB Shapes form 2 W (Filename$|Resource, as outline of TransparentColor&) image 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 0 WX form when hidden ShowModal FUNCTION AS SHORT Display form 0 WXG and wait for result ShowTitleBar SUB Displays 0 W Caption StretchDraw SUB (Rect AS QRECT, Draw BMP and 2 W BMP) stretch to fit inside Rect 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 Returns the 1 W WORD height, in pixels, of Text$ string TextWidth FUNCTION (Text$) AS Returns the 1 W WORD width, in pixels, of Text$ string TextRect SUB (Rect AS QRECT, Write text, 6 W x%, y%, S$, fc%, bc%) and clip within region Rect TextOut SUB (x%, y%, s$, fc%, Write text to 5 W bc%) form Details: fc% = foreground color bc% = background color For a transparent background, set bc% parameter to -1 QForm Events Event Type Occurs when... Params Support =============== =============== =============== =============== =============== User clicks on OnClick VOID open area of 0 W form OnClose SUB (Action AS Form closes 1 W INTEGER) OnHint SUB (Hint AS Hint is 1 W STRING) displayed SUB (Key AS OnKeyDown Word, Shift AS Key held down 2 W INTEGER) OnKeyPress SUB (Key AS User presses a 1 W BYTE) key SUB (Key AS User releases a OnKeyUp Word, Shift AS key 2 W INTEGER) OnMouseDown SUB (Button%, Mouse button 4 W X%, Y%, Shift%) held down OnMouseMove SUB (X%, Y%, Mouse moves 3 W Shift%) OnMouseUp SUB (Button%, Mouse button is 4 W X%, Y%, Shift%) released OnPaint VOID Form requires 0 W repainting OnResize VOID Form is resized 0 W OnShow VOID Form is 0 W displayed SUB (Hwnd%, Messages WndProc Msg%, wParam%, posted/sent to 4 W lParam%) form 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 ' =============================================================================== ' 2003 Holyguard.net - 2007_Abruzzoweb