2323
FAQ [Full list]
On this page are placed the answers to questions which I cruelly (or easy) found, I do not think, that the answers are exhausting, and if you will find, that something not conform to your representations, let's discuss and we shall find the best decisions... Besides frequently answer can depend on the version as OS and Visual FoxPro, to check up all on all versions and platforms for me simply excessively. Initially this list was only for VFP 5.0, while now it only VFP 7.0/8.0, I could somewhere and miss a mention of the version, and if you will find discrepancies, inform me, please.

а
Contents:

аааControls
аааDataEnvironment
аааForms
аааInternet
аааMenu
аааOOP
аааPrograms
аааReports
аааOthers


Controlsа

DataEnvironmentа

Formsа

Internetа

Menuа

OOPа

Programsа

Reportsа

Othersа


Controlsа

Q: How to return the value numerical code from ComboBox with two fields (symbolical name, numerical code) for record with numerical field in the table, i.e. when the given tables for ComboBox are subordinated of some parental table with a numerical code field?а

A: For version Visual FoxPro 3.0 the exhausting answer the registered users can find in Internet to the address:http://msdn.microsoft.com/library/ (eng). In section Preodicals/FoxTalks/Volume 8 1996: (http://www.pinpub.com/foxtalk/) clause Use a Combo Box to Select Foreign Keys http://msdn.microsoft.com/library/periodic/period96/D1/FT0896.htm (for brevity details I here do not discuss). In version Visual FoxPro 5.0a it is enough at ComboBox to establish property BoundTo value .T., [distinct from .F. (Default)], certainly by determining properties: BoundColumn, ControlSource, RowSource and RowSourceType in appropriate way.

Q: How I can display the subordinated set of records in Grid for some record in the parental table, if a source of the data for Grid is View?а

A: Essentially, there are two opportunities to make it: to use parametrical query as a source of the data to Grid or to establish for it the appropriate property Filter. Each of these cases can much differ by quantity of the sent information between server of the data and client, it is necessary also to note, that in the first case you will need obvious using function REQUERY() for a source of the data Grid after moving of the current record in the parental table repeatedly to execute query of the data according to changing conditions. See also
Q142974 Views.exe - One-To-Many Form Using a Parameterized View эр Microsoft.com
Q156169 HOWTO: Ignore Parameters in View or Query If Blank

Q: How to add CheckBox and ComboBox as displayed elements of columns in Grid?а

A: First of all, it is necessary to note, that for CheckBox the type of the data of the field, appropriate to it of a source of the data should be by type logic, while use ComboBox means, that you determine for it properties: RowSource, RowSourceType, Style (data displayed in ComboBox or a binding source of the data) and ControlSource, BoundColumn, BoundTo (returned value, i.e. the edited field of the table - source of the data Grid, for which ComboBox actually also displays the binding value).
For addition CheckBox it is easiest to use Builder for Grid (call BuilderЕby right click button of the mouse), where on a tab Layout follows set Control type in CheckBox for the appropriate column Grid. Check, that before a call Builder the used tables previously were open, as it can analyze the contents only if tables is opened, giving you the information for adjustment.
The elements CheckBox or ComboBox can be added and during editing Grid. For this purpose choose your column as active (Column[i] in a window Properties) and drag the element, necessary to you, (CheckBox or ComboBox) from Forms Controls Toolbar and drop it in the first line Grid for required column. If now you will open ComboBox of objects in a window Properties, will see, that the element, chosen by you, is added as an element of a column (at once after Text1), though it is not active now. At last, to make active the element, added by you, reset property CurrentControl for a column Column[i] on the element, necessary to you.

Q: I would like on click of the mouse on heading of a column Grid to change an active index at a source. To change the index is carried out, but I thus lose the current record. How I need to make, that the record the after changed of an index remained former?а

A: In VFP6.0 magic action in Grid.Header.Click() following:
LOCAL lnRecNo
lnRecNo = IIF(!EOF(), RECNO(), 0)
ThisForm.DataEnvironment.cursor1.Order = "Column_Order" 
*-- or SET ORDER TO TAG Column_Order
WITH This.Parent.Parent
    .ActivateCell(1, .ActiveColumn)
    IF lnRecNo # 0
        GO (lnRecNo)
    ELSE
        GO TOP 
    ENDIF
    .Refresh()
ENDWITH
See also "PRB: Incremental Search with Grid Causes Screen Flicker" in MSDN

Q: At me the record in Grid does not deleted, explain please, as I should make it correctly.а

A: If at you the blocking of records in mode buffering record and property DeleteMark of Grid is established to .F., you can be helped by the following code:
...
WITH ThisForm
    IF VARTYPE(.ActiveControl) = "O";
        AND .ActiveControl.BaseClass == "Grid";
        AND !INLIST(CURSORGETPROP("Buffering"), 4, 5);
        AND !.ActiveControl.DeleteMark 
        *-- Grid with DeleteMark = .F. and buffering record has a problem
        *-- at delete of record, it is necessary temporarily
        *-- to establish property DeleteMark = .T. 
        LOCAL loGrid
        loGrid = .ActiveControl
        loGrid.DeleteMark = .T.
    ENDIF
ENDWITH
lnRecNo = RECNO()
DELETE
llError = !TABLEUPDATE(.T.)
IF TYPE("loGrid") = "O"
    loGrid.DeleteMark = .F.
ENDIF
...
See also: http://support.microsoft.com/kb/q191641/

Q: How in object Grid to remove (to hide from the screen), and later to restore, on a former place, column (object Column)? Thus, it is necessary that at removal column was replaced with the right column.а

A: Try the following in a event Header1.Click():
WITH This.Parent
    IF .Visible 
        .Visible = .F.
        .Width = 0
    ELSE
        .Visible = .T.
        .Width = 75 && -- or former size
                    ** -- from the previously created array-property of your form  
    ENDIF
ENDWITH

you can establish Grid1.GridLineColor = RGB (128, 128, 128), that the latent column "did not rush in eyes"... As, I hope, most simple variant...

Q: I want to add the data in ComboBox, so to have two columns, I do not have joined(attached) source of the data, the data I would like to add from the program, but at me nothing it turns out. How it can be made?а

A: If I correctly have understood a problem, you need to use: for the first column: .AddItem (...) ...and for all others: .AddListItem(...)

Q: I place on the form ActiveX-components ImageList and add to it Images. I place on the same form of ActiveX-components Toolbar. I put in it the reference on ImageList and then I complete editing Toolbara. I open it again, but reference - none. What do with it?а

A: Made initialization of a property MyForm. MyToolbar1. Object. ImageList in runtime, similarly to the following:
#DEFINE tbrDefault	0
#DEFINE tbrCheck	1
#DEFINE tbrButtonGroup	2
#DEFINE tbrSeparator	3
#DEFINE tbrPlaceholder	4
#DEFINE tbrDropDown	5 

#DEFINE MAXBUTTONS	2 

LOCAL lcCurKey, loButton, lnCntImg, lnCntBtn
lnCntImg = 0
WITH ThisForm.MyToolbar1.Object
	.ImageList = ThisForm.MyImageList.Object
	WITH .Buttons
		FOR lnCntBtn = 1 TO MAXBUTTONS
			lnCntImg = lnCntImg+1
			lcCurKey = SYS(2015)
			.Add(,lcCurKey)
			loButton = .Item(.Count)
			WITH loButton
				.Image = lnCntImg 
				* ... etc
			ENDWITH
			loButton = NULL
		ENDFOR	
	ENDWITH
ENDWITH
Pay attention on two moments:
Using of the key word Object to be addressed not to VFP-cover of object, but immediately to it's property/method
To receive the reference on Button, I use Buttons.Item(Buttons.Count) instead of returned by a method Add()
I suspect, that for this trivial object, it is all is looked as "superfluous things", but only up to some of case..., and certainly, all depends on the version of objects...: -)
See also Q163803 in MSDN

