From: Ezra B. <ezr...@us...> - 2008-08-24 03:44:40
|
Update of /cvsroot/win32forth/win32forth/Help/html/IDE In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23086/Help/html/IDE Added Files: Creating a Form.htm Using Forms.htm Log Message: Beginning of docs for the IDE. EAB --- NEW FILE: Using Forms.htm --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>Using Forms</title> </HEAD> <BODY LANG="en-US" DIR="LTR"> <P><H1 align="center">Using Compiled Forms</H1></p> <a name="top"></a> <p> Several files can possibly be loaded by a form - excontrols.f, bitmap.f, mdi.f, mdidialog.f, and folderview.f ExControls.f will be loaded if one or more controls are used in the form and Bitmap.f will be loaded if any bitmap buttons or static labels are used. Mdi.f and MdiDialog.f will be loaded if a form is set to compile as an MDI dialogwindow. Folderview.f is a directory browser loaded if a form has such a object. The paths for these files are already set but if your path is different then be sure to add it, as in <b>fpath+ yourdrive:\your\path</b>. <pre>Compiled forms can be used in an application in a number of ways - A form can be copied to the clipboard and then pasted into the program and modified. It can be compiled to disk and the .frm file modified with a text editor. Source file FormProperty.f is an example of this. One drawback to this and the previous method is that any future desired modification to the form wil prove difficult without erasing any modifications. As such, these two methods are best used when no future changes to the designed form is anticipated. The third method involves compiling the form to a .frm file and loading the form with the application. Controls would then be accessed directly or indirectly to achieve the intended purpose. An alternative method would be to use the loaded form object as the superclass for an additional form object. The Preferences.frm source file from ForthForm and the code that uses it is such an example of the former method. It is reproduce here for purposes of explanation. An example of the latter method is also given. <b> /* ********************** ForthForm Preferences **************** */ needs preferences.frm \ preferences dialog : ApplyPreferences ( -- ) IsButtonChecked?: chkFlatToolBar to FlatToolBar? IsButtonChecked?: chkButtonText to ButtonText? Close: TheControlToolBar TheMainWindow Start: TheControlToolBar false SaveRestore: TheControlToolBar \+ withbgnd ReDrawImage: TheMainWindow ; : pref-func { id obj -- } ( h m w l id obj -- h m w l ) id case IDOK of ApplyPreferences Close: obj endof IDCANCEL of Close: obj endof endcase ; : doPreferences ( -- ) ['] pref-func SetCommand: frmPreferences GetHandle: TheMainWindow SetParent: frmPreferences IDOK SetID: btnOk IDCANCEL SetID: btnCancel Start: frmPreferences FlatToolbar? Check: chkFlatToolBar ButtonText? Check: chkButtontext ; ' doPreferences is doPref /* ************************************************************** */ </b> Notes - "ApplyPreferences" is the routine that will update the application if the user clicks the 'Ok' button. - "pref-func" is the function that handles the form 'WM_COMMAND' message. Two parameters are of primary concern; 'id' which is the id of the control that was clicked and 'obj' which is the address of the form object. An application can use these two values to control various aspects of the displayed form. To set the message handler for the WM_COMMAND message use the method SetCommand: (formname) e.g ['] pref-func SetCommand: frmPreferences. Controls can be compiled as global whereby they will be referenced by name or they can be referenced by dot notation (not recommended however)e.g. IDOK SetID: frmPreferences.btnOk If the form is a modal form its parent can be set by the SetParentWindow: method e.g Gethandle: TheMainWindow SetParentWindow: frmPreferences. If it is not modal but a parent is set the form will simply behave as an owned window, its title not being displayed in the task bar. Method #3 fload test.frm \ load the form :Object MyForm Super frmTest \ use the form in test.frm as super class \ note the error in "Super" above. HTML would not permit the "less than" character \ all controls are automatically available without them being global \ you can change the window style :M WindowStyle: ( -- style ) WS_CAPTION ;M \ eliminate the Close [x] button for this form :M On_Init: ( -- ) \ modify the behaviour of some controls On_Init: Super \ initialize form false Enable: chkButton \ disable this one IDOK SetID: btnOk \ change this id \ and anything else you wish ;M \ the power is yours! ;Object Method #4<br> <A HREF="Code Window.htm">Add code at design time.</A><br><br> <h3>Control commands</h3> The controls directly supported by the Form Designer at this time include, Single and multi-selection listboxes Text and bitmap labels Single and multiline textboxes Text and bitmap buttons Checkboxes Radiobuttons Combo and combolist boxes Groupboxes Horizontal and vertical up/down controls Tab Controls A Directory Browser class Additional controls are available in the source file ExControls.f. In addition a generic control is provided to allow for any control not directly supported by Form Designer. Compiled forms will have the coordinates and dimensions of any such control added as values e.g A form having a generic control with the name "imgButton" will have the following values when compiled - 'x' value imgButtonX - x coordinate 'y' value imgButtonY - y coordinate 'w' value imgButtonW - width 'h' value imgButtonH - height The directory browser object is created by the FileWindow class. This object is capable of displaying files matching different specs for a directory as well as displaying the files and directories in ascending or descending order. The method "SetSpecs:" with an argument for e.g "*.f;*.htm;*.frm" (note each spec is separated by a ; ) sets the object to display files with matching extensions. Some other methods include - <b>ShowFiles:</b> ( flag -- ) display files if flag is true otherwise show directories only. <b>UpdateFiles:</b> ( -- ) update the file display, perhaps after changing the filespecs or the path. <b>IsOn_Update:</b> ( cfa -- ) the function at cfa will be executed after the file display. is updated. <b>SetPath:</b> ( addr cnt -- ) set the path for the the displaying of files. <b>SortAscending:, SortDescending:</b> change the display order of files and directories. Directories will always be displayed first. <b>#Dirs:, #Files:</b> return the number of directories or files respectively. For further information please browse the file FileLister.f. Following are some other control methods that may be useful in forms. <b>AddStyle:</b> ( style -- ) - add any additional style to a control before it is created. <b>Enable:</b>, <b>Disable:</b>, - self-explanatory <b>SetFont:</b> ( fonthndl -- ) - set the font for applicable controls <b>AddStringTo:</b> ( stringz -- ) - add asciiz string to listboxes and comboboxes <b>SetSelection:</b> ( n -- ) - set current selection for listboxes and comboboxes <b>Clear:</b> - erases contents of listboxes and comboboxes <b>Check:</b> ( flag -- ) - checks (true) or unchecks (false) a checkbox or radiobutton <b>IsButtonchecked?:</b> ( -- f ) - return state of radiobutton or checkbox <b>SetBitmap:</b> ( hbitmap -- ) - set image for a bitmap button <b>ToolString:</b> ( addr cnt -- ) - set the tooltip for a bitmap button N.B All controls are derive from the basic Win32Forth controls. As such any methods available for those controls can also be used. Please review the source files ExControls.f (and its component files), Control.f, Controls.f as well as Generic.f for a more exhaustive list of methods for the various controls. </pre> <hr> <A href="#top"><img src="top.gif" align="absmiddle" border=0>Top</a><p> <A HREF="Form Designer.htm#Index"><img src="back.gif" align="absmiddle" border=0>Back to main page</A></P> </BODY> </HTML> --- NEW FILE: Creating a Form.htm --- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> </head> <body lang="en-US" dir="LTR"> <b><h2 align="center">Creating and Compiling a Form</h2></b> <p>Click on New form in the toolbar or select 'New' from the "Form" menu to create a form with default parameters. After a form is displayed click on the desired control in the toolbar. That control will appear pressed and remain pressed until another control is selected or the select button is clicked. Click at the location on the form where the control is to be placed and drag the mouse to create the control. Alternatively just click at desired location to create a control of default size. Additional controls of the same type can quickly be added by simply clicking on the form( if enabled from the Preferences dialog). <b>Note that if you need to select a group of controls or position any you may need to click the select button from the toolbar.</b> (If the mouse cursor changes to a hand when hovering over a control it indicates "select" mode - a control can be selected and/or moved - otherwise it is in "control" mode i.e the selected control will be added if the mouse is clicked)</p> <p>Below is an example of a new form with a single pushbutton control.</p> <p align="center"><img src="New Window.gif" border="0"><br clear="LEFT"> </p> <p>Click and drag controls ( make sure you are in "select" mode! ) to reposition them on the form. Click and drag on any of the four handles at the corner of the control to modify its size.</p> <img src="forthform.gif" align="LEFT" width="32" height="32" border="0"> The functions "Size sequential controls" , "Arrange sequential controls vertically" and "Arrange sequential controls horizontally" in the menus are very useful for quickly positioning controls.<br><br> Any group of controls can be selected and aligned or adjusted in size. Left click and drag on the form to select the desired controls, indicated by a dashed-line box ( controls are considered selected if their top left corner falls inside the box ). Right click anywhere on the form and select "Group Action" from the menu. Select desired operation from the "Group Action" dialog. Below is an example form with four label controls selected.<br> <p align="center"><img src="GroupExample.gif" alt="" border="0"><br clear="LEFT"></p> The dimensions of the selection box can be fine tuned by using the arrow keys (up, down, left, right). These keys increase the area of the selection box only. This can be useful in the instance where selected controls are moved outside the selection box. By adjusting the box these controls can once again be adjusted.<br><br> <p> The Group Action dialog is shown below. The designated function for each button should be self-explanatory. However, a word of explanation for the position/size adjustment. Set the value for the adjustment in the spinnercontrol, select from the radiobuttons which attribute to change, then click the appropiate arrow. The up/right arrows and the left/down arrows achieve identical results for size adjustments. <p align="center"><img src="GroupAction.gif" alt="" border="0"> <p>Right click on a control and select 'Properties' to modify its name, caption etc. <p align="center"><img src="Control Property Window.gif" border="0"><br clear="LEFT"></p> The Control Properties Window can remain open as you modify controls. However, before switching to another control you must 'Apply' the current control's properties to save any modifications. To close the property window click 'Close'.<br><br> The XPos, YPos, Width and Height parameters are in pixel units - no units, twips or dips! The Xpos and Ypos are relative to the top left corner of the form. Click the arrow to change the value of a property or alternatively enter a number directly in the control.<br><br> Tooltip - use primarily for bitmap buttons. Enter the text to be displayed when the mouse is hovering over the control.<br><br> ... Pushbutton - if enabled click to browse for a bitmap file.<br><br> Group - Begins or ends a group of controls. Used to group radiobuttons and checkboxes.<br><br> Global - If selected the control will be available accessible to the entire program, otherwise it is private to the form object.<br><br> Spinner - Valid only for textboxes. Converts the control to what is called a spinbutton.<br><br> Justification - select how text will be shown in control.<br><br> Previous and Next - Cycle through controls of a form.<br><br> <b>Font Selection</b> - To change the default font for a control right click on the desired control and select "Change Font" from the menu. Having selected a font its properties will be compiled to the form in a definition based on the control's name. If a font is needed for the form but not for a control then add a generic control and select the font for it. When the form is compiled the selected font will be available for general use.<br><br> <img src="forthform.gif" align="LEFT" width="32" height="32" border="0"> It is a good idea to choose names for the controls that will indicate the type of control. This will be useful especially if the controls are global: e.g<br> txtName - identifies this control as a text box<br> lblName - this a label<br> btnOk - a pushbutton control etc. <p>To modify a form's properties right click anywhere in the form and select 'Properties' from the menu. The following form will be displayed. <p align="center"><img src="Form Property Window.gif" border="0"><br clear="LEFT"> <br> <br> </p> <p>If 'Modal Form' is selected the form will behave like a modal dialog i.e. access to it's parent will be denied until the form is closed. Note that the parent window must be set for the form. Note too that a modal form will not return to its caller until it is closed.</p> <p>'Save screen location' allows a form to remember its last screen location when it is closed. When next displayed it will return to that saved location.</p> <p>If 'Status Bar' is checked the form will be compiled and shown with a status bar. <p> A form can be compiled as a default dialog window, a child window (useful for instance in tab controls) or as a multiple document interface (MDI) dialog window. Select the appropiate option before compiling. The option 'Initially Hidden' applies only to child windows, where a form will be invisible when it is first started. Methods are also compiled to allow hiding and unhiding the form. <p>Multiple forms can be created or open and edited simultaneously. If you are working on multiple forms saving a session ( from the Form Toolbar ) will allow you to resume where you stopped off.</p> <p>When a form is compiled to disk it will use the same name as the binary form file but with a .frm extension. If a form has been designed and compiled and will not need to be modified at a later time the corresponding binary .ff file can be deleted if desired.</p> <br> <p>To set the position of the compiled form on screen move the mini window in the Monitor window or alternatively set the position in the form property window .</p> <p>The status window in the Form Designer Tab window displays some properties of the currently selected control.</p> <center><img src="FormDesignerTab.gif" alt="" border="0"></center> <A HREF="Code Window.htm">Adding code to a form at design time</A> <hr> <p><A HREF="Form Designer.htm#Index"><img src="back.gif" align="absmiddle" border=0>Back to main page</A></p> </body> </html> |