Visual FoxPro TipsCovers Visual FoxPro Verison 3 and Visual FoxPro Version 5 |
Using the Path specified in the Applications Shortcut...
Setting the Path to the Database files using the Shortcut's Start in: setting...
Context Specific Menu... Hint: Right Click
Displaying Property Description on Properties for the Controls...
How I get Help for Visual FoxPro Programming questions...
When I try to exit my Visual FoxPro application, I get the following message "Cannot quit Visual FoxPro". How do I fix this?...
List of Code Characters for the @...GET FUNCTION and PICTURE...
Visual FoxPro Interactive Mode: I hit Alt+F4 or clicked on the Close Box and Lost a lot of Work. How do I stop this?...
Create a Julian Date (YJJJ and KYJJJ) from a Date (MM/DD/YYYY) (Year 2000 Compatible)...
Create a Date (MM/DD/YYYY) from a Julian Date (YJJJ and KYJJJ) (Year 2000 Compatible)...
Grid: How do I Add (Delete) a column(s) to an existing Grid Control?...
List of Code Characters for the FORMAT Attribute...
How do I Cascade the MDI Child Windows in my application?...
How do I Enable/Disable Menu options?...
How do I Print the contents of an Edit Box from the File | Print?...
How do I store a BITMAP Copy of my Applicaiton (or Full Screen) in the Windows Clipboard?...
Quick/Short Tips and Tricks... (Little explaination and NO Frills!)
Status line, Quick Menu, Close All, Help, Transform(), Report Designer: Preview
Tips and Tricks about using Microsoft's Technical Support Knowledge Base...
How do I add an Open Windows List to the end of my Windows Menu?...
How do I Arrange the Minimized MDI Child Windows in my application?...
Report Designer: How do I change the text of a label (not the sticky ones<G>) control?...
How to Index Descending in an Ascending Index or visa versa...
How do I pass command line arguments to my application?...
List of Selected Microsoft Knowledge Base Articles... (Updated!)
Microsoft's FTP (Download) Software Library...
How to Auto-Cascade MDI Child Windows...
|
These Tips and Tricks come from years of experience, from help that I've gotten from others, from books and other places (such as Compuserve). I've tried to identify and give credit to the people who have helped me along the way. Sadly, I haven't been about to identify everyone -- but I have tried. Most times the Tips or Tricks come from my own experience. If I have trouble with something or find something useful -- I figure that someone else might benifit. I hope that you find these Tips and Tricks useful. I refer to them from time to time. |
The path of interest is under the "Shortcut" tab of the Shortcut's Properties dialog. The "Start in:" text box contains the default path that Windows will establish when the Shortcut/Application is run.
At the time of startup, SYS(5) + SYS(2003) can be used to determine what the path is that was set in the "Start in:" field. SYS(5) is the default drive with colon and SYS(2003) is the default path, without a trailing "\" unless the path is the root directory.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/09/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The path of interest is under the "Shortcut" tab of the Shortcut's Properties dialog. The "Start in:" text box contains the default path that Windows will establish when the Shortcut/Application is run.
The "SET PATH TO" command is used to set the default path that FoxPro should use to find the database files. The path can be set to a subdirectory under the path specified in the Application's Shortcut's "Start in:" field by,
SET PATH TO SYS(5) + SYS(2003) + "\DBF\"
Where SYS(5) is the default drive with colon and SYS(2003) is the default path, without a trailing "\" unless the path is the root directory. "\DBF\" can be a hardcoded string, as above, or a variable containing the path with the leading and trainig "\".
If you think that your user might designate a root directory, then you need to check the return value from SYS(2003) to see if the last character is a "\". This can be done with if(RIGHT(sys(2003),1) = "\") then...endif.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/09/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
As in Windows/95, RIGHT Clicking on an object -- most likely will bring up a Context Specific Menu.
When in doubt -- Right Click! -- to find out
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/09/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
When you're configuring a control (Grid, TextBox, Command Button, etc) there is a Properties Display Dialog. This Dialog is used to set the attritributes for the control. The Dialog can be configured to display a short description of the current Property (Class, Delete event, ZOrder, etc). This is done by RIGHT Clicking on the Title bar "Properties - ..." and checking the "Properties Descriptions". Other attributes that you can set are... "Always on top", "Non-Default Properties only", Font size (small, medium, large) and get some Help.
"Always on top" in VFP/3 is set by clicking on the icon that looks like a thumb tack or push pin.
Platform: Windows/95
FoxPro: VFP/5
Recorded: 06/09/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
| FoxPro Help |
|
| Compuserve VFOX
Forum |
(Please note, that my Compuserve Account is a personal account, ie, not paid for by my employer. I feel that this is a worthwild investment for me to help me keep up with the current trends in programming -- thus helping me do a better job and hopefully earn a better salary.) |
| World Wide Web |
|
| Books |
(Please note, I am an Amazon.com Associate. Which basically, means that I get some monies from any books that are purchased through links from my page. Prior to (and after) becoming an Amazon.com Associate, I purchased a lot of books. As it stands right now -- I will not be able to quite my day job because of all the revenue that I'm getting <g>) (Another note, I purchase most of the books I have myself, ie, my employer does not pay for them. I feel that this is a worthwild investment for me to help me do a better job and hopefully earn a better salary.) |
| Magazines |
|
| Developer Conferences,
Conferences, Trade Shows and Courses |
|
| Personal Interaction |
|
| Other Technical Resources |
|
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/10/1998 .. 06/29/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Or another way to put this... Why doesn't the Close Box ([x] button) on the Window Title bar or the Alt+F4 key combination work?
There is probably a READ EVENTS in effect and they need to be Cleared with a CLEAR EVENTS command, before your application can close. The best way to do this is by setting up an ON SHUTDOWN routine.
The best way to set up an ON SHUTDOWN routine is to put in code that looks something like...
ON SHUTDOWN DO pSHUTDOWN OKtoShutDown = .T.
...at the top of your application or add a custom property to your application class.
The pSHUTDOWN Procedure, that is called ON SHUTDOWN, would look something like...
PROCEDURE pSHUTDOWN
IF (OKtoShutDown) THEN
** Close databases and do other cleanup
CLOSE DATABASE
CLOSE ALL
** Clear the READ EVENTS
CLEAR EVENTS
** Clears the assignment to ON SHUTDOWN, Only important if ever run in
** Interactive Mode.
ON SHUTDOWN TO
** Quit the application
QUIT
ELSE
=MessageBox("Unable to exit the application", 48, "Application Busy...")
ENDIF
RETURN
** end-of-pSHUTDOWN
If you don't want the user to exit the application, because something important is being done and should not be interrupted, then set OKtoShutDown to .F. If the user tries to exit the application, they will get a message saying that the application is busy and can not be exited at this time. Be sure to set OKtoShutDown to .T. or the user will never be able to exit.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/11/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
@ ... GET - Text Box Command
FUNCTION cFormatCodes | PICTURE cFormatCodes
Specifies a function code or picture code that determines how the text box output is displayed or printed. You can include the FUNCTION clause, the PICTURE clause, or both to create an editing mask. These clauses contain special codes that control how the memory variable, array element, or field is displayed and edited. FUNCTION codes can be included in a PICTURE clause. In this case, the PICTURE clause must start with @. Also, a PICTURE clause can contain FUNCTION codes, PICTURE codes, or both. Since a FUNCTION clause affects the entire expression, it can contain only FUNCTION codes.
FUNCTION
Code Purpose
A Allows alphabetic characters only (no spaces or
punctuation marks).
B Left-justifies numeric data within the text box.
D Uses the current SET DATE format.
E Edits Date-type data as a BRITISH date.
I Centers text within the text box.
J Right-justifies text within the text box.
K Selects the entire text box when the cursor is
moved to the text box.
L Displays leading zeros (instead of spaces) in the
text box. Use with numeric data only.
MList Creates multiple preset choices. List is a
comma-delimited collection of items. Individual
items within the list cannot contain embedded
commas. If MemVarName or FieldName initially do
not contain one of the items in the list when
READ is issued, the first item in the list is
displayed. To scroll through the list, press the
Spacebar or type the first letter of an item. To
choose one of the items and move to the next
control, press Enter. Use with character data only.
R Displays a format mask in a text box. These mask
characters are not stored to the field when you
exit the text box. Use with character or numeric
data only.
Sn Limits the text box to n characters. You can scroll
within the region with the cursor control keys.
Use with character data only.
T Trims leading and trailing blanks from MemVarName
or FieldName.
Z Displays MemVarName or FieldName as blank if its
numeric value is 0. Use with Numeric data only.
! Converts alphabetic characters to uppercase. Use
with Character data only.
^ Displays numeric data using scientific notation.
Use with Numeric data only.
$ Displays the currency symbol before numeric data.
Use with numeric data only.
A PICTURE expression can include any characters, but only
the characters listed below determine how the text
box is displayed and edited.
Source: Visual FoxPro Version 3 Help File
PICTURE
Code Purpose
A Allows the entry of alphabetic characters only.
L Allows the entry of logical data only.
N Allows the entry of letters and digits only.
X Allows the entry of any character.
Y Allows you to enter Y, y, N, and n for the logical
values true (.T.) and false (.F.), respectively.
9 Allows entry of only digits in character data.
Allows entry of digits and signs in numeric data.
# Allows entry of digits, blanks and signs.
! Converts lowercase letters to uppercase letters.
$ Displays the current currency symbol specified by
SET CURRENCY. By default, the symbol is placed
immediately before or after the numeric value.
However, the currency symbol and its placement
(SET CURRENCY), the separator character
(SET SEPARATOR), and the decimal character
(SET POINT) can all be changed.
* Asterisks are displayed in front of a numeric value.
Use with a dollar sign ($) for check protection.
. A decimal point specifies the decimal point position.
, A comma is used to separate digits to the left of
the decimal point.
Source: Visual FoxPro Version 3 Help File
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/14/1998
Edided: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Basically, you need to create a program that warns you that the SHUTDOWN event has happened. The following will do just that...
Create a program with the following (or similar) code, or copy/paste what I have here. I called my program VFPSYSQUIT.PRG and saved it in my Visual FoxPro directory.
* VFPSYSQUIT.PRG 06/15/1998 06/15/1998
local OK2QuitVFP && Is it OK to quit the Visual FoxPro Application?
&& Interactive Mode, Prevent Accidental Quiting
OK2QuitVFP = messagebox( "Are you sure you really want to quit Visual FoxPro?";
+chr(13)+chr(13)+;
"(Before saying Yes, make sure you have saved your work)",;
4+16+256, "Quit Visual FoxPro?")
* 4 for Yes/No Button ; see MessageBox in FoxPro Help File
* 16 for Stop Sign
* 256 default button is the second one
if( OK2QuitVFP = 6) then && see MessageBox in FoxPro Help File, 6 is for Yes
quit
endif
* end-of-VFPSYSQUIT.PRG
Installing your "Are you sure?" program....
In the Command Window type ...
ON SHUTDOWN DO \VFP\VFPSYSQUIT.PRG
Include the approprate drive, path and filename for your situation.
or add the following line to your CONFIG.FPW file, normally in your Visual FoxPro directory...
COMMAND = ON SHUTDOWN DO \VFP\VFPSYSQUIT.PRG
Be sure to include the approprate drive, path and filename for your situation.
Adding this to your CONFIG.FPW will elimate you forgetting to enter the command through the Command Window. Test the program, before you start using it realtime, to make sure that it is working correctly and that it is being loaded.
I have included some the nDialogBoxType codes used by MESSAGEBOX() and some other basic information about MESSAGBOX(). Refer to the Visual FoxPro Help file for more information about MESSAGEBOX().
MESSAGEBOX() Function
Displays a user-defined dialog box.
Syntax
MESSAGEBOX(cMessageText [, nDialogBoxType [, cTitleBarText]])
Omitting nDialogBoxType is identical to specifying a value of 0 for nDialogBoxType.
Value Dialog box buttons
0 OK button only.
1 OK and Cancel buttons.
2 Abort, Retry, and Ignore buttons.
3 Yes, No, and Cancel buttons.
4 Yes and No buttons.
5 Retry and Cancel buttons.
Value Icon
16 Stop sign.
32 Question mark.
48 Exclamation point.
64 Information (i) icon.
Value Default button
0 First button.
256 Second button.
512 Third button.
nDialogBoxType can be the sum of up to three values; one value from each of the preceding tables. For example, if nDialogBoxType is 290 (2+32+256), the specified dialog box has the following characteristics:
* Abort, Retry, and Ignore buttons. * The message box displays the question mark icon. * The second button, Retry, is the default.
Remarks
The value MESSAGEBOX() returns indicates which button in the dialog box was chosen. In dialog boxes with a Cancel button, pressing ESC to exit the dialog box returns the same value (2) as choosing Cancel.
The following table lists the values MESSAGEBOX() returns for each button.
Return value Button 1 OK 2 Cancel 3 Abort 4 Retry 5 Ignore 6 Yes 7 No
Source Visual FoxPro Version 5 Help File
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/15/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The format that I use for Julian date is YJJJ, were Y is the last digit of the year, ie, 1998 would be 8. The JJJ is the number of the day in the year. January 1st is 1, February 15th is 46, etc. This format is not appropriate for the change of the century, Y2K, or for changing decades, 1980 to 1990. I've added a character to the front of the string, so the format it KYJJJ. K is a letter, "A", "B", "C", etc. "A" is for 199, "B" is for 200, "C" is for 201, etc.
Create a Julian date using a date string
yrDate = str(year(ctod(strDate))) && Year of the Date, 4 digit year
yrcDate = right(yrDate, 1) && last digit of the year 1998 --> 8
* Format: YJJJ, Add 1; 1/1/98 - 1/1/98 should equal 1
JDate = yrcDate + PADL(ctod(strDate) - ctod("01/01/"+yrDate) + 1, 3, "0")
* Y2K, Possible Solution. Increase the Julian date a variable to
* 5 character field
*
* A> 1990 - 1999, B> 2000 - 2009, C> 2010 - 2019, etc
*
* Does not support dates earlier that 1990, if earlier dates are needed
* -- have "A" represent the earlies date, ie, let say you need dates of
* 1970 and later - "A" would be for 197, "B" for 198, "C" for 199, etc.
*
* 1998> 199; 1999> 199; 2000> 200; 2001> 200; ... 2010> 201
yrFirst3 = val(left(yrDate, 3))
* A; 199, B; 200, C; 201, D; 202
cY2K = chr(asc("A") + (yrFirst3 - 199))
JDate = cY2K + JDate && Format: KYJJJ ;K - Y2K Character
Create a Julian date using a date variable
yrDate = str(year(dteDate)) && Year of the Date, 4 digit year
yrcDate = right(yrDate, 1) && last digit of the year 1998 --> 8
* Format: YJJJ, Add 1; 1/1/98 - 1/1/98 should equal 1
JDate = yrcDate + PADL(dteDate - ctod("01/01/"+yrDate) + 1, 3, "0")
* Y2K, Possible Solution. Increase the Julian date a variable to
* 5 character field
*
* A> 1990 - 1999, B> 2000 - 2009, C> 2010 - 2019, etc
*
* Does not support dates earlier that 1990, if earlier dates are needed
* -- have "A" represent the earlies date, ie, let say you need dates of
* 1970 and later - "A" would be for 197, "B" for 198, "C" for 199, etc.
*
* 1998> 199; 1999> 199; 2000> 200; 2001> 200; ... 2010> 201
yrFirst3 = val(left(yrDate, 3))
* A; 199, B; 200, C; 201, D; 202
cY2K = chr(asc("A") + (yrFirst3 - 199))
JDate = cY2K + JDate && Format: KYJJJ ;K - Y2K Character
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/16/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The format that I use for Julian date is YJJJ, were Y is the last digit of the year, ie, 1998 would be 8. The JJJ is the number of the day in the year. January 1st is 1, February 15th is 46, etc. This format is not appropriate for the change of the century, Y2K, or for changing decades, 1980 to 1990. I've added a character to the front of the string, so the format it KYJJJ. K is a letter, "A", "B", "C", etc. "A" is for 199, "B" is for 200, "C" is for 201, etc.
YJJJ Julian Date Format: Create a Date (MM/DD/YYYY) using a Julian date string
yrcDate = left(jdate,1) && last digit of the year 1998 --> 8
yrDate = "199"+yrcDate && Year for the Date, ASSUME 199
* Create the date for January 1st of the Year, add the
* Julian Date number and then subtract 1 to make it right.
* January 1st is Julian number 1, not 0
dteDate = ctod("01/01/"+yrDate) + val(right(jdate,3)) - 1 && Date format
strDate = dtoc(dteDate) && Date in a string variable
KYJJJ Julian Date Format: Create a Date (MM/DD/YYYY) using a Julian date string
kcDate = left(kjdate,1) && Get the "A", "B", "C", etc
yrcDate = right(left(jdate,2),1) && Get the Year digit
* Create the year based on the "A", "B", "C", etc plus the Year Digit
* Calculate the ASCII Value difference between "A" (meaning 199) and the
* kcDate character. Add the difference to 199. For example, "B" - "A" = 1,
* add 1 to 199 to get 200. "B" stands for "200"
yrDate = str(199+(asc(kcDate)-Asc("A")))+yrcDate
* Create the date for January 1st of the Year, add the
* Julian Date number and then subtract 1 to make it right.
* January 1st is Julian number 1, not 0
dteDate = ctod("01/01/"+yrDate) + val(right(jdate,3)) - 1 && Date format
strDate = dtoc(dteDate) && Date in a string variable
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/16/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
DON'T USE the Grid Builder. If you do, you will be sorry... Trust me I KNOW from experience!
Adding a column(s) to an exiting Grid Control
Adding a column(s) to the control is not hard, it's the configuring that takes the time.
Here are the steps required to add a column(s) to your existing Grid Control. Click on the Grid Control, to make it the active control. In the Properties dialog you should see the name of your Grid in the drop down list box. If you do, find the ColumnCount Attribute and change it to the total number of columns you want in your control. If you're adding, then the new number should be larger than what is there<grin>. Click on the check mark and save as normal.
That's it, if the new number is larger than it was -- you will have X number of new columns added to the end of your grid. If the number is smaller, then you lost X number of columns from the end.
At this point you will have to configure the new column(s) -- set the Heading, ControlSource, InputMask, StatusBarText, etc.
If you need to change the order of the Columns then you will be updating the ColumnOrder Attribute under the Column (ColumnXX) data.
Deleting a column(s) in an exiting Grid Control
Warning! Warning! Warning! the columns that are removed are the ones at the right end of the grid. If you don't want these columns removed, then you need to rearrange your Grid so that the ones that are on the right end are the ones that you want removed.
To delete a column(s) from your existing Grid Control, you need to Click on the Grid Control, to make it the active control. In the Properties dialog you should see the name of your Grid in the drop down list box. If you do, find the ColumnCount Attribute and change it to the total number of columns you want. Click on the check mark and save as normal.
The columns that are removed are the ones from the right end.
Remember and NEVER FORGET!, the changes DO NOT take effect until you save. If you're not happy with the change(s), close the Form with the Grid and say NO to the save question.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/17/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
FORMAT Property
Specifies the input and output formatting of a control's Value property. Available at design time and run time.
The Format Attribute sets the properties for the field as a whole. Whereas, the InputMask is a character by character format for the field.
Refer to your Visual FoxPro Help File for more information about Format and InputMask.
The valid cFunction settings for an EditBox control are:
Setting Description
K Selects all the text when the control gets the focus.
The valid cFunction settings for a Spinner control are:
Setting Description
$ Displays the currency symbol.
^ Displays numeric data using scientific notation.
K Selects all the text when the control gets the focus.
L Displays leading zeros (instead of spaces) in the text box.
R Displays the format mask for the text box that is specified in the
InputMask property. The mask formats data for easier entry and
clearer display (for example, if the mask is 99-999, the number
12345 is displayed as 12-345), but is not stored as part of the
data. Use only with character or numeric data.
Z Displays the value as blank if it is 0 except when the control has
the focus.
The valid cFunction settings for a TextBox control and Column object are:
Setting Description
! Converts alphabetic characters to uppercase. Use with Character
data only.
$ Displays the currency symbol. The ControlSource property must
specify a numeric source for the textbox.
^ Displays numeric data using scientific notation. The ControlSource
property must specify a numeric source for the textbox.
A Allows alphabetic characters only (no spaces or punctuation marks).
D Uses the current SET DATE format.
E Edits Date values as British dates.
K Selects all the text when the control gets the focus.
L Displays leading zeros (instead of spaces) in the text box. The
ControlSource property must specify a numeric source for the
textbox.
M Included for backward compatibility.
R Displays the format mask for the text box that is specified in the
InputMask property. The mask formats data for easier entry and
clearer display (for example, if the mask is 99-999, the number
12345 is displayed as 12-345), but is not stored as part of the
data. Use only with character or numeric data.
T Trims leading and trailing blanks from the input field.
YS Displays Date values in a short date format determined by the
Windows Control Panel short date setting.
YL Displays Date values in a long date format determined by the
Windows Control Panel long date setting.
The Format property specifies a behavior for the entire input field. You can mix several Format codes, but they always affect everything in the input field. This property contrasts to the InputMask property in which each entry in the input mask corresponds to an entry in the input field.
Source Visual FoxPro Version 5, Help File
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/17/1998
Edited: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Visual FoxPro only provides an "Arrange All" option. This option Tiles the MDI Child Windows. I prefer the Cascade, it is more useful for my current need and I want to provide a Cascading option for my users. It is an option that users expect and is consistant with other Windows Applications.
I ran across some Visual FoxPro code by Mike Lewis, [eMail] [Homepage], to do this. (Drop by Mike's webpage and see his FoxStuff for his Tips and Tricks. His cascade routine is there. If you need some consulting work, he might be the consultant for you.) He got me started, but like most programmers -- I couldn't leave it alone <G>. I have made several changes and enhancements to his original code.
When I first started looking for a way to Cascade the Child Windows, Brad Schulz, [eMail], of the Visual FoxPro Forum (GO VFOX) gave me some very basic code. Based on what Mike and Brad told me, here is what I came up with...
Advertizement: If you are not a member of Compuserve I highly recommend that you join. The Visual Fox Forum (GO VFOX) is an outstanding resource. For example, I posted a question in the VFOX Forum, right after lunch, and within 2 to 3 hours, that day -- I had the enhancement added to my program. I had gotten a reply, with the information that I needed, and with that information was able to implement the enhancement. I don't know of another resource that can provide that kind of timely help. If you are a memeber and you don't drop by -- then you should start. There are other wonderful forums - covering - Visual Basic, PowerBuilder, Visual C++, etc.
I have included the following code in my Windows | Cascade (\<Cascade) Procedure...
* Cascade MDI Child Windows by Richard Hendricks 06/19/1998 .. 08/11/1998
local lnNewWidth, lnNewHeight, lnNewLeft, lnNewTop, lnFmIdx
local lnTopOffset, lnLeftOffset, slnNewLeft, slnNewTop
local lnNumToCascade, lnLeftCouldFit, lnTopCouldFit, lnWinCouldFit, llForceULeft
llForceULeft = .f.
lnTopOffset = Sysmetric(9) * 1.2 && horizontal offset, height of
&& Window Title bar; add some to space it out some
lnLeftOffset = Sysmetric(9) * 1.2 && vertical offset
lnNewWidth = 0.80 * _SCREEN.Width && new window width
lnNewHeight = 0.70 * _SCREEN.Height && new window height
* Handle very small main MDI Windows
IF(lnNewWidth < 3 * lnLeftOffset) THEN
lnNewWidth = 3 * lnLeftOffset
ENDIF
IF(lnNewHeight < 3 * lnTopOffset) THEN
lnNewHeight = 3 * lnTopOffset
ENDIF
* Determine how many windows there are to cascade
lnNumToCascade = 0
FOR lnFmIdx = 1 TO _SCREEN.FormCount
WITH _SCREEN.Forms(lnFmIdx)
* Don't count mimimized windows
IF (Type(".WindowState")<>"U" AND .WindowState = 1) THEN
LOOP
ENDIF
lnNumToCascade = lnNumToCascade + 1
ENDWITH
ENDFOR
lnNewLeft = _SCREEN.Width - lnNewWidth - 10
lnNewTop = _SCREEN.Height - lnNewHeight - 10 - SysMetric(9) && account for status line
lnLeftCouldFit = Int(lnNewLeft / lnLeftOffset)
lnTopCouldFit = Int(lnNewTop / lnTopOffset)
lnWinCouldFit = Min(lnLeftCouldFit, lnTopCouldFit)
IF(lnWinCouldFit <= 0) THEN
lnWinCouldFit = 1 && force left/top to be 0, 0 for all windows
&& very small Main MDI Frame
llForceULeft = .t.
ENDIF
* Fewer than, equal to the number of Windows to Cascade, (or Force Upper Left)
* than there is room for
* Note: if only 1 Window to Cascade, position it at 0, 0
IF (lnNumToCascade <= lnWinCouldFit or llForceULeft = .t.) THEN
lnNewLeft = (lnLeftOffset * (lnNumToCascade-1))
lnNewTop = (lnTopOffset * (lnNumToCascade-1))
ELSE
* More Windows to Cascade, than there is room for -- layers of
* Cascaded Windows
lnNewLeft = (lnLeftOffset * (lnWinCouldFit))
lnNewTop = (lnTopOffset * (lnWinCouldFit))
ENDIF
slnNewLeft = lnNewLeft && save starting position
slnNewTop = lnNewTop && save starting position
FOR lnFmIdx = 1 TO _SCREEN.FormCount
WITH _SCREEN.Forms(lnFmIdx)
* Don't resize/cascade mimimzied windwos
IF (Type(".WindowState")<>"U" AND .WindowState = 1) THEN
LOOP
ENDIF
* If resizable then Resize it
IF (Type(".BorderStyle")<>"U" AND .BorderStyle = 3) THEN
* Set window height and width, windows resize event will
* take care of min/max values
.Width = lnNewWidth
.Height = lnNewHeight
ENDIF
* Move the Window to its new position
IF ((lnNewTop >= 0) and (lnNewLeft >=0)) then
* The window will fit on the main window, ok
.Move(lnNewLeft,lnNewTop)
* Calculate the position of the next window
lnNewLeft = lnNewLeft - lnLeftOffset
lnNewTop = lnNewTop - lnTopOffset
ELSE
* Window would be off the main window, so go back
* to original top and left corner
.Move(slnNewLeft, slnNewTop)
lnNewLeft = slnNewLeft - lnLeftOffset
lnNewTop = slnNewTop - lnTopOffset
ENDIF
ENDWITH
ENDFOR
* end-of-Cascade
Comments...
Related Tips...
I hope that you find this useful. If you find any problems or have any suggestions, please let me know.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/20/1998 .. 08/11/1998
Helper: Mike Lewis [eMail]
[Homepage]
Helper: Brad Schulz [eMail]
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Sometimes, you do not want your user to be able to select a menu option while they are in the process of using that option. For example, they are in the configure application dialog. You wouldn't want them to have two instances of that dialog open at the same time.
Other times you might not want them to select a Menu option because all the requirements for the option are not present. For example, a certain file is not available, there is nothing to print, there isn't anything selected -- so they can't copy to clipboard, etc. These situations can be handled by using the "Skip for" attribute for the selection or by the following.
Menu's are made up of pads or options that the user can select. You can enable/disable the selection on the Menu bar (effectively disabling all the sub selections) or individual entries on a menu.
To enable/disable an entry on a menu, lets say the "Configure" option on the "Options" menu, you would do the following...
You need to set or determine the Bar Number for the "Configure" selection. Let's say it is 56.
To set it, in the Menu Builder, you would find the "Configure" entry on the "Options" Menu (similar to File, Window, etc). Click on the "Configure" line and under the "Options" column - click on the little gray button. This will bring up a dialog box that has several entries on it.. "Key Label", "Skip for", "Bar #", "Message", etc. In "Bar #" field, enter the number you want the bar to have. In this case enter 56. Press the OK button and save the menu.
I assign these based on the location of the selection within the whole menu system. In this example, the "Options" Menu is the 5th selection on the menu bar and "Configure" is the 6th selection under it. The Bar numbers can be duplicated across menus, File, Edit, ..., Window, Help, because you use the number and the name to designate what selection to enable/disable.
Disable the "Configure" selection...
In the INIT Event of the form that is opened when you click on "Configure" Selection, put...
SET SKIP OF 56 OF OPTIONS .T.
Enable the "Configure" selection...
In the Destroy Event of the form that is opened when you click on "Configure" Selection, put...
SET SKIP OF 56 OF OPTIONS .F.
When the user selects the "Configure" option, the form will disable the menu selection. When the user closes the form, the menu selection will be enabled.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/20/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
I needed to be able to print the contents of an Edit Box from the File | Print menu selection. There could be multiple instances of the Form and Edit Box with different text. So, I needed to make sure that I printed the correct text. This technique can be used to print text in labels, Text Boxes, database fields, variables, etc.
I have a PUBLIC variable prTextToPrint that is declared in the startup program. I set the value of prTextToPrint to "". If prTextToPrint is empty, then the File | Print selection is disabled.
Whatever text is stored in prTextToPrint will be printed, so you can put whatever text you need printed in prTextToPrint. For example, you could load the contents of a Grid or the text from all the Text Boxes and Edit Boxes on the form.
In the "Skip for" of the "Print" selection, put "empty(prTextToPrint)" (without the quotes).
To set this, using the Menu Builder, you would find (or create) the "Print" entry on the "File" Menu. You need to have your own "Print", not the one FoxPro give you with Quick Menu -- because you want to have control of it. Click on the "Print" line and under the "Options" column - click on the little gray button. This will bring up a dialog box that has several entries on it.. "Key Label", "Skip for", "Bar #", "Message", etc. In "Skip for", enter "empty(prTextToPrint)" (without the quotes). Press the OK button. Save the menu.
In the "Activate" Event of any form that will be using the File | Print selection. Set the value of prTextToPrint to the text that you want printed. In the case of my Edit Box, I had something like THISFORM.edtViewDetails.Text. When the user selects the form, then the appropriate text will be loaded into prTextToPrint. This will enable the File | Print selection.
In the "Deactivate" and "Destroy" Event of these forms, set the value of prTextToPrint to "". When the user leaves the form or closes it -- prTextToPrint will be cleared, thus disabling the File | Print selection.
The following routine is in the File | Print Procedure. The user is ask what printer (GETPRINTER()) to print to. If the user selects one, then the text (if there is any), in prTextToPrint, will be printed -- otherwise nothing is printed. The status of the printer is checked (PRINTSTATUS()). The user is notified when the printing is done and if there is a problem.
You might want to remove the message about the printing being done or replace it with a "WAIT ... WINDOW TIMEOUT nSec.".
prSelected = GETPRINTER()
IF(LEN(TRIM(prSelected)) > 0 and !EMPTY(prTextToPrint)) THEN
SET PRINTER TO NAME (prSelected)
if(PrintStatus() = .t.) then
SET PRINTER ON
?? prTextToPrint
EJECT
SET PRINTER OFF
SET PRINTER TO
=messagebox("Report Printed...", 0, "Print")
else
=messagebox("There is a problem with the printer", 0+16,;
"Printer problem...") && Stop Sign
endif
ENDIF
This routine uses the standard FoxPro font. You can add to the routine the specifying of the Font, Size and Style with SET FONT. Refer to the Visual FoxPro Help File.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/20/1998
Helper: Brad Schulz [eMail]
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The following technique uses a Windows API call to perform the equivalent of Alt-PrintScreen (copy window to clipboard) and PrintScreen (copy screen to clipboard). I found this information from a Tip by Matt Hart, [eMail] [Homepage], PRNTFORM.ZIP. His tip is for Visual Basic and with some minor changes I was able to convert it to Visual FoxPro code.
Matt's copyright notice and disclaimer.
Copyright 1997 by Matt Hart
All Rights Reserved.
This software is FREEWARE. You may use it as you see fit for
your own projects but you may not re-sell the original or the
source code. If you redistribute it you must include this
disclaimer and all original copyright notices.
No warranty express or implied, is given as to the use of this
program. Use at your own risk.
Save BITMAP Copy of Application to Clipboard..
In Visual FoxPro or other MDI Applications, you can not just capture the current MDI Child Window to the Windows Clipboard. In the case of an MDI Application, the whole application will be captured to the Windows Clipboard.
DECLARE keybd_event IN Win32api integer bVk, integer bScan,;
long dwFlags, long dwExtraInfo
= keybd_event( 44, 0, 0, 0 )
Save BITMAP Copy of Whole Screen to Clipboard..
DECLARE keybd_event IN Win32api integer bVk, integer bScan,;
long dwFlags, long dwExtraInfo
= keybd_event( 44, 1, 0, 0 )
Note: Windows API function names are case sensitive.
Note: Visual FoxPro Version 3, you may need to replace the "long" with "integer".
Additional Reference:
Platform: Windows/95 and Windows/NT
FoxPro: VFP/3 and VFP/5
Recorded: 06/22/1998 .. 06/24/1998
Helper: Matt Hart
[eMail]
[Homepage]
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Writing to the MDI Frames Status line
SET MESSAGE TO [text]
* OR *
Set the StatusBarText Attribute
06/20/1998Getting Visual FoxPro to generate a Quick Menu
File | New
Select Menu radio button
Click on New file button
Click on Menu button
Menu | Quick Menu
Note: Quick Menu is only available on a new/empty menuAdding Menu Option: "Close All" MDI Child Windows
Open up your menu in the Menu Builder
Find the location in your menu system, where you want Close All. Typically, this is on the Windows Menu.
Position the cursor on the entry above which you want Close All
Click on Insert Bar...
From the Insert System Menu Bar dialog, select Close All
Click on the Insert button
06/20/1998Quick Help for a Topic
In the FoxPro Command Window you can type in Help topic
You can also get help by highlight the topic and press F1
The topic you type in or highlight can be just a partial spelling of a topic title
06/21/1998TRANSFORM() has some interesting options
Convert Decimal Number to Hexidecimal Number
? TRANSFORM( 10, "@0") ; 0x0000000A
Function to convert Hexidecimal to Decimal
FUNCTION Hex2Dec
*-- This function converts Hexidecimal (Char) to Decimal (Integer).
*-- Input: Character
*-- Output: Numeric
PARAMETERS InStr
InStr=ALLTRIM(InStr)
PRIVATE ALL LIKE J*
jLen=LEN(InStr)
nSum=0
rPtr=0
FOR nCtr= 1 TO jLen
cPtr=UPPER(SUBSTR(InStr,jLen-rPtr,1))
DO CASE
CASE cPtr='A'
cPtr='10'
CASE cPtr='B'
cPtr='11'
CASE cPtr='C'
cPtr='12'
CASE cPtr='D'
cPtr='13'
CASE cPtr='E'
cPtr='14'
CASE cPtr='F'
cPtr='15'
ENDCASE
nSum=nSum+(VAL(cPtr) * 16^(nCtr-1))
rPtr=rPtr+1
ENDFOR
RETURN(nSum)
Convert Logical .T./.F. to Y/N
? TRANSFORM( .T., "Y") ; Y
Format Codes Description @C CR is appended to positive currency. @D Date and DateTime values are converted to the current SET DATE format. @E Date and DateTime values are converted to a BRITISH date format. @T Leading and trailing spaces are trimmed from character values. @X DB is appended to negative currency. @Z If 0, currency or numeric values are converted to spaces. @( Encloses negative currency or numeric values in parentheses. @^ Converts currency or numeric values to scientific notation. @0 Converts numeric or currency values to their hexadecimal equivalents. ! Converts character data to uppercase. $ Adds the current currency symbol. X Specifies the width of character values. Y Converts logical true (.T.) and false (.F.) values to Y and N. ! Converts lowercase characters to uppercase. . Specifies the decimal point position in currency and numeric values. , Separates digits to the left of the decimal point. See Visual FoxPro Help File for more information.06/23/1998
Report Designer: How do I Preview the Report that I'm working on?
In VFP/5, I do not see a Preview selection on any of the menus. There is a Run on the Report Menu and a "!" on the toolbar. Run wants to direct the report to a printer or a file.
Right click on the background of the Report. You will get a popup menu with "Preview" on it.
** OR **
Select View | Preview from the Visual FoxPro Menu.
** OR **
Click on the Preview Icon on the Toolbar. The Icon is a white piece of paper with a magnifying glass and it is to the right of the Print Icon.
06/28/1998 .. 07/09/1998Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/20/1998 .. 07/09/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The Microsoft Technical Support Knowledge Base Homepage is a good place to start for information about Visual FoxPro (and other Microsoft Products).
The Basic search allows for you to select the Product, Visual FoxPro, and then enter your question. Then you click on the "Find" button.
If you don't have a question and simply want to browse the articles, then you might try some of the following...
Search on...
Try these links...
Notes:
Some interesting articles that I found...
See my Tip entitled List of Selected Microsoft Knowledge Base Articles... for more articles
This was written with Visual FoxPro for Windows/95 in mind, but it can be applied to Windows 3.1, DOS and Macintosh -- as well as other products like Visual Basic, Excel, Word, etc.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/24/1998 .. 07/10/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
It is common for MDI (Multiple Document Interface) Windows Applications to have a list of open MDI Child Windows. The Visual FoxPro application has this list, but it is not obvious how to implement this feature.
I found the required information in one of Microsoft's Knowledge Base Articles. The article is How to List the Currently Active Windows in a Menu.
The article described what is reqired and how to write code to enable this feature. My tip describes how to do enable it through the Menu Builder.
There are two things that are required. 1) The reserved name _MWINDOW must be used as the name of the menu popup. 2) There must be at least one menu bar (menu option) entry on the menu.
The article also seems to imply that other things are required. For
example, that there needs to be a pad called "----Active----" that is
disabled and that when the Window menu is selected that it needs to execute
RETURN "". These are not required.
I am assuming that you already have a menu system defined and you have a sub menu, ie, Windows, that you want the Open Window List to be added to.
If not, you need to create one. I have a tip about how to get FoxPro to generate a Quick Menu. You can also get what you need from the Visual FoxPro Help file.
OK, let's get started...
Open the Menu Builder and select the Menu Title, ie, \<Window, that you want the list added to. I'm assuming that you are going to add the list to the Window Menu.
Click on the Edit button on the \<Window line.
Click on the Menu Level Drop Down List box and insure that the entry relatd to the Window menu is selected.
Go to the FoxPro System Menu and select View | Menu Options
On the Menu Options dialog window, set the name to _MWINDOW. It is very important that you use this exact name. Case of the letters does not matter.
Click on the OK button.
If you have entries on your Window Menu, for example, Arrange All, Cycle, etc. Save the menu and build your applicaiton.
You should see the list of MDI Child Windows at the end of your Window menu.
If you do not have entries on your Window Menu, here are some you might add.
Click on the Insert Bar... and select Arrange All. This is towards the end of the list. Click on OK. I changed the prompt to \<Tile. It's a little more Windows type terminology.
Click on the Insert Bar... and select Close All. This is towards the beginning of the list.
Click on the Insert Bar... and select Cycle. This is towards the end of the list. Click on OK.
Save and Build your application. You should see the list of MDI Child Windows at the end of your Window menu.
Related Tips...
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/24/1998 .. 08/11/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Visual FoxPro only provides an "Arrange All" option. This option Tiles the MDI Child Windows and does nothing with the Minimized MDI Child Windows. I wrote a Cascade MDI Child Windows routine to give my users the ability to cascade the child windows. I also wanted to provide my users with the ability to arrange the icons, or minimized Child Windows of the MDI Application. Arrange Icons is an option that users expect and is consistant with other Windows Applications.
I have included the following code in my Windows | Arrange Icons (Arrange \<Icons) Procedure...
* Arrange Minimized MDI Child Windows by Richard Hendricks 06/28/1998 .. 06/28/1998
LOCAL lnNewLeft, lnNewTop, lnFmIdx, lnMinWinHeight, lnMinWinWidth
lnMinWinHeight = Sysmetric(17) * 0.8 && Trial and Error to determine this
lnMinWinWidth = Sysmetric(16) * 5 && Trial and Error to determine this
lnNewLeft = 0
lnNewTop = _SCREEN.Height - lnMinWinHeight
FOR lnFmIdx = 1 TO _SCREEN.FormCount
WITH _SCREEN.Forms(lnFmIdx)
* Don't arrange non-Minimized Windows
IF (Type(".WindowState")<>"U" AND .WindowState <> 1) THEN
LOOP
ENDIF
* Move the Minimized Window to its new position
.Move(lnNewLeft,lnNewTop)
* Calculate the position of the next Minimized Window
lnNewLeft = lnNewLeft + lnMinWinWidth
IF(lnNewLeft + lnMinWinWidth > _Screen.Width) THEN
lnNewLeft = 0
lnNewTop = lnNewTop - lnMinWinHeight
IF(lnNewTop <= 0) THEN
lnNewTop = _SCREEN.Height - lnMinWinHeight
ENDIF
ENDIF
ENDWITH
ENDFOR
* end-of-Arrange Minimized Windows
Comments...
Related Tips...
I hope that you find this useful. If you find any problems or have any suggestions, please let me know.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/28/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
The reason I'm including this tip, is because I searched and struggled quite awhile for a way to change the text of label that Quick Menu assigned.
Click on the [A] button, on the Report Controls Toolbar.
Click on the text of the label, where you want to make the change. You can use the right and left arrow keys to move within the text.
Change the text in the label.
Click on the Upward Arrow button, on the Report Controls Toolbar, or click on the Report Designer someplace outside of the text. This will take you out of the edit mode.
If you don't have a Report Controls Toolbar, then select View | Report Controls Toolbar from the Visual FoxPro main menu.
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 06/28/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Before there was a DESCENDING order option on indexes, we would index the negative of our numbers to get a descending order sort. This works when you have an index of all numbers. Now! We don't have to do this, but this trick can be handy.
If you have an index with strings in it and you have a number you want indexed descending. You can subtract the number from a big number and then convert the difference to a string. Lets say, your numbers range from 1 to 10. Subtract the number from 100. -- 1 becomes 99 and 10 becomes 90. Index on that and you get a descending order. Be sure that the length of the number does not change. Subtracting from lets say 11 would not be good. 1 would go to 10 and 10 would go to 1. The length of the STR() values are different and you want the length of each entry in the index to be the same length.
Both of these tricks can be useful, in the right situation.
Lets say you have a code, CODE1, that is numeric and you have a count or some other number (for this example lets use, count1) you want to include in the index. The second number, COUNT1, needs to be in descending order whereas the first number needs to be in ascending. If your index statement is INDEX ON CODE1 + (-1 * COUNT1), then CODE1 will be ascending and COUNT1 will be descending.
Lets say that you want to look at the last 5 oil changes for your fleet of trucks. Index on the licence plate numbers (char) + str(9999999-milage). (I'm assuming that the maximum mileage is 999999.) The licence plate numbers will be in ascending order and the milages will be highest to lowest. Look at the first 5 records for the licence plate number.
Platform: Windows/95
FoxPro: dBase II, dBase III/+, FoxBase, ... ,VFP/3 and VFP/5 (All xBase)
Recorded: 07/03/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
There are times that you might want to pass arguments to your application. You might want to pass in the users' name, what operation to perform or switches to influence the operation of your application. Visual FoxPro has a set of command line switches/options that can be used to influence how it operates. Hopefully, this tip will show you how to implement this feature in your own program.
The way that you pass arguments to a PROCEDURE is to include a PARAMETERS statement as the first executable command (comments don't count, you can have those before the PARAMETERS statement) of the procedure. Basically, that is how you add this feature to your applicaiton.
The first executable command in your application MUST be a PARAMETERS statement with the variable names specific for your application. You must include enough variables to support all of the command line arguments that the user will be using.
Spaces and tabs are used to separate command line arguments. If the argument is quoted, then imbedded spaces and tabs will be included in the string the program receives. For example...
You might want to ALLTRIM() the variable, to insure that no unwanted spaces are present.
You will want to UPPER() or LOWER() the variables. This makes it easier for you to determine if the user has supplied a specific argument.
The user can include these parameters in the ShortCut, Batchfile, command line, etc. So, you should expect some variation in what will be typed or passed to the program.
Depending on your application, you might want to inform your user if any invalid option were entered.
The PARAMETERS() function returns the number of parameters that were passed to the program, procedure, etc.
Platform: Windows/95
FoxPro: most earlier xBase versions, VFP/3 and VFP/5
Recorded: 07/03/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 07/08/1998 .. 04/08/1999
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
Microsoft has an FTP (Download) Site that contains a lot of patches, examples and free utilities.
Take a look at the Index.txt file for the /Softlib/MSLFILES subdirectory. Use this file to find the files that you need. The files are stored in /Softlib/MSLFILES. There are lots of files here. Look around...
The following link, takes you to the Microsoft's Software
Library Files FTP Directory (/Softlib/MSLFILES). You will be presented with a
FTP list of files. You can click on the file(s) that you want or add the
filename to the URL
("ftp://ftp.microsoft.com/Softlib/MSLFILES/") in the
"Location:" text box.
Platform: Windows/95
Products: All Microsoft Products including, Visual FoxPro Versions 3, 5 and 6
Prepared: 07/31/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
When you have multiple instances of the same MDI Child form, they will be displayed on top of each other. This may also happen when you have lots of different Child MDI Forms.
This tip provides a possible solution for this situation. This solution uses a Public Variable to help determine the placement of the next form/window to be displayed.
I'm using the Sysmetric(9) function to determine the height
of the window title bar. I use this number to set the top and
left offset of the next form/window.
I saw a similar tip in FoxPro Advisor, September 1998, page 74 by Keith Hekker. His tip requires that the form/window use a "private data session" and it for use with multiple instances of the same form. He uses the DataSessionID to determine the form/window placement.
His tip didn't work for me because I wasn't using a "private data session".
* Prior to the Showing of the Forms public piInstanceCount piInstanceCount = 0
* Include in the Form's Init Event liOffset = Sysmetric(9) * 1.2 && height of Window Title bar THISFORM.Top = THISFORM.Top + (piInstanceCount * liOffset) THISFORM.Left = THISFORM.Left + (piInstanceCount * liOffset) piInstanceCount = piInstanceCount + 1
This will cascade the windows down the Main MDI Frame. If you have a lot
of windows, then you might want to MOD the value of
piInstanceCount by 5 or 10. This should layer the windows in
groups of 5 or 10. An alternative would be to check the value of
piInstanceCount and set it back to zero when it gets too
big.
* Include in the Form's Init Event liOffset = Sysmetric(9) * 1.2 && height of Window Title bar THISFORM.Top = THISFORM.Top + ((piInstanceCount % 5) * liOffset) THISFORM.Left = THISFORM.Left + ((piInstanceCount % 5) * liOffset) piInstanceCount = piInstanceCount + 1
Also see my tip on How do I Cascade the MDI Child Windows in my application?... and How do I Arrange the Minimized MDI Child Windows in my application?....
Platform: Windows/95
FoxPro: VFP/3 and VFP/5
Recorded: 08/11/1998
Author: Richard Hendricks [eMail]
[Homepage]
[Copyright & Disclaimer]
|
|
|
Copyright © 1998 by Richard Hendricks All Rights Reserved. Feel free to use these tips and tricks in your applications and feel free to share copies and the information to your friends and colleagues. You may not re-sell the original or the source code. If you redistribute it you must include the disclaimer and all original copyright notices. Do not remove the contributors names, copyright notices and disclaimer. Give credit where credit is due. The information given here is believed to be correct, but no legal liability can be accepted for its use. No warranty express or implied, is given as to the use of the information or source code. Use at your own risk. The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications. Microsoft Corporation holds the rights and copyrights for FoxPro, Visual FoxPro |