Q: It's impossible at me call UDF in ControlSource of a column Grid in the form.а

A: Try to use the following expression: (UDF(Table.Field1[,...])[...]). Pay attention on "superfluous" external brackets and actual parameter in UDF: table-field.

Q: I want to show value of a memo-field of the table in a column Grid, however at me the word Memo is mapped only, and I need value. How it can be made?а

A: The most simple method to add "superfluous" external parentheseses similarly to ThisForm.MyGrid.ColumnX.ControlSource = "(MyTable.MyMemoField)", also is possible to insert Editbox and reset CurrentControl of a column into Edit1 to map value of a memo-field through it.

Q: I want a multiple-line headers of columns in Grid. What it is possible to make?а

A: See ID: Q133164 in MSDN or on http://www.microsoft.ru/catalog/article.asp?article_id={4CA8A85C-B996-11D4-9DAA-00508B8B6DC3} (rus) or http://support.microsoft.com/kb/q133164/

Q: In application I use ActiveX control, I create distribution by using VFP Setup Wizard. After installation on the customer I receive an error: OLE error code 0x80040112: Appropriate license for this class not found. Whether it is possible to overcome it?а

A: see "INFO: OLE Control Licensing in Visual FoxPro" in MSDN also see "HOWTO: Register an ActiveX Control (.ocx) Manually".

Q: I have Windows NT, I try to do printing from RichTextBox Control, but it's not possible from CommonDialog Control to receive device context hDC property to transmit to first (in method SelPrint). In other words: whether it is possible to introduce an information from RichTextBox Control to printing?а

