Controls, Events, Commands, and More Microsoft Visual FoxPro 9 is here and it brings lots of new features.This entire issue of CoDe is dedicated to Visual FoxPro 9, providing details and scenarios on how you can use the new features and enhancements. In this article, I will discuss some of the new controls, events, and commands, and a little more. | " | The AppStates property indicates whether the application has focus (value 1), or not (value 0).
| " |
I'm sure you are as anxious as I am to explore new properties, events, and methods, new or improved commands, and FoxPro Foundation Classes (FFCs). Let's dive right in! Anchoring Controls Before Visual FoxPro 8, many lines of code had to be written in order to properly resize onscreen controls whenever a form was resized. In Visual FoxPro 8, that task got slightly easier with the introduction of the BindEvent function. In Visual FoxPro 9, it gets way easier with the introduction of anchoring. Anchors allow a control to maintain its proportional relationship with other objects and controls within a form, no matter what size the form becomes. The Anchor property is obeyed when the control sits on containers such as Forms, CommandGroups, and Page objects. Whenever those containers get resized, the controls within it that have the Anchor property set are resized and/or repositioned depending on the settings used. Make sure to check out the Anchor Property topic on the Help file for available settings. Docking Forms Docking allows toolbars and other controls to be "attached" to any user-chosen edge of a Form and maintain that positioning despite resizing or scrolling. Visual FoxPro 8 introduced the ability to dock objects, such as the Command, Document View, and Properties windows, as well commands and functions that handled docking programmatically. Visual FoxPro 9 goes a step further and introduces the docking capability to user-defined forms as well. That enables creating dockable Forms on the IDE or on the application delivered to the users. In order to support this feature, new members were added to the Form class, such as the Dockable and Docked properties, the Dock and GetDockState methods, and the AfterDock, BeforeDock, and UnDock events. Listing 1 shows a simple example that produces the result showed on Figure 1.  Figure 1: Docking user-defined windows is simple.Collection Object Support in ComboBox and ListBox Controls The RowSourceType property on ComboBox and ListBox objects has a new option added to the list of possible sources: value 10, for the Collection object. A Collection could be populated with Business objects or objects holding some sort of data, and that Collection can be used to populate ComboBoxes and ListBoxes. The following code snippet shows an example of that, using a collection named colEmployees contained in the form, and the ComboBox's RowSourceType property is set to 10. Select EmployeeId, FirstName; from employees into cursor curTemp
Scan Local loEmployee as Object Scatter NAME loEmployee Blank Scatter NAME loEmployee additive
This.colEmployees.Add(loEmployee,; Transform(loEmployee.EmployeeId)) EndScan
This.cboEmployees.RowSource =; "Thisform.colEmployees, FirstName, EmployeeId"
| & | | 
By: Claudio Lassala Claudio Lassala is a Senior Developer at EPS Software Corp. He has presented several lectures at Microsoft events such as PDC and various other Microsoft seminars, as well as several conferences and user groups across North America and Brazil. He is a multiple winner of the Microsoft MVP Award and also holds the MCSD for .NET certification.
He has articles published on several magazines, such as MSDN Brazil Magazine, CoDe Magazine, UTMag, Developers Magazine, and FoxPro Advisor.
Blog: http://claudiolassala.spaces.live.com
classala@eps-software.com | Fast Facts | | As is common with every new version of Visual FoxPro, new commands, properties, methods, and events are introduced. This article highlights some of these new features to make the introductions, but you'll want to look at the "What's New" section on the Help file, because there's a lot more in there. | |
|