A: Hm... has looked... and really does not work... :-( However, try something as next:
#DEFINE C_DRVNAME "winspool"
DECLARE LONG CreateDC IN Gdi32.dll ;
  STRING @ lpszDriver, ; &&// driver name
  STRING @ lpszDevice, ; &&// device name
  STRING @ lpszOutput, ; &&// not used; should be NULL
  STRING @ lpInitData  &&// optional printer data
LOCAL nCntPrn
LOCAL ARRAY laPrinters[1,2]
nCntPrn = APRINTERS(laPrinters)
IF nCntPrn = 0
 RETURN .F.
ENDIF
LOCAL lcPrinter, lhDC
lcPrinter = laPrinters[1,1]
lhDC = CreateDC(C_DRVNAME, lcPrinter, NULL, NULL)
IF lhDC = 0
 RETURN .F.
ENDIF
ThisForm.Olecontrol1.Object.SelPrint(lhDC)
CLEAR DLLS
C_DRVNAME as I have understood from MSDN CreateDC() for Windows 95/98 there should be NULL. However at me NT too, and therefore "winspool"

Q: Whether I somehow can insert Internet Explorer into the VFP-form?а

A: Try to do something similarly to following:
#DEFINE C_URL	"http://vfpdmur.narod.ru/" &&- Insert your URL here

RELEASE ox
PUBLIC ox
ox = CreateObject("MyInternetExplorer")
IF TYPE('ox') = 'O' AND !ISNULL(ox)
	WITH ox
		.oWeb.Navigate(C_URL,,"_self")
		IF !.Visible
			.Visible = .T.
		ENDIF
	ENDWITH
ELSE
	MESSAGEBOX("Error in CreateObject('MyInternetExplorer')", 16, 'Error')
ENDIF

DEFINE CLASS MyInternetExplorer AS form
	ADD OBJECT oWeb AS CWebExp
	Caption = "My Internet Explorer"
	PROCEDURE Init
		WITH ThisForm
			.Width = SYSMETRIC(21)*3/4
			.Height = SYSMETRIC(22)*3/4
			.Resize()
		ENDWITH
	ENDPROC
	PROCEDURE Resize
		ThisForm.oWeb.resize()
	ENDPROC
ENDDEFINE

DEFINE CLASS CWebExp AS olecontrol
	OleClass = "Shell.Explorer"
	PROCEDURE Resize
		WITH This
			.Width = ThisForm.Width - 1
			.Height = ThisForm.Height - 1
		ENDWITH
	ENDPROC
	PROCEDURE Refresh
		NODEFAULT
	ENDPROC
ENDDEFINE

Q: The h-file with definition of constants for Excel 2000 is necessary Where it is possible to take?а

A: Where to take just for Excel 2000 I do not know, for Excel 97 is on http://www.universalthread.com However, there is still such utility "GetConstants - COM constants to .h file" on http://www.west-wind.com/files/getconstants.zip

Q: SelectOnEntry on MouseClick for TextBox how to do?а

A: Try execute KEYBOARD '{SHIFT+END}' in event MyTextBox.GotFocus()

Q: It is impossible to use DayBold() in ActivX Comctl2.MonthView.2, returns "Function argument value, type, or count is invalid (Error 11)". How to overcome?а

A: Try to use next code:
 
WITH ThisForm.Olecontrol1.Object 
	FOR lnCnt = 1 TO 42 
		.DayBold(TTOC(.VisibleDays(lnCnt))) = .T. 
	ENDFOR 
ENDWITH 


DataEnvironmentа

Q: Why the trigger gives out a mistake?а

A: Because on the moment of performance of the trigger the data, do not satisfy to its requirements. To understand, what exactly occurs, it is best to look after the appropriate site of a code in debugger. Without the analysis of a concrete situation it is possible to assume, that the buffering of records the changeable table does not corresponding to logic of modification registered in a code. For example, you insert new record into the table, without use of properties default value for fields, only were going to bring in respective changing, and the trigger already has fulfilled.

Q: How it is necessary to establish a buffering mode for data sources of form?а

A: The best variant: to reset property Form.BufferMode of a Form in value 2-Optimistic. In this case, if properties Form.DataEnvironment.Cursor(i).BufferModeOverride at sources of the given Form will be established in value by default: 1-Use Form Setting(Default), all marked above problems are removed automatically, however you are free to establish a way of buffering of cursors of a Form how will find necessary.

Q: Why there can be problems with deleting of records from the table, having Primary Key?а

A: The given problem arises because it is not possible always to follow correct setting of a system mode Set Deleted in On at use of the table, and in state Off certainly requirements on uniqueness of value Primary Key are broken. To remove this problem follows indexes appropriate as Primary Key, and Candidate to nominate value of the filter containing expression: Not Deleted(). It is necessary to have in view of if told above accepted it is true if there are no problems of perfomance, because Rashmore optimization will not be carried out in this case. Otherwise you should think about an opportunity again to use of before mark as deleted records (see. RECALL Command)

Q: Why created in Visual FoxPro the tables have not code page 1251?а

A: It is strange, if at you localized version Windows is established (check Regional Settings and set Russian). But in any case, it is necessary to achieve, that the value received from the function Cpcurrent() was 1251. If it is enough to choose it by your machine, item Tools/Options Е and by changing a mode Collate sequence in value Russian on a tab Data, to execute Set As Default. Further, not bad would be to be passed under the projects, created by you, and in each of them, by opening dialogue Project Info Е, on a tab Files to execute Update Native Code Page for display of code pages of files included in the project. The program Cpzero will help you to change code pages of any files with structure DBF. At last, by machines of the clients using feasible files, it is necessary to try to ensure installation of code page by addition of parameter: CODE PAGE = 1251 in files Config.fpw in the current catalogues of these executed files.

Q: I have created Local view with two tables and use a keyword Join from View designer, and it does not work how I expected. What is a problem?а

A: Microsoft Visual FoxPro 5.0a has a problem at creation Local view, containing a key word Join: in the list of the tables following at once the key word FROM, the complete list of the tables participating in query is located whereas at presence Join, it is required to exclude from it those tables, which are used directly in Join. Further, if in Join more than two tables are involved, the conditions of "connection" of records, i.e. parameters ON, should follow at once for appropriate Join, while designer LocalView creates group of parameters ON at the end of the list of parameters Join (though I am not absolutely sure concerning last). I write the utility ModeView.exe, which will help you to make the appropriate updating Local view of a database, the truth it should use after any changes with preservation yours of Local view, containing Join directly ahead of their use in the appendix [to receive a copy ModeView.exe]. See also http://support.microsoft.com/kb/q157254/

Q: Whether there is a simple opportunity to change a folder (site) of a database at FoxPro application?а

A: If speech goes about a property Database at objects CursorX in DataEnvironment of the forms and reports, you can easily it change in runtime in an event DataEnvironment.BeforOpenTables() (at least since version 5.0), or in event MyBaseForm.Load(), by set MyForm.DataEnvironment.AutoOpenTables = .F. and by use MyForm.DataEnvironment.OpenTables() from code. However you can also:
Placed at new site of a database, while its former site is already inaccessible, in editing mode consistently to open all forms and reports and on a question on impossibility to open a database to specify its new site. The brought changes, certainly should be saved at an exit from dialogue of editing of the form/report.
If the offered variant seems to you tiresome, you can make respective alterations, by opening files *.scx and *.frx "manually". (See for *.scx of a field: Class and Properties, and for *.frx of a field: Name and Expr. It is necessary to you to edit property Database at object Cursor).
At last last variant can be executed from the program. For this purpose I write the utility ChangeDb.exe. [to receive a copy ChangeDb.exe]

Q: In VFP 6.0 at attempt to receive connection with the table of a database Visual FoxPro through ADO-ODBC I receive mistakes which not exist. Whether there is an opportunity to make what I want?а

A: Really, ADO-ODBC VFP 6.0 has a problem, including the example does not work: http://msdn.microsoft.com/vfoxpro/downloads/download.asp?ID=025 , however after installation http://msdn.microsoft.com/vfoxpro/downloads/download.asp?ID=027 the problem disappears. And still: it is necessary to register a VFP-source of the data under System DSN in ODBC-Administrator.

Q: At the reference to the stored procedure I receive a mistake that the procedure is not found. How correctly it is necessary to call the stored procedures?а

A: Before attempt of calling to any stored procedure from a database you should make its as active, using a command SET DATABASE TO dbc_name. The problem can arise during of compilations, if code included call to a stored procedure immediately and database is not included in the project. In this case it is enough in addition to place advantage EXTERNAL ARRAY MyDbcFunction in a code immediately before the call to a stored procedure to explain this feature to the compiler.

Q: In the application I use one database, and I need to open some table of another, and it is impossible to me. Can't I work with several databases?а

A: First of all, I advise you to look property Exclusive for all of Cursor's in DataEnvironment of your forms and reports, look also value of parameter Open Exclusive in Tools\Options... on tab Data, very much can be, that these parameters required opening databases - tables in Exclusive mode ... For opening the tables it is necessary to do from code something similarly to the following:
IF !DBUSED("MyDbc")
    OPEN DATABASE [full_path]MyDbc.dbc SHARED
    IF !DBUSED("MyDbc")
        ?CHR(7)
        MessageBox("Can not open database: MyDbc", 16, "Error")
        RETURN .F.
    ENDIF
ENDIF
SET DATABASE TO MyDbc
IF !INDBC("MyTable", "Table")
    ?CHR(7)
    MessageBox("No table: MyTable in database: MyDbc", 16, "Error")
    RETURN .F.
ENDIF
USE MyDbc!MyTable IN 0 SHARED

Q: It seems, that simple task: for example, there is a table of approximately such structure: a code of the client, date of payment, sum. The codes of the client in the table repeat.Is it possible by one inquiry to receive result: a code of the client - date of last payment - sum. And that should be broken into two subquery - ugly :-(а

A: Something as next:
SELECT * FROM MyDbё!Payments p ;
    WHERE STR(p.idclient) + DTOS(p.date) IN;
        (SELECT STR(p.idclient) + DTOS(MAX(p.date));
            FROM MyDbё!Payments p;
            GROUP BY p.idclient)

... by though two in one, ...and if for the concrete client, it is possible so:

SELECT TOP 1 *;
FROM MyDbё!Payments p;
WHERE p.idclient = ?idclient;
ORDER BY p.date DESC

Q: I have VFP 6.0+SP3 VS6 and now has appeared class Session. Whether will show an example of its use?а

A: Somehow approximately so:
#DEFINE C_DATABASE	"D:\Program Files\Microsoft Visual Studio\";
	+"MSDN\99OCT\1033\SAMPLES\VFP98\Tastrade\Data\Tastrade.dbc"
RELEASE goSec
PUBLIC goSec
goSec = CreateObject('MyclsSession')

DEFINE CLASS MyclsDE AS DataEnvironment
	Comment = 'MyMultiUsedDEObject'
	InitialSelectedAlias = 'Employee'
	
	ADD OBJECT Cursor1 AS cursor WITH ;
		Database = C_DATABASE, ;
		Alias = 'Employee', ;
		CursorSource = 'Employee', ;
		Exclusive = .F.
	* ...
	PROCEDURE BeforeOpenTables
		*... change if need
	ENDPROC 
ENDDEFINE

DEFINE CLASS MyclsSession AS Session
	DataSession = 2
	Name = 'MySession'
	oDataEnvironment = NULL
	FUNCTION Init
		This.oDataEnvironment = CreateObject('MyclsDE')
		IF VARTYPE(This.oDataEnvironment) = 'O'
			This.oDataEnvironment.OpenTables()
		ENDIF
	ENDFUNC
ENDDEFINE
Pay attention, to a moment of an event MyclsDE.BeforeOpenTables() the instance of object MyclsDE already exists, and you can from a code change it directly ahead of opening of sources of datas.
Also It is necessary to have in view, that a method AddObject (...) of any container and function CreateObject (...) works differently:
1) method This. AddObject ('MySession') adding instance of class Session into containers having propery DataSession, - never and any new DS not creates... and acts so:
- if the parent object has property DataSession = 2-Private DS, - then into DS of this parent object.
- If the parent object has property DataSession = 1-Default DS, - then into DS Default(1)
2) in turn, behaviour of creation instance object of a class Session through CreateObject ('MySession') a little bit other:< br > - if the created object has property DataSession = 2-Private DS, - then always as new DS, pay attention, value of a property MyForm.DataSessionID overwrite into value of the last created session
- if the created object has property DataSession = 1-Default DS, - then into DS Default (1)

Q: I don't create Connection object in database. Simply in a code I write lnHndl = sqlconnect (lcDSN, lcLogin, lcPassw) and would like to prevent error message, to treat it in program. How to me to make it?а

A: Try to do
=SQLSETPROP(0,"DispWarnings", .F.) 
=SQLSETPROP(0,"DispLogin", 3)  && DB_PROMPTNEVER
 

Q: Has installed VFP6.0, and though "Prompt for code page" is set, change Code Page dialog does not happen :-( In what a problem?а

A: Read carefully in MSDN section "SET CPDIALOG"... and there is written:
ON - (Default) Displays the Code Page dialog box when you open a table
and the following conditions are true:
- The table is opened exclusively.
- The table is not marked with a code page.
In other words, what for call Code Page dialog, if to interchange a code page in any case will fail :-)

Q: Whether it is possible to execute a command PACK for the table through ODBC?а

A: See HOWTO: Pack a Table Through the Visual FoxPro ODBC Driver (VFPODBC.dll)
on http://support.microsoft.com/kb/q234756/

Q: Is it possible from the VFP-program to add/change/delete in ODBC Administrator DSN?а

A: All operations are possible through Win32Api by using SqlConfigDataSource from Odbccp32.dll and function of access to the system register:
  - for adding see [Q142216] HOWTO: Create ODBC Data Sources Using SqlConfigDataSource in MSDN
  - for read/change: see [Q191638] HOWTO: Programmatically Access the Registry in Visual FoxPro ("ODBC Registry") in MSDN i.e. ODBCReg class from HOME (2)+"classes\registry.prg" and example in Solution.app in Win32Api "Read ODBC Regestry values" ("Sample Class Libraries" in MSDN)
  - for deleting see [Q195262] HOWTO: Delete ODBC Data Source Using SqlConfigDataSource
  - see also [Q165866] How to Use File DSNs and DSN-less Connections

Q: In any way I can not receive complete Rushmore optimization (SYS (3054) returns the optimization partial) on the table with an unique character field. That it could be?а

A: Try to do SET DELETED OFF before your SQL-SELECT :-)... If in the latter case receive complete optimization, try to add an index INDEX ON DELETED() TAG DEL into your table... Now, as I hope, the optimization will be complete and with SET DELETED ON

Q: It would be desirable automatically to have field of datas of a type "date of the last modifications", however in trigger update for the table it is impossible at me. Why and how it can be made?а

A: Infortunately in Update trigger it is impossible to make modifications datas, concerning which it is called, as an infinite recursion :-( and in Update trigger it is possible only to make changes to other table have communication from an initial table type one-to-one. Otherwise you are able to do it:
- in Record Rule for table to call SP
- in MyBaseForm.Save()
- in events Valid() appropriate controls

Q: How to receive the updated data in network version in case Private Data Session is used?а

A: Really, in process on the party of the client by an interval of updating of data is set by second parameter in SET REFRESH (if not use SYS (1104) [<- in VFP 6.0 see: Q269284 Knowledge Base Articles INFO: Undocumented Function SYS(1104) or VFP 7.0], which makes of updating at the moment of call... well or REQUERY() in a case Remote View/SELECT : -) to receive new updating data... no other way
Further, even if Cache is also updated (obviously through call SYS (1104), or the interval specified by second parameter in SET REFRESH has passed), in any case, that the updated data in the current record "is real new ", it is required move point of record (type GO (RECNO ('ChangedTable')) IN ChangedTable)
In other words, GO (RECNO ('ChangedTable')) IN ChangedTable (or other way get updated datas, for example Refresh() for binding controls) earlier than the interval specified as second parameter in SET REFRESH, for VFP 5.0 has not expired


Formsа

Q: Why at activization of a form I have mistake about absence of the opened table?а

A: Well, probably that someone already had time to close it, if it in general opened. The work with fields given from cursors "binding" to form objects, requires to hold open all cursors, used in a form. It does not cause difficulties with one active form (using Form.DataEnvironment.AutoOpenTables = .T. (Default), and on the contrary Form.DataEnvironment.AutoCloseTables = .F.), but can result in problems at simultaneous work with several forms, if in them are available, for example inconsistent installations Set Relation to Е In such cases are best for using property Form.DataSession established to state 2-Private Data Session (in this case is possible to to allow and Form.DataEnvironment.AutoCloseTables = .T.). Here it is necessary to warn, that in each of sessions of the data, you should see to it about a set of settings Set Е, at once after opening session (in Form.DataEnvironment.BeforOpenTable()).

Q: Why in an operating time in the form the operation of addition is carried out successfully, and on an exit from the form all changes are lost. What is a problem?а

A: The analysis of not working variant has shown, that the problem was in "careless" use of function TABLEUPDATE() at the buffered source of the data. It is necessary always to analyze returned value of this function, and if it will matter .F. It is necessary in addition to use function AERROR() for specification of the reasons of failure of system in saving of the data. (Visual FoxPro 5.0 has an example of a class DataChecker in Vfp\Samples\Classes\Samples.vcx demonstrating correct ways of saving of the data. A more simple way of saving of the data you can see in Tasmanian Traders Sample: a method tsBaseForm.Save () in library of classes Vfp\Samples\Tastrade\Libs\Tsbase.vcx). In the given concrete case rejected saving by the trigger of addition of the data of the appropriate table.

Q: How quickly to get access to controls in the form in a mode of editing for adjustment of their properties, if the form contains PageFrame? It is not possible with the help of the mouse to switch pages of PageFrame and/or to choose any element.а

A: For a choice any of the element contained in a class-container enough on it click right mouse key and in the revealed menu to choose item Edit, then to you there are accessible to editing objects of the top level of this class, etc.

Q: How it is necessary to make some calculations for saving of results from the form?а

A: Ideal, but, unfortunately, not always possible is triggers of the appropriate sources of the data, so in the trigger update for some table attempt to make changes to the same table is finished by a mistake. The mistake here too is caused by attempt of moving pointer of active record, that excludes an opportunity of scanning of the table with the purpose of performance of some calculations. Thus, if the results of calculations are required be to be made and to be kept in fields by this, i.e. the changeable record, or for calculations to you needs scanning the changeable table, most likely it will be necessary to you to change a method Save of the form, i.e. at once before TABLEUPDATE() to make a call of an additional method, for example PrepSave, which will execute necessary calculations and changes before saving record. It is necessary to tell, that the procedure carrying out calculations and making these changes in the table should be issued as the stored procedure called from the form.
It is necessary also to note, that the additional difficulties at you will arise at use of edited object Grid, as it independently makes saving of changes from buffers of the source at moving from record on record. In the latter case you will need to redefine Valid-function of object displaying the data in the column, from which and to carry out a call of a method Save of the form. And still best variant consists in such designing of structure of the tables, that all necessary changes could be executed in the appropriate triggers, for example, by allocating calculated fields in the separate table and by connecting it in appropriate way with initial.

Q: I would like to receive listing (source code) form with the purposes of debugging, but I do not know as it it is possible to make. Whether is though any variant of reception of a code of the form?а

A: For this purpose you should 1) save your form as a class ('File\Save as class...') in your vsx-library; 2) to open this library using Class Browser (Tools\Class Browser); 3) by choosing thus created class in Class Browser to execute item 'View Class Code' (button on the panel of tools).
(Class Browser in version 6.0 supports viewing many types of files [see. Files of type at opening], including scx, therefore is not necessary to do it through library)
In general means of debugging in VFP 6.0 are very variously, personally I frequently simply insert a command SET STEP ON into a method, the work code of which is necessary for observing under debugger. Can be here pertinently remind, that the search (CTRL+F) has an option Scope: All objects allowing to search a fragment in all methods of a class, and not just in current.

Q: I use PageFrame on my form, on which pages are present TextBoxes with determined ControlSource. How now, if I change an active record being on one page, I want to update datas in TextBoxes other, at the moment of switching on it?а

A: Try in all events MyForm.PageFrame1.Page[i].Activate() to add a lines
DODEFAULT()
This.Refresh()
*
* ... or ...
*
DODEFAULT()
IF !ThisForm.App_picbtns1.EditMode
	 This.Refresh()
ENDIF
... or something similar it, but is necessary with This.Refresh(). Better for this purpose to create a base class MyPageFrame, and to use derivative from it in the forms.

Q: Nothing I understand, I create the form by using Form Wizard, I do SET DELETED ON and next start the form, and deleted records are accessible. How to overcome?а

A: Most likely, at your form have property MyForm.DataSession = 2-Private Data Session... In this case, for each such form, is created a session of datas but SET's with which, have not any relation to SET's in Default Data Session (1)... Therefore in each such form they are necessary to setting it's each time at once after creation of new Data Session for the form...
There are two places where it better to make:
- If use Local View (SELECT's), most likely it is necessary also SET DELETED ON before opening, and then it is better to locate a code similar following:
IF ThisForm.DataSession # 1
   SET DATASESSION TO ThisForm.DataSessionID
   SET TALK OFF
   SET DELETED ON
   SET MULTILOCKS ON
   SET EXCLUSIVE OFF
ENDIF
in an event MyForm.DataEnvironment.BeforOpenTables()
- If told above is not critical, a the above same code may be locate in an event MyForm.Load(), i.e. before creation yours window Control's, probably it is necessary still add
IF !EMPTY(ALIAS()) 
     LOCATE && or GO TOP
ENDIF

Q: How to TextBox of the forms to support works with Windows Clipboard?а

A: It's enough in main menu to keep appropriate menu items... see menu items after generation of the menu through Menu\Quick menu

Q: From the form I call the Mymodal form, and the last is not the scx-file, and it's a class of my vcx-library... How to me now to return from Mymodal some value into the calling form? а

A: If in brief, in your modal form call a method ThisForm.Hide () in MyModalForm.cmdSaveValue.Click() [carefully read article in MSDN on Hide() method :-)], in this case, the next after loMyModalForm.Show (1) command will be executed, and reference loMyModalForm still valid (in any opposite case is already desroyed :-)... also this reference can be used for returns value from MyModalForm for example, through special public property oMyModalForm.uRetValue :-)... And to transmit parameters value to your MyModalForm by use parameters in MyModalForm.Init(tuP1[,tuP2...]), probably by additional private-properties for these parameters, "to inform" them values up to an event MyModalForm.cmdSaveValue.Click() :-)
The interesting candidate solution was has shown by Mike Korneev on fido7 news RU.VISUAL.FOXPRO:
*********** any.prg
local lc_Tmp
lc_Tmp='1234'
createobj('ff',@lc_Tmp)
? lc_Tmp

define class ff as form
	autocenter=.t.
	width=200
	height=100
	add object txt as textbox with top=20, left=50, width=100
	add object cmd as commandbutton with top=60, left=50, height=25, width=100
	
	func cmd.click
		thisform.hide
	endfunc
	
	func init(rc_Val)
		this.txt.value=rc_Val
		this.show(1)
		rc_Val=this.txt.Value
		return .f.
	endfunc
enddef
********** end of any.prg

Q: How to prevent muli-instance forms in VFP-application?а

A:
- the most simple method: to insert into menu item of open the form as expression in Skip for: !WEXIST('MyForm'), but it if exist menu item for call of the form...< br >- other variant to store into array of the all references somewhere in a class MyApplication, and open/realize of the forms by a method of this class, which purely and will be correct ruling start/erasure... In other words exactly how Application Wizard VFP 6.0 makes in:< br>Class Library: HOME()+'wizards/_framewk.vcx'
Method: DoForm (..., tlNoMultipleInstances, ...)
While the mode is installed through Application Builder on a tab Form - one instance form...
- At last, there are no problems to write in a base class for all your forms in an event MyBaseForm.Load() look all of the references in _SCREEN.Forms(), and return .F. if the form with such name already exists.


Internetа

Q: I'm beginner in VFP 6.0 and me interest opportunities on use ADO and OLE of objects in Internet, how I can take advantage VFP in ASP?а

A: In ASP you can use VFP-COM objects just as also anyone others, is like: var ob = Server.CreateObject ("VfpOleObject"); However I have understood so, that you interests uses tables/views from VFP database. It you can do creating ADO RecordSet's for VFP sources of the data: (var oc = Server.CreateObject ("ADODB.Connection"); oc.Open (sVfpODBCConnctStr); etc.) If you are interested a question of creation of html-pages by means VFP. It has the large set of Wizards, classes, and FoxIsapi for these purposes. See also http://www.west-wind.com/ ...And it is a lot of another about VFP in Internet. For transformation ADO RecordSet in VFP cursor you can take advantage http://msdn.microsoft.com/vfoxpro/downloads/download.asp?ID=025. See also http://support.microsoft.com/kb/q197861/

Q: In VFP 7.0 is two new functions: CursorToXML() & XMLToCursor() using first of them I have receive the xml-file for the table, however how view it in IE.а

A: To view the xml-file in IE it is necessary to define format of map of datas and it is possible to make by using css or xls files.Try to do the following:
- open table HOME(2)+"tastrade\data\setup.dbf"
- from Command window enter: ?CursorToXML("Setup", "myXMLSetup.xml", 1, 8+48+512, 0, "myShmSetup.xsd")
- create new file with text below:
<?xml version="1.0"?>
<!-- File Name: myXMLSetup.xsl -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<H2>List VFP table Setup</H2>
<xsl:for-each select="VFPData/setup">
<SPAN STYLE="font-style:italic">key_name: </SPAN>
<xsl:value-of select="key_name"/><BR />
<SPAN STYLE="font-style:italic">value: </SPAN>
<xsl:value-of select="value"/><P />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
save this as myXMLSetup.xsl file
- insert to myXMLSetup.xml file line:
<?xml-stylesheet type="text/xsl" href="myXMLSetup.xsl"?>
as line number two
-at last is possible to try to open the myXMLSetup.xml file from IE.
Other method consists in writing for myXMLSetup.xml the css-file, for example:
/* File Name: myXMLSetup.css */

key_name
{display:block;
margin-top:12pt;
font-size:10pt}

value
{display:block;
font-size:12pt;
font-weight:bold;
font-style:italic}
and use it instead of xsl shown above.
See also
- Q253732 HOWTO: Use FoxPro and MSXML to Return Information About an XML Document
- Q191758 Convert FoxPro Cursor into XML Data Format
- Q253713 Move Data From an XML Document into a FoxPro Table
in MSDN.
Is necessary also to have in view, that the construction of type:
<SCRIPT LANGUAGE="JavaScript">
var doc = dsoData.XMLDocument;
...
<XML id="dsoData" src="Data.xml"></XML>
actually returns as a value of variable doc is object DOMDocument (i.e. "MSXML.DOMDocument"). How to be spoken do not trust own eyes :-)

Q: At attempt to use VFP 8.0 OLEDB Provider from under MS IIS (OS Windows 2003 Server) I receive: System.Data.OleDb.OleDbException: No error information available: REGDB_E_CLASSNOTREG (0x80040154). If to create the usual Windows-application (for example on C#) with access through System.Data.OleDb), all works without questions. Whether there is a way of struggle with it?а

A: Some variants of overcoming this problem are known for me:
1) Instead of VFP 8.0 OLEDB Provider to use VFP OLEDB Provider for version 7.0
2) In the machine.config file in section processmodel change UserName with MACHINE on SYSTEM
3) Instead of VFP 8.0 OLEDB Provider 8.0.0.3006 use VFP OLEDB Provider 8.0.0.3117 (SP1VFP8) or later from http://msdn.microsoft.com/vfoxpro/downloads/updates/default.aspx Pay attention, that the rights of the local administrator (NOT the domain admin or network admin account) of a server are necessary for correct registration of OLE-component to you.
It seems, the second variant is not necessary try to use because of reasons of safety.

Q: How from VFP-code download the file from an internet-resource, having its address?а

A: For VFP immediately such built-in possibility it's not present, but
- first, from VFP it is possible to call Win32API-functions
- Secondly, in VFP it is possible to use ActiveX of the component, specialized for similar operations

Rather first:
There are at least two sets of functions: MS WinSock and MS WinInet (see in MSDN), usage first is hampered because of necessity to pass structures through parameters (in this occasion it is possible to look struct.zip by Christof Lange in internet), whereas second easily enough, see for example: on ftp://ftp.prolib.de/ tools/archive/internettools/ vfphttp.PRG, ftp_test.prg, ftp.PRG. See also in MSDN - [Q174524] "HOWTO: How To Retrieve and Insert HTML Into Memo Field".
... Concerning any of an example with MS WinSock - see example on http://vfpdev.narod.ru/util_r.html - getip.zip (1,69KB) - class for obtaining IP address for any host name, with usage Windows Sockets 2 API

Rather secondly:
from MS I know two components in this direction: MsWinSck.ocx, MsInet.ocx
See examples MSDN Knowledge Base:
- [Q311306] HOWTO: Use Visual FoxPro to Download a Web Page from the Internet
- [Q315124] SAMPLE: Use the Winsock ActiveX Control with Visual FoxPro
See also examples on http://vfpdev.narod.ru/util_r.html
- smtp.zip (20,8KB) - the example demonstrates sending the message through the SMTP protocol, using MS WinSock control.
- tcpSock.zip (12,5KB) - example of the client and server with usage MS Winsock control (MsWinSck.ocx) VFP6.0+SP3(VS6)/VFP7.0(SP1VFP7)
- srvwinsk.zip (100KB) - example of the applications of the client and server with usage MS Winsock control (MsWinSck.ocx) VFP 8.0/VFP 9.0
As addition, there it is possible to see: wsDmur.zip (49,5KB)


Menuа

Q: Why during interpretation of the menu I have syntactic mistake, though in the text of the program of any mistake is not present?а

A: If the top line of the menu, contains items, in which the keys of a fast call (ALT + Е) on the Russian letters are redefined, during interpretation of such menu there is a syntactic mistake. It is possible to offer the following ways decisions:
- To change, if it is possible, the contents of items so that a key of a fast call have coincided with the first letters of items, thus
. it is not necessary to use symbols of allocation \<
. in ALT+... use latin analog
- To redefine function error handler, ignoring the given mistake (in setup the menu set new error handler function with saving old former function, and in cleanup to restore old saving function). In this case, at attempt to take advantage of keys of a fast call there is no activization of item, while the system gives out a sound signal.


OOPа

Q: From what to begin and how practically to use the OOP approach at programming in Microsoft Visual FoxPro, after we were determined with structure of the customer data?а

A: First of all, on my sight, it is necessary to mention the following moments about data:
It is necessary to be overlook all tables and for each of fields to give value to heading of a field (Caption) and to give definition of a field (Field comment) on a tab Fields, if you it have not made yet. Thus it is necessary also to specify the Russian names of the tables (aliases of the tables) (Name) and to give definitions to the tables (Table comment) on a tab Table. It is necessary to note, that though version Visual FoxPro 5.0 and allows to enter verbose aliases of the tables, it is better nevertheless to have one-word aliases received by combined of words by means of a symbol '_'. Concerning the names of fields, it is necessary to tell, that though for the tables placed in the database Visual FoxPro there is a restriction in 128 symbols, early or late there can be a necessity of carry of the data on SQL Server, where, certainly, there are restrictions (for example, for MS SQL Server 6.5 lengths of a field 30 symbols, besides the names of fields, certainly are used at programming on server [Transact-SQL], where the first symbol '@' designates working local variable, reducing thus actual length of a field up to 29 symbols), moreover, the name of an index in Visual FoxPro 5.0 makes only 10 symbols, others will be rejected, if you will create an index, being based on a field.
Further look after, please, that for all of primary keys the functions returning new values of keys (default value) were determined, same most it is necessary to do and for all values of foreign keys in each of the tables. The code of the appropriate functions should be placed in a database as the stored procedures. Believe, that it not a problem of the front client to try correctly to generate new values of keys, it by all means should be by property of the data, instead of client. An example of the simple stored procedure allowing to receive new values of keys, you can find in Vfp\Samples\Tastrade\Data\Testdata.dbc - FUNCTION NewID(). Concerning values for foreign keys, I think, that is possible to adhere to the following rule: in any table being a source given for other tables, the first record, with initial value of a key primary key, - is value by default for all other tables, i.e. just this value should be determined as property default value for all fields foreign keys.
Pass once again on all fields of your tables and look critically: whether it is impossible at a stage of input, using a mask of a field (Input mask) to exclude only formal mistakes of input; define also format of display of the data (Format); and if there is a necessity, create functions of the control of the data of a level of a field (Rule) and define the text of the message (Message), given out at infringement of these rules on a tab Fields. If there is a necessity of check of a condition between values of different fields of one record of the table, by all means it is necessary to take advantage of function of the control of the data of a level of the table (Rule) and define the text of the message (Message), this rule, given out at infringement, on a tab Table.
At last, go on environment of editing of a database (Modify database ... Exclusive) and, by causing dialogue of the control of integrity of the data (Database/Edit Referential IntegrityЕ), establish necessary options of the control (Restrict | Cascade | Ignore) on events of changes of the data (Update, Delete, Insert) between all connected pairs tables. If the pairs, necessary to you, tables have not appeared in dialogue of the control of integrity of the data, go in editing the appropriate tables and establish to it a primary key, then define intertabulared relation, i.e. foreign key. Here pertinently once again to repeat, that, using function TABLEUPDATE() at the buffered source of the data, it is necessary always to analyze returned value of this function, and if it will matter .F. It is necessary in addition to use function AERROR() for specification of the reasons of failure of system in saving of the data and to notify on it the user, by means of distribution of the appropriate warning.
Further, for creation actually application on the initial stage you can take advantage, at least, two preparations: by a class cApplication, created by Application Wizard (Tools \Wizards\All Е) or class tastrade in an example Tasmanian Traders Sample (Vfp\Samples \Tastrade\Libs\ Main.vcx), inherited from Application in Vfp\Samples\Tastrade\Libs\Tsgen.vcx. In the first case it is required to you, most likely, being inherited from cApplication, to create an own class of the application, adding in it necessary functional-specific from classes Tastrade Application, for example support Toolbar. Certainly, you can write all from zero point independently, however, most likely thus you will find out, that write that is already written in the above mentioned classes.
At last, for maintenance "standard functional" works with the form, the best variant consists in use of a class tsBaseForm and inherited from tsMaintForm from library Vfp\Samples\Tastrade\Libs\Tsbase.vcx. Certainly, if essentially it is not pleasant to you, how the forms in an example Tasmanian Traders Sample works, you can not adhere to my advice and to write all from zero independently. However believe me, that you should write the same methods, and very much I doubt, that they will was essentially differ under the contents, when you will force them to work. Certainly, the mentioned above classes have only minimally necessary functional, and you will need them to develop and to improve as required. If you do not plan to use OOP style of programming and client/server technology for work with the data, probably, you really need to think of use any of other tools of programming of databases for building applications for the clients.

Q: How in the instance of a class tsBaseForm from Vfp\Samples\Tastrade\Libs\Tsbase.vcx to prevent use Toolbar, as in the given concrete case of the form at me is not present necessity for functions of navigation between records?а

A: It is enough to change value of property cToolbar of this class from the name of a class tsToolbar (working on default) to an empty line. If thus you nevertheless have necessity for use others, distinct from navigating methods, as: AddNew, Save, Restore etc., is required to you alternative ways of a call of these methods, for example, by means of addition in the form of command buttons. Further, in a lot of methods, for example AddNew, there is unconditional use of property Enabled of the button cmdNew, therefore it is necessary to ensure of the conditional manipulation to this property: IF TYPE ('oApp') = 'O' AND !EMPTY(ThisForm.cToolbal), by making the appropriate updating in all similar cases in methods of the given class.

Q: I have a visual class-container and it is impossible in runtime to change "geometry" of the elements for it's instance. For want of to attempt of modifications happens something completely not clear. Whether there is any variant it to make?а

A: Create a temporary instance of a class Form (oMyTempForm = CreateObject (" Form ")) and create a copy of your class - container as instance of a class Form (using a method oMyTempForm.AddObject ("oMyNewObj1", "MyBaseObj")). On completion of modifications save an improved copy of a class in your classes library. (oMyTempForm.oMyNewObj1. SaveAsClass (MyClassLibName, MyNewClassName [, Description]))

Q: Unexpectedly has come across a problem: the function PEMSTATUS() with attribute 0 in exe works only if the checked Debug info is on, and always .F. otherwise. It is valid so?а

A: Hm... Really there is such problem.

Q: How change the Quick Start form to the own form in VFP-application created by Application Wizard?а

A: In the instance of your class (app_application) (derivative from _framewk._application), if in Application Builder the Quick Start is checked, then we have:< br > Class: app_application
Properties:
cstartupformclass = app_favoritepicker
lStartupForm = .T.
... Now it is necessary to replace this on app_MyClassFirstForm, however such class, should be correct in the method DoDocumentPickerDialog() in app_application (<- _framewk._application)
... and to simplify a problem, it is possible to do next:
    - add in app_application an additional property type: This.lContinue
    - and overwrite method DoDocumentPickerDialog() on something of a type:

LPARAMETERS tcClass,tcClassLib,tlAlternateMode
IF !This.lContinue
      This.lContinue = .T.
      RETURN This.DoForm("MyFirstFormSCX")
ELSE
      RETURN DODEFAULT(tcClass,tcClassLib,tlAlternateMode)
ENDIF


Programsа

Q: Why the exe-module created in Visual FoxPro "does not work" at attempt to start it by the machine, where complete version Visual FoxPro is not established, but only RunTime version it? а

A: I more than am sure, that the same module will not work and there, where the complete version is established if to start it not from under an environment Visual FoxPro. Try to do it, and if it is valid so, the reason is simple. In this module it is necessary to organize an infinite cycle handling system window messages, and finished on a command of end of work of the module. It is made by VFP commands Read Events and Clear Events accordingly.

Q: I experimentally have established, what set of files should be placed in the catalogue together with the exe-module created in Visual FoxPro, that it correctly worked on the client without installation RunTime verion Visual FoxPro. Whether I am correct has made, whether will be at me of problems in the future?а

A: I think, that you will have problems, when you will incur one more, module, created by you, to that to the client, and it is possible also new version of the former module, which, for example, will begin to use the ODBC-driver Visual FoxPro. Therefore, best variant of carry, - creation distributive, using Wizard Setup itself Visual FoxPro. The truth sometimes it works with a mistake, which consists that in information files distributive the files are registered which actually are not copied on distributional disks. For elimination of this problem it is necessary manually to edit these files, by resulting them in conformity that actually is on distributional disks.

Q: I create the application VFP 6.0 using Application Wizard. Why now, when I open the created thus project of the application from a Explorer window at me all Wizard and Builders are inaccessible? That I have, if I shall create icon of the application on DeskTop Windows (Shortcut) and I shall open the application through it.а

A: Open a file Config.fpw in the catalogue of your project and on time of development of the project place comment (first char *) in lines _BROWSER = "", ... , _WIZARD = "". Probably you also will need to change setting RESOURCE = OFF.

Q: How "to kill" Main Visual FoxPro Window? I create the form. I establish ShowWindow = 2 (As Top-Level Form)...а

A: Place SCREEN=OFF in yours of Config.fpw

Q: How to solve a problem of a storage of the passwords for access to the program. Are a simple way to do it? For the passwords I have dbf-file (user, password). Would like to be able to cipher/decipher a field password.а

A: Use for a save/check only result of function SYS (2007, cExpression), the most simple way, as I hope. Can slightly noise it.

Q: Where is find the information about problems of 2000 year for FoxPro?а

A: Problems Y2K are discussed here http://www.microsoft.com/technet/year2k/product/product.asp (eng.) http://www.microsoft.com/technet/year2k/product/user_list.asp(eng.) or http://www.microsoft.com/rus/year2000/prodguide/product.asp (rus.) http://www.microsoft.com/rus/year2000/prodguide/user_list.asp (rus.) see also Y2KFOX on http://www.y2kfox.com (eng.) or DateHound on http://www.digitalcoyote.com (eng.) and http://msdn.microsoft.com/vfoxpro/technical/tutorial/dates.asp (eng.)

Q: How to prevent start of several copies of the VFP application on one work station?а

A: Try something similarly to the following:
#DEFINE MY_APP_CAPTION "Application Window"
#DEFINE SW_SHOWNOACTIVATE	4
DECLARE INTEGER SetForegroundWindow IN Win32API ;
    LONG hWnd
DECLARE INTEGER IsIconic IN Win32API;
    LONG hWnd
DECLARE LONG FindWindow IN Win32API ;
    STRING lpClassName;
    ,STRING lpWindowName
DECLARE LONG ShowWindow  IN Win32API ;
     LONG hwnd ;
    ,LONG nCmdShow
LOCAL lhWnd
lhWnd = FindWindow(NULL, MY_APP_CAPTION)
IF lhWnd # 0
	IF IsIconic(lhWnd) # 0
    		ShowWindow(lhWnd, SW_SHOWNOACTIVATE)
	ENDIF
	SetForegroundWindow(lhWnd)
	CLEAR DLLS
	QUIT
ENDIF

Q: I create VFP-application with one form (ShowWindow - 2 as Top-Level Form), create setup, establish on the Windows 95 client..., on end of application a task failed. Whether there is a method to be saved of it?а

A: Try will establish DCOM on the client machine. Have in view, that there are two versions Dcom95.exe and Dcom98.exe. See also
Q193472 FIX: Exception Error Exiting Top-Level Form App in Windows 95
Q215362 HOWTO: Detect DCOM Installation Under VFP 6.0
http://fox.wikis.com/wc.dll?Wiki~C0000005ExError~VFP

Q: How from VFP determine: when a 32-bit process has completed?а

A: see. ID: Q191584 in MSDN "HOWTO: Determine When a 32-bit Process has Completed"

Q: It is necessary from a code to switch keyboard layout: Rus/Lat. Whether it is possible it to make?а

A: Something as next:
#DEFINE hklRus			"00000419" 	&& - name from 0x0419 Russian 
#DEFINE hklEng			"00000409" 	&& - name from 0x0409 English (US)
#define KLF_ACTIVATE	1			&& 0x00000001

DECLARE LONG LoadKeyboardLayout IN WIN32API ; 
	STRING pwszKLID, ; && input locale identifier
	INTEGER Flags      && input locale identifier options

LOCAL lnRetCode
lnRetCode = LoadKeyboardLayout(hklRus, KLF_ACTIVATE)
lnRetCode = LoadKeyboardLayout(hklEng, KLF_ACTIVATE)

CLEAR DLLS

Q: How to place a picture in VFP main window?а

A: Try something similarly to the following::
WITH _SCREEN
	.AddObject( "MyPic", "Image" )
	.MyPic.Picture = HOME()+"Fox.bmp"
	.MyPic.Top     = 10
	.MyPic.Left    = 10
	.MyPic.Visible = .T.
ENDWITH
*
*... and for deleting:
*
 _screen.RemoveObject("MyPic") 

Q: Whether there is a localization library for VFP6? Such as in fifth vfp5rus.dllа

A: In SP4 VS6 VS6sp47.cab file is contained vfp6rrus.dll (at me, at least)...

Q: Whether it is possible somehow to work with C-structures, received through Win32Api functions from VFP?а

A: On http://www.universalthread.com/ (the registration is free) in section Files lays Struct.zip by Christof Lange which allows to do it.

Q: Cannot Quit VFP-application by [x]. How to overcome it?а

A: See. ID: Q172455, Q110970, ON SHUTDOWN in MSDN. As adding, if you wish, that your application was normally finished on closing OS [CTRL + ALT + DELETE], add into end of your procedure MyCleanUp, called on an event ON SHUTDOWN, something similarly to following:
PROCEDURE MyCleanUp 
ON SHUTDOWN
...
IF VERSION (2) = 0
	 QUIT
ENDIF

Q: I use HOME()+' tools/GenDbc/GenDbc.prg' for generation dbc-files, however I receive a disgrace similar:

...
DisplayStatus ([Creating table the LIST_MARKS_DISCONNECTOR...])
MakeTable ________________________________ ()
... 
Is it possible to overcome it?а

A: Try in gendbc.prg PROCEDURE FixName (...) "rigidly" to overwrite, something as type:
PROCEDURE FixName(lcProcName) 
	lcProcName=ALLTRIM(lcProcName) 
	cbadchars = '/,-=:;!@#$%&*.<>()?[]'+; 
		'+'+CHR(34)+CHR(39)+" " 
	lcProcName = CHRTRANC(lcProcName,cbadchars ,REPL('_',LEN(cbadchars))) 
	RETURN lcProcName 
ENDPROC 

Q: Attempt to use the solution Q194702 "HOWTO: Locate Windows Special Folder Locations" from MSDN not reduced any result. Whether there is an alternate solution?а

A: Try to use next:
o = CreateObject('wscript.shell')
for i = 1 to 17
? o.SpecialFolders(i)
next

Q: Whether there is a way to keep track events of VFP main window (_SCREEN) from the own program?а

A: One method is shown in Desktop.zip on page examples, other in creation of the own class just as is shown below:
* ScreenMethods.PRG
*
* Author: Fred Taylor - 4/10/2001
*
* Use the following to modify _SCREEN methods:
*
* For VFP6 & 7:
*
*     _SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg")
*
* For VFP3 & 5:
*
*     SET PROCEDURE TO screenmethods ADDITIVE
*     _SCREEN.AddObject("oSH","ScreenHook")
*
* Any of the main VFP screen methods can be hooked into in this manner.
*
DEFINE CLASS ScreenHook AS CUSTOM
oScr = _SCREEN
PROCEDURE oScr.Resize()
  *
  * Code to handle the main VFP screen being resized
  *
  WAIT WINDOW NOWAIT TRANSFORM(this.Width)+" "+TRANSFORM(this.Height)
ENDPROC
PROCEDURE oScr.RightClick
  *
  * Code to do a "shortcut" menu on main VFP screen RightClick
  *
  DO testmenu.mpr
ENDPROC
*
* Custom methods work, too.
*
PROCEDURE oScr.MyMethod
wait window "my method fired!"
ENDPROC
ENDDEFINE
Pay attention, that in the latter case part number of events is inaccessible, in particular QueryUnload()

Q: How to determine leap-year?а

A: !EMPTY(DATE(m.lnYear, 2, 29))

Q: How to build setup for VFP-application in version 7.0 and later? Can not fined menu item Tools/Wizards/Setupа

A: It's true: setup not exist in VFP environment. But InstallShield Express include to VFP setup CD. See 'Where is the Setup Wizard?' and Other Annoying InstallShield Questions in MSDN.
  - to use InstallShield Express see VFP-documentasion, and look in MSDN (by use key word "InstallShield Express")
  - what run-time dll-libraries for clien and which need register as COM-component see
   http://fox.wikis.com/wc.dll?Wiki~VFP7RuntimeFiles~VFP,
   http://fox.wikis.com/wc.dll?Wiki~VFP8RuntimeFiles~VFP,
   http://fox.wikis.com/wc.dll?Wiki~VFP9RuntimeFiles~VFP
  - see also MSDN KB: [Q320151] How to determine dependencies with InstallShield Express


Reportsа

Q: Whether it is possible from the report received by means of creation of the report in Visual FoxPro to receive "the full-function textual document" (fonts, etc.)?а

A: Directly is not present. By means of the report it is possible to receive only textual document (option ANSI in a command REPORT). If it is necessary to you to receive "the full-function document" any of a product, for example Word, you should use the OLE-mechanism just of this product for registration of the results from Visual FoxPro.

Q: Whether there is a possibility automatically to maximize the preview window of the report?а

A: Try to do:
#DEFINE WND_PRVREP "Report"
IF WEXIST(WND_PRVREP)
    ZOOM WINDOW (WND_PRVREP) MAX
ENDIF
in event MyReport.DataEnvironment.Init(). Pay attention, that it will not work in Application, constructed by the means Application Wizard in VFP 6.0, however there and there are no these problems.

Q: I wish to print a text file from VFP, but it is impossible to me something do it :-( It can somehow be made?а

A: Try to do similarly to the following:
#DEFINE C_FILENAME	"D:\MyApp\Vfp\Picture.prg"
#DEFINE C_OUT_PORT	"\\Server\Printer1"
*
******************* Or:
*#DEFINE C_OUT_PORT	"PRN:"  &&<- default
*#DEFINE C_OUT_PORT	"LPT1:" &&<- LPT1
******************* 
*
DECLARE INTEGER CopyFile IN KERNEL32.DLL ;
	STRING lpExistingFileName,; && name of an existing file
	STRING lpNewFileName,;      && name of new file
	INTEGER bFailIfExists       && operation if file exists

LOCAL lbRetVal
IF CopyFile(C_FILENAME, C_OUT_PORT, 0) = 0
	ACTIVATE SCREEN
	?CHR(7)
	=MessageBox('Can not print file', 16, _SCREEN.Caption)
ELSE
	lbRetVal = .T.	
	WAIT WINDOW 'Ok!' NOWAIT
ENDIF
CLEAR DLLS
RETURN lbRetVal

Q: On REPORT FORM... TO PRINTER I receive an error: 1958 Error loading printer driver. How to overcome it?а

A:
- In Report designe choice from menu item: File - > Page Setup, Print Setup..., OK, OK.
- See also article "HOWTO: Control Printer Attributes for a Report at Run Time" in MSDN
- at last try do next:
USE Myreport.frx  && Open the FRX as a table
LOCATE FOR Objtype = 1 AND Objcode = 53  && find the record that holds
** the printer information. For more information on the Table Structure
** of an .FRX file, see 'Table Structures of Table Files' in Help.
REPLACE Tag WITH ""  && Remove any Printer codes that may be stored in
** the Tag memo
REPLACE Tag2 WITH ""  && Remove any Printer codes that may be stored in
** the Tag2 memo

Q: There is a desire to print out lines from VFP but I can not understand, how it can be made. Is it possible?а

A: Try to look Q255744 section "HOWTO: Obtain a Device Context Handle for a Print Device" in MSDN

Q: Cannot quit Visual FoxPro when previewing report. How to overcome?а

A: See in MSDN:
Q179605 PRB: Cannot Quit Visual FoxPro When Previewing Report in a DESKTOP Window
Q156237 PRB: Report Designer/Preview Needs VFP Desktop to Display
Q190069 HOWTO: Showing Print Preview as MDI Child of Top-Level Form
Q188887 HOWTO: How to Display Print Preview in a Top-Level Form

Q: Whether it is possible to choose the printer at printing of the VFP-report?а

A: Try do commands:
REPORT ... to printer PROMPT
SET PRINTER ON PROMPT
See also: SYS(1037), GETPRINTER(), APRINTERS(), ...


Othersа

Q: At me the Themes (Subset) in MSDN Library have collapsed and at me it is impossible them to restore. I even reinstall MSDN Library, but a bit later they again have collapsed. Explain please, as I can them correctly establishа

A: Try the following: Choose item of the menu View\Define Subset... In the arisen dialogue define(determine) your theme (subset), pay attention to a textual field "Save new subset as:" - just it allows to give the name to your theme similarly to "*Visual FoxPro Documentation".
а
а
Hosted by uCoz