home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / VFP50 / SAMPLES / SOLUTION / SOLUTION.APP (.txt) < prev    next >
Encoding:
MS Visual FoxPro App  |  1996-08-01  |  439.3 KB  |  3,946 lines

  1. solution.scx0
  2. ERROR
  3. DO SolutionErrHandle
  4. solution
  5. ON ERROR &cOldError
  6. CCURRENTPROCEDURE
  7. NPATHSTART
  8. NLENOFPATH    
  9. COLDERROR
  10. SOLUTION
  11. Error: CE
  12. A form cannot simultaneously be open in design mode and running.
  13. Error: CE
  14. One of the necessary files is marked as read-only.
  15. Please make sure you have read and write access to the file.
  16. solution
  17. Error: CCC,Z
  18. ON ERROR &cOldError
  19. LNCHOICE
  20. SOLUTION
  21. SolutionErrHandle>
  22. MAINHWND-
  23. _WHTOHWND4
  24. _WONTOP;
  25. GetFileVersionB
  26.     9999
  27. 9999999
  28. 99999999
  29. 99991
  30. PLATFORM
  31. UNIQUEID
  32. TIMESTAMP
  33. CLASS
  34. CLASSLOC
  35. BASECLASS
  36. OBJNAME
  37. PARENT
  38. PROPERTIES
  39. PROTECTED
  40. METHODS
  41. OBJCODE
  42. RESERVED1
  43. RESERVED2
  44. RESERVED3
  45. RESERVED4
  46. RESERVED5
  47. RESERVED6
  48. RESERVED7
  49. RESERVED8
  50.  COMMENT Screen              
  51.  WINDOWS _R8C0YJACG 547204541
  52.  WINDOWS _R8C0YJACQ 553027776
  53.  WINDOWS _R980X8VQR 553027776l
  54.  WINDOWS _R980X8VQS 5530277766
  55.  WINDOWS _RB90WULHA 553027776
  56.  WINDOWS _RB90X15BW 553027776
  57.  WINDOWS _R7I13CW81 553027776
  58.  WINDOWS _RAH0OR73R 550736252
  59.  WINDOWS _RAH0OR744 550791607c
  60.  WINDOWS _R8C0YJACG 548430283l
  61.  WINDOWS _R7I13CWB6 548430283
  62.  WINDOWS _R7J0L510G 548430283Z
  63.  WINDOWS _R7J0L510V 553027776
  64.  WINDOWS _R7J15YJPQ 553027776
  65.  WINDOWS _R7J15YJQC 553027776
  66.  WINDOWS _R7J15YJQZ 553027776
  67.  WINDOWS _R8C0YJACQ 548430283
  68.  WINDOWS _R7V0X3DC3 553027776
  69.  WINDOWS _R9G0YY3OE 548430283
  70.  WINDOWS _R9H0ZJD19 553027776
  71.  WINDOWS _R7V0X3DY6 553027776
  72.  WINDOWS _R7V0X3DX6 553027776u)
  73.  WINDOWS _R7V0XEPQZ 553027776
  74.  WINDOWS _R7V0XEPS8 5530277760"
  75.  WINDOWS _R7V0XEPTF 550405607G
  76.  COMMENT RESERVED            
  77. VERSION =   3.00
  78. dataenvironment
  79. dataenvironment
  80. Dataenvironment
  81. KLeft = 31
  82. Top = 239
  83. Width = 527
  84. Height = 164
  85. Name = "Dataenvironment"
  86. cursor
  87. cursor
  88. Cursor1
  89. Dataenvironment
  90. rLeft = 20
  91. Top = 10
  92. Width = 90
  93. Height = 90
  94. Alias = "solutions"
  95. CursorSource = solution.dbf
  96. Name = "Cursor1"
  97. cursor
  98. cursor
  99. Cursor2
  100. Dataenvironment
  101. Left = 227
  102. Top = 12
  103. Width = 90
  104. Height = 89
  105. Alias = "reftext"
  106. Order = "text"
  107. CursorSource = reftext.dbf
  108. Name = "Cursor2"
  109. cursor
  110. cursor
  111. Cursor3
  112. Dataenvironment
  113. jLeft = 124
  114. Top = 11
  115. Width = 90
  116. Height = 89
  117. Alias = "xref"
  118. CursorSource = xref.dbf
  119. Name = "Cursor3"
  120. cursor
  121. cursor
  122. Cursor4
  123. Dataenvironment
  124. Left = 333
  125. Top = 14
  126. Width = 95
  127. Height = 90
  128. Alias = "customer"
  129. Database = ..\data\testdata.dbc
  130. CursorSource = "customer"
  131. Name = "Cursor4"
  132. cursor
  133. cursor
  134. Cursor6
  135. Dataenvironment
  136. wLeft = 438
  137. Top = 9
  138. Width = 95
  139. Height = 90
  140. Alias = "country"
  141. CursorSource = ..\data\country.dbf
  142. Name = "Cursor6"
  143.     solutions
  144. DataSession = 2
  145. Top = -1
  146. Left = 1
  147. Height = 298
  148. Width = 529
  149. DoCreate = .T.
  150. ShowTips = .T.
  151. BorderStyle = 2
  152. Caption = "Visual FoxPro Solutions"
  153. MaxButton = .F.
  154. Name = "solutions"
  155. PROCEDURE filltree
  156. o = THIS.pgf1.pagTree.oleTree
  157.     IF ALLTRIM(parent) = '0'
  158.         oNode = o.nodes.add(,1,ALLTRIM(key),ALLTRIM(text),,)
  159.     ELSE
  160.         oNode = o.nodes.add(ALLTRIM(parent),4,ALLTRIM(key), ALLTRIM(text),,)
  161.     ENDIF
  162.     * add images to the treeview
  163.     IF !empty(image)
  164.         oNode.Image = ALLTRIM(image)
  165.     ENDIF
  166. ENDSCAN
  167. o.Sorted = .T.
  168. ENDPROC
  169. PROCEDURE Destroy
  170. CLEAR EVENTS
  171. ENDPROC
  172. PROCEDURE Init
  173. #DEFINE NOLOADOCX_LOC    "Visual FoxPro could not load ActiveX controls used by this form. Try reinstalling sample applications."
  174. * Check to see if OCX installed and loaded.
  175. IF TYPE("THIS.pgf1.pagTree.oleImages") # "O" OR ISNULL(THIS.pgf1.pagTree.oleImages)
  176.     MESSAGEBOX(NOLOADOCX_LOC)
  177.     RETURN .F.
  178. ENDIF
  179. IF TYPE("THIS.pgf1.pagTree.oleTree") # "O" OR ISNULL(THIS.pgf1.pagTree.oleTree)
  180.     MESSAGEBOX(NOLOADOCX_LOC)
  181.     RETURN .F.
  182. ENDIF
  183. THIS.filltree
  184. ENDPROC
  185. PROCEDURE Activate
  186. this.c_solutions1.saveHelp
  187. ENDPROC
  188. PROCEDURE Deactivate
  189. IF TYPE('THIS.C_SOLUTIONS1') = "O" THEN
  190.     THIS.C_SOLUTIONS1.RESTOREHELP
  191. ENDIF
  192. ENDPROC
  193. THISFORM
  194. ACTIVEPAGEI
  195. SOLUTION
  196. THISFORM
  197. PAGLIST    
  198. CBOFILTER    
  199. LISTCOUNT
  200. ADDLISTITEM    
  201. LISTINDEX
  202. REFTEXT
  203. XREF_ID
  204. SOLUTION
  205. ASAMPLES
  206. PARENT
  207. LSTSAMPLES
  208. REQUERY
  209. ACTIVEPAGE
  210. optTree.Click,
  211. optList.Clickb
  212. THISFORM
  213. PAGTREE
  214. OLETREE
  215. NODES
  216. COUNT
  217. EXPANDED
  218. Click,
  219.     solutions
  220. optiongroup
  221. optiongroup
  222. solutions.pgf1.pagList
  223. combobox
  224. ?*filltree fill the oletree tree view control
  225. ^asamples[1,2] 
  226. shape
  227. shape
  228. Shape2
  229.     solutions
  230. STop = 12
  231. Left = 9
  232. Height = 211
  233. Width = 429
  234. SpecialEffect = 0
  235. Name = "Shape2"
  236. label
  237. label
  238. Label2
  239.     solutions
  240. AutoSize = .T.
  241. FontBold = .F.
  242. FontName = "MS Sans Serif"
  243. FontSize = 8
  244. Caption = " Solution Samples "
  245. Height = 15
  246. Left = 16
  247. MousePointer = 7
  248. Top = 7
  249. Width = 89
  250. TabIndex = 1
  251. Name = "Label2"
  252. shape
  253. shape
  254. Shape1
  255.     solutions
  256. STop = 233
  257. Left = 9
  258. Height = 56
  259. Width = 429
  260. SpecialEffect = 0
  261. Name = "Shape1"
  262. editbox
  263. editbox
  264. edtDescription
  265.     solutions
  266. FontBold = .F.
  267. FontName = "MS Sans Serif"
  268. FontSize = 8
  269. BorderStyle = 0
  270. Height = 43
  271. Left = 15
  272. ReadOnly = .T.
  273. ScrollBars = 0
  274. TabIndex = 0
  275. TabStop = .F.
  276. Top = 240
  277. Width = 416
  278. ControlSource = "solutions.descript"
  279. IntegralHeight = .T.
  280. Name = "edtDescription"
  281. c_solutions
  282. solution.vcx
  283. custom
  284. C_solutions1
  285.     solutions
  286. ]Top = 258
  287. Left = 476
  288. Height = 18
  289. Width = 25
  290. autosetdefault = .T.
  291. Name = "C_solutions1"
  292. behindscenes
  293. solution.vcx
  294. commandbutton
  295. Behindscenes1
  296.     solutions
  297. =Top = 266
  298. Left = 494
  299. TabIndex = 6
  300. Name = "Behindscenes1"
  301.  PROCEDURE Click
  302. ENDPROC
  303. Click,
  304. commandbutton
  305. commandbutton
  306. cmdRun
  307.     solutions
  308. Top = 12
  309. Left = 447
  310. Height = 23
  311. Width = 72
  312. FontBold = .F.
  313. FontName = "MS Sans Serif"
  314. FontSize = 8
  315. Caption = "\<Run Sample"
  316. Default = .T.
  317. Enabled = .F.
  318. TabIndex = 3
  319. Name = "cmdRun"
  320. /PROCEDURE Click
  321. THISFORM.Visible = .F.
  322. DO CASE
  323.     CASE solutions.type = "F" && form
  324.         DO FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))
  325.     CASE solutions.type = "R" && report
  326.         ON KEY LABEL F1 HELP ID (VAL(solutions.key))
  327.         REPORT FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file)) PREVIEW NOCONSOLE
  328.         THISFORM.Visible = .T.
  329.     CASE solutions.type = "Q" && query
  330.         ON KEY LABEL F1 HELP ID (VAL(solutions.key))
  331.         #DEFINE TITLE_LOC "Results of Query "
  332.         DEFINE WINDOW brow_wind FROM 1,1 TO 30, 100 TITLE TITLE_LOC + UPPER(ALLTRIM(file))+ ".QPR " ;
  333.             FLOAT GROW MINIMIZE ZOOM CLOSE FONT "Arial",10
  334.         ACTIVATE WINDOW brow_wind NOSHOW
  335.         DO (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file) + ".QPR")
  336.         RELEASE WINDOW brow_wind
  337.         THISFORM.Visible = .T.
  338.     CASE solutions.type = "V" && view
  339.         ON KEY LABEL F1 HELP ID (VAL(solutions.key))
  340.         #DEFINE TITLE2_LOC "Results of View "
  341.         DEFINE WINDOW brow_wind FROM 1,1 TO 30, 100 TITLE TITLE2_LOC + UPPER(ALLTRIM(file)) ;
  342.             FLOAT GROW MINIMIZE ZOOM CLOSE FONT "Arial",10
  343.         ACTIVATE WINDOW brow_wind NOSHOW
  344.         SET DATABASE TO testdata
  345.         SELECT 0
  346.         USE (ALLTRIM(solutions.file)) ALIAS _VIEW
  347.         IF !EMPTY(ALIAS())
  348.             * We had no error opening table
  349.             BROWSE
  350.             RELEASE WINDOW brow_wind
  351.             USE
  352.         ENDIF
  353.         SELECT solutions
  354.         THISFORM.Visible = .T.
  355. ENDCASE
  356. ON KEY LABEL F1
  357. ENDPROC
  358. PROCEDURE Error
  359. #DEFINE ERR_VIEWMESS_LOC    "Could not run view sample: "
  360. LPARAMETERS nError, cMethod, nLine
  361. IF solutions.type = "V"
  362.     MESSAGEBOX(ERR_VIEWMESS_LOC+MESSAGE())
  363.     RETURN
  364. ENDIF
  365. ENDPROC
  366. SOLUTION
  367. solution
  368. VALUE
  369. SOLUTION
  370. THISFORM
  371. ASAMPLES
  372. XREF_ID
  373. PARENT
  374. LSTSAMPLES
  375. REQUERY    
  376. LISTINDEX
  377. InteractiveChange,
  378. THISFORM
  379. PAGTREE
  380. OLETREE
  381. NODES
  382. COUNT
  383. EXPANDED
  384. Click,
  385. THISFORM
  386. RELEASE
  387. Click,
  388.     cboFilter
  389. combobox
  390. solutions.pgf1.pagList
  391. lstSamples
  392. listbox
  393. commandbutton
  394. commandbutton
  395. cmdSee
  396.     solutions
  397. Top = 40
  398. Left = 447
  399. Height = 23
  400. Width = 72
  401. FontBold = .F.
  402. FontName = "MS Sans Serif"
  403. FontSize = 8
  404. Caption = "\<See Code"
  405. Enabled = .F.
  406. TabIndex = 4
  407. Name = "cmdSee"
  408. PROCEDURE Click
  409. THISFORM.Visible = .F.
  410. ON KEY LABEL F1 HELP ID (VAL(solutions.key))
  411. DO CASE
  412.     CASE solutions.type = "F" && form
  413.         IF !EMPTY(solutions.method)
  414.             cMacro = solutions.method
  415.             MODIFY FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file)) ;
  416.                 METHOD &cMacro
  417.         ELSE
  418.             MODIFY FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))
  419.         ENDIF
  420.     CASE solutions.type = "R" && report
  421.         MODIFY REPORT (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))
  422.     CASE solutions.type = "Q" && query
  423.         MODIFY QUERY (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))
  424.     CASE solutions.type = "V" && view
  425.         SET DATABASE TO testdata
  426.         MODIFY VIEW ALLTRIM(solutions.file)
  427.         SELECT solutions
  428. ENDCASE
  429. THISFORM.Visible = .T.
  430. ON KEY LABEL F1
  431. ENDPROC
  432. NODE    
  433. SOLUTIONS
  434. THISFORM
  435. CMDRUN
  436. ENABLED
  437. CMDSEE
  438. REFRESH'
  439. THISFORM
  440. CMDRUN
  441. ENABLED
  442. CLICK    
  443. NodeClick,
  444. DblClick
  445. m, 0, 9, 5, 13, 11, 11, 2, 0
  446. MS Sans Serif, 0, 8, 5, 13, 11, 11, 2, 0
  447. Courier New, 0, 11, 9, 17, 13, 10, 4, 0
  448. listbox
  449. solutions.pgf1.pagTree
  450. cmdExpandAll
  451. commandbutton
  452. commandbutton
  453. commandbutton
  454. commandbutton
  455. cmdQuit
  456.     solutions
  457. Top = 80
  458. Left = 447
  459. Height = 23
  460. Width = 72
  461. FontBold = .F.
  462. FontName = "MS Sans Serif"
  463. FontSize = 8
  464. Cancel = .T.
  465. Caption = "\<Close"
  466. TabIndex = 5
  467. Name = "cmdQuit"
  468. .PROCEDURE Click
  469. THISFORM.Release
  470. ENDPROC
  471. }PROCEDURE Click
  472. o = THISFORM.pgf1.pagTree.oleTree
  473. FOR i = 1 TO o.Nodes.Count
  474.     o.Nodes(i).Expanded = .T.
  475. ENDFOR
  476. ENDPROC
  477. solutions.pgf1.pagTree
  478. cmdCollapseAll
  479. commandbutton
  480. label
  481. label
  482. lblDescription
  483.     solutions
  484. AutoSize = .T.
  485. FontBold = .F.
  486. FontName = "MS Sans Serif"
  487. FontSize = 8
  488. Caption = " Description "
  489. Height = 15
  490. Left = 16
  491. MousePointer = 7
  492. Top = 228
  493. Width = 61
  494. TabIndex = 0
  495. Name = "lblDescription"
  496.     pageframe
  497.     pageframe
  498.     solutions
  499. ErasePage = .T.
  500. PageCount = 2
  501. BorderWidth = 0
  502. Top = 20
  503. Left = 13
  504. Width = 419
  505. Height = 200
  506. SpecialEffect = 2
  507. Tabs = .F.
  508. TabIndex = 2
  509. Name = "pgf1"
  510. Page1.Caption = "Page1"
  511. Page1.Name = "pagTree"
  512. Page2.Caption = "Page2"
  513. Page2.Name = "pagList"
  514. olecontrol
  515. olecontrol
  516.     oleImages
  517. solutions.pgf1.pagTree
  518. CTop = 21
  519. Left = 333
  520. Height = 45
  521. Width = 65
  522. Name = "oleImages"
  523.  qhj ZtuQha;jdfn[iaetr 
  524. ImageHeight
  525. ImageWidth
  526. wwwww
  527. picture
  528. picture
  529. '''''
  530. world
  531. picture
  532. wwwwww
  533. picture
  534. picture
  535. picture
  536. picture
  537. picture
  538. picture
  539. picture
  540. picture
  541. picture
  542. picture
  543. picture
  544. picture
  545. picture
  546. picture
  547. picture
  548. picture
  549. picture
  550. DDDDD
  551. DDDDD
  552. DDDDD
  553. DDDDD
  554. picture
  555. picture
  556. DDDDDO
  557. DDDDDDO
  558. picture
  559. picture
  560. DDDDD
  561. DDDDD
  562. DDDDD
  563. DDDDD
  564. picture
  565. ,OLEObject = C:\WINDOWS\SYSTEM\COMCTL32.OCX
  566. olecontrol
  567. olecontrol
  568. oleTree
  569. solutions.pgf1.pagTree
  570. OTop = 27
  571. Left = 5
  572. Height = 168
  573. Width = 411
  574. TabIndex = 1
  575. Name = "oleTree"
  576. PROCEDURE NodeClick
  577. *** OLE Control Event ***
  578. LPARAMETERS node
  579. SELECT SOLUTIONS
  580. LOCATE FOR Key = node.Key
  581. IF EMPTY(file)
  582.     THISFORM.cmdRun.Enabled = .F.
  583.     THISFORM.cmdSee.Enabled = .F.
  584.     THISFORM.cmdRun.Enabled = .T.
  585.     THISFORM.cmdSee.Enabled = .T.
  586. ENDIF
  587. THISFORM.Refresh
  588. ENDPROC
  589. PROCEDURE DblClick
  590. *** OLE Control Event ***
  591. IF THISFORM.cmdRun.Enabled
  592.     THISFORM.cmdRun.Click
  593. ENDIF
  594. ENDPROC
  595. PROCEDURE InteractiveChange
  596. IF THIS.Value = "-1"
  597.     SELECT solution.text , solution.key FROM SOLUTION ;
  598.         WHERE type != "N" ORDER BY text INTO ARRAY THISFORM.aSamples
  599.     SELECT solution.text, solution.key FROM solution ;
  600.         WHERE solution.key = ;
  601.         SOME(select xref.key from xref where xref.xref_id = VAL(THIS.Value)) ;
  602.         ORDER BY text INTO ARRAY THISFORM.aSamples
  603. ENDIF    
  604. THIS.Parent.lstSamples.Requery
  605. THIS.Parent.lstSamples.ListIndex = 1
  606. ENDPROC
  607. commandbutton
  608.  qhj ZtuQha;jdfn[iaetr 
  609. MS Sans Serif
  610.     oleImages
  611. HideSelection
  612. Indentation
  613. MousePointer
  614. BorderStyle
  615. ,OLEObject = C:\WINDOWS\SYSTEM\COMCTL32.OCX
  616. Top = 9
  617. Left = 399
  618. Height = 18
  619. Width = 15
  620. FontBold = .F.
  621. FontName = "Courier New"
  622. FontSize = 11
  623. Caption = "-"
  624. TabIndex = 3
  625. ToolTipText = "Collapse All"
  626. Name = "cmdCollapseAll"
  627. PROCEDURE Click
  628. o = THISFORM.pgf1.pagTree.oleTree
  629. FOR i = 1 TO o.Nodes.Count
  630.     o.Nodes(i).Expanded = .F.
  631. ENDFOR
  632. ENDPROC
  633. FontBold = .F.
  634. FontName = "MS Sans Serif"
  635. FontSize = 8
  636. BoundColumn = 2
  637. ColumnCount = 2
  638. ColumnWidths = "411,0"
  639. Height = 23
  640. Left = 5
  641. Style = 2
  642. TabIndex = 1
  643. Top = 28
  644. Width = 411
  645. Name = "cboFilter"
  646. FontBold = .F.
  647. FontName = "MS Sans Serif"
  648. FontSize = 8
  649. BoundColumn = 2
  650. ColumnCount = 2
  651. ColumnWidths = "470,0"
  652. RowSourceType = 5
  653. RowSource = "THISFORM.aSamples"
  654. Height = 139
  655. Left = 5
  656. TabIndex = 2
  657. Top = 55
  658. Width = 411
  659. IntegralHeight = .T.
  660. Name = "lstSamples"
  661. Top = 9
  662. Left = 382
  663. Height = 18
  664. Width = 15
  665. FontBold = .F.
  666. FontName = "Courier New"
  667. FontSize = 11
  668. Caption = "+"
  669. TabIndex = 2
  670. ToolTipText = "Expand All"
  671. Name = "cmdExpandAll"
  672. HELP ID (VAL(solutions.key))
  673. MODIFY FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))  METHOD &cMacro
  674. testdata
  675. THISFORM
  676. VISIBLE
  677. SOLUTIONS
  678. METHOD
  679. CMACRO
  680. TESTDATA
  681. Click,
  682. PROCEDURE InteractiveChange
  683. SELECT SOLUTIONS
  684. LOCATE FOR Key = THIS.Value
  685. IF EMPTY(file)
  686.     THISFORM.cmdRun.Enabled = .F.
  687.     THISFORM.cmdSee.Enabled = .F.
  688.     THISFORM.cmdRun.Enabled = .T.
  689.     THISFORM.cmdSee.Enabled = .T.
  690. ENDIF
  691. THISFORM.Refresh
  692. ENDPROC
  693. PROCEDURE ProgrammaticChange
  694. THIS.InteractiveChange
  695. ENDPROC
  696. PROCEDURE UIEnable
  697. LPARAMETERS lEnable
  698. IF lEnable AND !EMPTY(solutions.descript)
  699.     THIS.Value = solutions.key
  700. ENDIF
  701. IF !lEnable
  702.     o = THISFORM.pgf1.pagTree.oleTree
  703.     FOR i = 1 to o.Nodes.Count
  704.         IF o.Nodes(i).Key = ALLTRIM(THIS.Value)
  705.             o.Nodes(i).Selected = .T.
  706.             EXIT
  707.         ENDIF
  708.     ENDFOR
  709. ENDIF
  710. ENDPROC
  711. PROCEDURE DblClick
  712. IF THISFORM.cmdRun.Enabled
  713.     THISFORM.cmdRun.Click
  714. ENDIF
  715. ENDPROC
  716. SOLUTIONS
  717. VALUE
  718. THISFORM
  719. CMDRUN
  720. ENABLED
  721. CMDSEE
  722. REFRESH
  723. INTERACTIVECHANGE
  724. LENABLE    
  725. SOLUTIONS
  726. DESCRIPT
  727. VALUE
  728. THISFORM
  729. PAGTREE
  730. OLETREE
  731. NODES
  732. COUNT
  733. SELECTED'
  734. THISFORM
  735. CMDRUN
  736. ENABLED
  737. CLICK
  738. InteractiveChange,
  739. ProgrammaticChange
  740. UIEnable-
  741. DblClicke
  742. HELP ID (VAL(solutions.key))
  743. HELP ID (VAL(solutions.key))
  744. Arial
  745. Results of Query CC
  746. .QPR 
  747. HELP ID (VAL(solutions.key))
  748. Arial
  749. Results of View CC
  750. testdata
  751. THISFORM
  752. VISIBLE    
  753. SOLUTIONS
  754. BROW_WIND
  755. TESTDATA
  756. _VIEWY
  757. Could not run view sample: CE
  758. NERROR
  759. CMETHOD
  760. NLINE    
  761. SOLUTIONS
  762. Click,
  763. Error1
  764. ButtonCount = 2
  765. BackStyle = 0
  766. BorderStyle = 0
  767. Value = 1
  768. Height = 28
  769. Left = 11
  770. Top = 18
  771. Width = 381
  772. TabIndex = 0
  773. Name = "opg1"
  774. Option1.FontBold = .F.
  775. Option1.FontName = "MS Sans Serif"
  776. Option1.FontSize = 8
  777. Option1.BackStyle = 0
  778. Option1.Caption = "View samples by \<outline"
  779. Option1.Value = 1
  780. Option1.Height = 15
  781. Option1.Left = 8
  782. Option1.Top = 8
  783. Option1.Width = 130
  784. Option1.AutoSize = .T.
  785. Option1.Name = "optTree"
  786. Option2.FontBold = .F.
  787. Option2.FontName = "MS Sans Serif"
  788. Option2.FontSize = 8
  789. Option2.BackStyle = 0
  790. Option2.Caption = "View samples by \<filtered list"
  791. Option2.Value = 0
  792. Option2.Height = 15
  793. Option2.Left = 174
  794. Option2.Top = 8
  795. Option2.Width = 145
  796. Option2.AutoSize = .T.
  797. Option2.Name = "optList"
  798. zPROCEDURE optTree.Click
  799. THISFORM.pgf1.ActivePage = 1
  800. ENDPROC
  801. PROCEDURE optList.Click
  802. LOCAL lo
  803. lo = THISFORM.pgf1.pagList.cboFilter
  804. IF lo.ListCount = 0
  805.     #DEFINE ALL_LOC "All"
  806.     lo.AddListItem(ALL_LOC, 1, 1)
  807.     lo.AddListItem("-1", 1, 2)
  808.     lo.ListIndex = 1
  809.     SELECT reftext
  810.     FOR i = 1 TO RECCOUNT()
  811.         lo.AddListItem(reftext.text, i + 1, 1)
  812.         lo.AddListItem(ALLTRIM(STR(reftext.xref_id)), i + 1, 2)
  813.         SKIP
  814.     ENDFOR
  815. ENDIF
  816. SELECT solution.text, solution.key FROM SOLUTION WHERE type != "N" ORDER BY text INTO ARRAY THISFORM.aSamples
  817. lo.Parent.lstSamples.Requery
  818. lo.ListIndex = 1
  819. THISFORM.pgf1.ActivePage = 2
  820. ENDPROC
  821. PAGTREE
  822. OLETREE
  823. PARENT
  824. ONODE
  825. NODES
  826. IMAGE
  827. SORTED
  828. THIS.pgf1.pagTree.oleImagesb
  829. Visual FoxPro could not load ActiveX controls used by this form. Try reinstalling sample applications.
  830. THIS.pgf1.pagTree.oleTreeb
  831. Visual FoxPro could not load ActiveX controls used by this form. Try reinstalling sample applications.
  832. PAGTREE    
  833. OLEIMAGES
  834. OLETREE
  835. FILLTREE
  836. C_SOLUTIONS1
  837. SAVEHELP9
  838. THIS.C_SOLUTIONS1b
  839. C_SOLUTIONS1
  840. RESTOREHELP
  841. filltree,
  842. DestroyK
  843. InitW
  844. Activate
  845. DeactivateG
  846. DDDDDD@
  847. |CONTEXT
  848. |CTXOMAP
  849. |FONT
  850. |KWBTREE
  851. |KWDATA
  852. |KWMAP
  853. |SYSTEM
  854. |TOPIC
  855. |TTLBTREE
  856. |bm10
  857. |bm11
  858. |bm12
  859. |bm13
  860. |bm14
  861. |bm15
  862. wwpwp
  863. wpwp    w
  864. pwp    w
  865. wwppw
  866. pwpwpw
  867. pwwppwwpw
  868. pwppw
  869. pwpwpw
  870. wwpwpw
  871. pwppw
  872. pwwpw
  873. pwppw
  874. wwx4w
  875. DDODODOD
  876. ODOODOOD
  877. ODODOD
  878. ODOOD
  879. OODOODOOD
  880. ODDOD
  881. OODOD
  882. ODDOD
  883. ODDOOD
  884. DODDODD
  885. ODOOD
  886. DDODDODOD
  887. pwppw
  888. ppwpp.w
  889. pwppw
  890. ppwppwppw
  891. pwppwppw
  892. pwppw
  893. ppwpp.w
  894. ppwppwpwp
  895. pwwpwppwpww
  896. wwppw
  897. pwppw
  898. ppwpp.w
  899. ppwppwpw
  900. pwppwpww
  901. pwppw
  902. ppwpp.w
  903. wpwppw
  904. ppwpp
  905. ppwpww
  906. pwpww
  907. Microsoft Word
  908. System
  909. Times New Roman
  910. "Arial
  911. Option Button Group
  912. Page Frame
  913. 00    99
  914. DA9919;
  915. K:H!-
  916. ?pDDO
  917. DDGpO
  918. DDGpL
  919. DD@wD@
  920. wwxwwx
  921. wDwwxww
  922. wwxwwx
  923. wDwwxww
  924. Visual FoxPro Solutions
  925. BrowseButtons()
  926. secondary
  927. Components
  928. Solutions Sample:
  929. Solutions Sample
  930. See Also
  931. List of Components
  932. The Visual FoxPro Solutions sample is a collection of independent samples designed to illustrate particular features of Visual FoxPro.  As you go through these samples, you can see how to accomplish specific tasks in Visual FoxPro.
  933. To run the Solutions Sample application
  934. Enter the following in the Command window:
  935. DO (HOME() + 'samples\solution\solution')
  936. The samples are organized into the following categories:  ActiveX, Controls, Databases, Forms, Menus, Reports, Toolbars, and WinAPI.  To see all of the components in this treeview, choose the 
  937. Expand All
  938.  button and scroll through the components.  
  939. When you select a component, you can:
  940. Read a brief description of the sample in the description area at the bottom of the main Solutions form, 
  941. Run the sample by choosing 
  942. Run Sample
  943. See the code by choosing 
  944. See Code
  945. After you close the form or designer that is opened, you are returned to the main Solutions form.
  946. See Also
  947. How the Solutions Sample Works
  948. How the Solutions Sample WorksH
  949. How the Solutions Sample Works
  950. Each component of the Solutions sample is listed in SOLUTION.DBF. This table stores the following:
  951. The key and parent key ids required to add nodes to a treeview control.
  952. The image id in the ImageList control for the picture to be displayed beside the item in the treeview control.
  953. The file name and path of the components.
  954. The method to open when you choose 
  955. See Code
  956. The description to be displayed in the Visual FoxPro Solutions form.
  957. There are two additional tables used to provide filtered list access to the components: XREF.DBF and REFTEXT.DBF.
  958. The FillTree method of the SOLUTION.SCX reads the information from SOLUTION.DBF to fill the treeview control.
  959. * FillTree
  960. o = THIS.pgf1.pagTree.oleTree
  961. IF ALLTRIM(parent) = '0'
  962. oNode = o.nodes.add(,1,ALLTRIM(key),ALLTRIM(text),,)
  963. oNode = o.nodes.add(ALLTRIM(parent),4,ALLTRIM(key), ALLTRIM(text),,)
  964. ENDIF
  965. * add images to the treeview
  966. IF !empty(image)
  967. oNode.Image = ALLTRIM(image)
  968. ENDIF
  969. ENDSCAN
  970. Forms
  971. Each form in the Solutions suite contains an object based on the c_solutions class in SOLUTION.VCX. This class provides a single place for environment and localization settings. When the c_solutions object is destroyed, old settings are restored and, if the Solutions form exists, it is redisplayed.
  972. The custom class is used in the Solutions sample because it provides greater flexibility:  you can add it to existing forms, and, if you want, you can delete it from the forms in the Solutions suite and customize the forms for your own use.  Instead of using a custom class to manage the environment settings, you can provide this functionality in one form class from which all forms in t'
  973. he Solutions sample are derived. 
  974. Form records in SOLUTION.DBF have a value of 
  975.  stored to the type field. In the code associated with cmdRun and cmdSee, the form is run or modified.
  976. * extract from cmdRun.Click
  977. CASE solutions.type = "F" && form
  978. DO FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))
  979.    In the Data Environment of SOLUTION.SCX, the cursor for SOLUTION.DBF is given an alias of 
  980. Solutions.
  981. Reports and Queries
  982. Report records in SOLUTION.DBF have a value of 
  983.  stored to the type field and queries have a type of 
  984. . You can run the reports and queries in the code associated with cmdRun, and you can modify them in the code associated with cmdSee.
  985. * extract from cmdRun
  986. CASE solutions.type = "R" && report
  987. REPORT FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file)) PREVIEW NOCONSOLE
  988. THISFORM.Visible = .T.
  989. Running a query opens the result set in a Browse window. By default, a Browse is displayed in the currently active window, which, in this sample would be the Solutions form. To display the Browse in a separate window, this code defines and activates another window, runs the query, then releases the separate window:
  990. CASE solutions.type = "Q" && query
  991. #DEFINE TITLE_LOC "Results of query "
  992. DEFINE WINDOW brow_wind FROM 1,1 TO 30, 100 TITLE TITLE_LOC + UPPER(ALLTRIM(file))+ ".QPR " ;
  993. FLOAT GROW MINIMIZE ZOOM CLOSE FONT "Arial",10
  994. ACTIVATE WINDOW brow_wind NOSHOW
  995. DO (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file) + ".QPR")
  996. RELEASE WINDOW brow_wind
  997. THISFORM.Visible = .T.
  998. ENDCASE
  999. Components in the Solutions Sample ApplicationX
  1000. Components in the Solutions Sample Application
  1001. Add and Remove Items in a Treeview Control
  1002. Add Items Interactively to a List Box
  1003. Add Menu Items at Run Time
  1004. Add New Items to a Combo Box
  1005. Allow Users to Choose List Values
  1006. Allow Users to Drag and Drop Controls
  1007. Automate a Microsoft Excel Spreadsheet
  1008. Automate a Microsoft Word Document in a Form
  1009. Automate Microsoft Word and Excel
  1010. Change Pages When a User Chooses a Button
  1011. Change the Number of Tabs at Run Time
  1012. Coordinate Menu Items and Toolbar Buttons
  1013. Create a 1-To-Many Data Entry Form
  1014. Create a Default Unique Id Value for a Field
  1015. Create a Query-By-Example Form
  1016. Create a Single Table Data Entry Form
  1017. Create an SDI Form
  1018. Create Small Indexes Using BINTOC( )
  1019. Create Dynamic Shortcut Menus
  1020. Customize the Open Dialog Box
  1021. Disable or Display a Check Beside a Menu Item
  1022. Display a Stop Watch
  1023. Display a System Clock
  1024. Display Calculated Values in a Column
  1025. Display Child Records from a Relationship
  1026. Display Controls in
  1027.  a Grid
  1028. Display Different Pages Without Tabs
  1029. Display Line Animation on a Form
  1030. Display Multiple Columns in a List Box
  1031. Display Pictures in a List
  1032. Display Pictures in an Image Control
  1033. Display Shortcut Menus
  1034. Display System Information
  1035. Draw Lines and Shapes on a Form
  1036. Dynamically Format Grid Columns
  1037. Edit a Memo Field or Text File
  1038. Execute Commands at Specified Intervals
  1039. Fill a List with Values from Different Sources
  1040. Format Input and Validate Data in a Text Box
  1041. Get Application Information from the Windows Registry
  1042. Get Version Information
  1043. Graph Equations on a Form
  1044. Index on Expressions
  1045. Interactively Build a SELECT Statement
  1046. Manipulate Display Characteristics of a Graph
  1047. Move Items Between List Boxes
  1048. Multiselect Items in a List Box
  1049. Nest Transactions
  1050. Open Dialog Box Flag Values
  1051. Open Multiple Files Interactively
  1052. Pass Parameters between Forms
  1053. Print a Percent of Total in a Report
  1054. Print Customer Mailing Labels
  1055. Print Data Dictionary Information
  1056. Print in Catalog Format
  1057. Print Product Orders By Quarter
  1058. Play an AVI File in an ActiveX Control
  1059. Play Multimedia Files Using MCI Commands
  1060. Present a User with Multiple Choices
  1061. Print an Invoice
  1062. Programmatically Check Table Properties
  1063. Programmatically Manipulate Objects
  1064. Programmatically Manipulate Text
  1065. Provide a Hierarchical Display of Items
  1066. Provide What
  1067. s This Help on a Form
  1068. Read and Write Visual FoxPro Registry Values
  1069. Read ODBC Registry Values
  1070. Refresh a Graph in a Form
  1071. Resize and Reposition Controls at Run Time
  1072. Return a Value from a Form
  1073. Run Multiple Instances of a Form
  1074. See Check Box Design Options
  1075. See Command Button Design Options
  1076. Select Customers in a Specific Country
  1077. Select Records from a Full Outer Join
  1078. Select Records from a Left Outer Join
  1079. Select Records from a Nested Join
  1080. Select Records from a Right Outer Join
  1081. Select Records from an Inner Join
  1082. Select Records from Both Inner and Outer Joins
  1083. Select the Ten Worst Selling Products
  1084. Select the Top Ten Best Selling Products
  1085. Send Mail
  1086. Sort List Box Items
  1087. Sort or Order A Table At Run Time
  1088. Use API Functions that Require a STRUCT
  1089. Use API Functions that Require Pointers to Arrays
  1090. Use Conditional Formatting in a Report
  1091. Use Slider and Status Bar Controls
  1092. Use the RichText Control
  1093. View Type Library Information
  1094. Add and Remove Items in a Treeview ControlT
  1095. Add and Remove Items in a Treeview Control
  1096. File: SAMPLES\SOLUTION\OLE\BLDTREE.SCX
  1097. A treeview control displays a collection of Node objects, each of which consists of a label and an optional bitmap. After creating a treeview control, you can add, remove, arrange, and otherwise manipulate Node objects by setting properties and invoking methods.
  1098. This sample illustrates adding nodes to a treeview control, deleting nodes, selecting nodes programmatically, writing a treeview hierarchy to a table, and reading a treeview hierarchy from a table.
  1099. Adding Nodes
  1100. Each node in a treeview control needs to have a unique key that is a character string, generated by the NewKey method in this sample form.
  1101. *NewKey method
  1102. cKey = THIS.cNextKey
  1103. THIS.cNextKey = ALLTRIM(STR(VAL(THIS.cNextKey) + 1) + "_")
  1104. RETURN cKey
  1105. The Add method of the treeview control is used to add new nodes. The code associated with the Click event of cmdNewNode adds a root level node using the Add method:
  1106. o = THISFORM.oleTree
  1107. o.Nodes.Add(,1,THISFORM.NewKey(),"Click to edit text",0)
  1108. The code associated with the Click event of cmdNewChild adds a node as a child of the currently selected node:
  1109. o = THISFORM.oleTree
  1110. IF !ISNULL(o.SelectedItem) THEN
  1111. o.Nodes.Add(o.SelectedItem.Key, 4, THISFORM.NewKey(), "Click to edit text",0)
  1112. ENDIF
  1113. Deleting Nodes
  1114. You can delete all of the nodes by calling the Clear method:
  1115. THISFORM.oleTree.Nodes.Clear
  1116. Or you can use the Remove method to delete selected nodes. All children of the deleted node are also deleted.
  1117. THISFORM.oleTree.Nodes.Remove(THISFORM.oleTree.SelectedItem.Key)
  1118. Writing And Reading Hierarchies In Tables
  1119. To save your treeview hierarchy in a table so you can reload it and edit it, loop through all the nodes in the treeview control and write the Key, the parent node
  1120. s Key, and the Text to the appropriate fields of a table.
  1121. FOR i = 1 TO loNodes.Count
  1122. IF ISNULL(loNodes.Item(i).Parent)
  1123. lcParent = "0_" && Root
  1124. lcParent = loNodes.Item(i).Parent.Key
  1125. ENDIF
  1126. INSERT INTO (lcDBFName) VALUES ;
  1127. (loNodes.Item(i).Key, ;
  1128.  lcParent, ;
  1129.  loNodes.Item(i).Text)
  1130. ENDFOR
  1131. To reconstruct the treeview hierarchy, scan through the records in the table, using the parent key, key, and text values that you previously stored.
  1132. * Fill the TreeView control with values in the table.
  1133. o = THISFORM.oleTree.Nodes
  1134. IF ALLTRIM(parent) = '0_'
  1135. o.add(,1,ALLTRIM(key),ALLTRIM(text),0)
  1136. o.add(ALLTRIM(parent),4,ALLTRIM(key), ALLTRIM(text),0)
  1137. ENDIF
  1138. THISFORM.cNextKey = ALLTRIM(STR(VAL(key) + 1) + "_")
  1139. ENDSCAN
  1140. Add Items Interactively to a List BoxO
  1141. Add Items Interactively to a List Box
  1142. File: SAMPLES\SOLUTION\CONTROLS\LISTS\LADD.SCX
  1143. This sample demonstrates adding and removing list box items. When a user types text in the text box and presses ENTER, the text in the text box is added to the list and the cursor is returned to the text box so that the user can enter another value. 
  1144. To allow a user to interactively add items to a list, use the AddItem method. In the sample, the following code in the text box KeyPress event adds the text in the text box to the list box and clears the text box when the user presses ENTER:
  1145. PARAMETERS nKeyCode, nShiftCtrlAlt
  1146. IF nKeyCode = 13     && Enter Key
  1147. THISFORM.lstAdd.AddItem (This.Value)
  1148. THIS.Value = ""
  1149. ENDIF
  1150. The following code in the DblClick event of the list box removes the item that was double-clicked, sending the value to the text box:
  1151. THISFORM.txtAddText.Value = This.List(This.ListIndex)
  1152. THIS.RemoveItem (This.ListIndex)
  1153. Add Menu Items at Run TimeD
  1154. Add Menu Items at Run Time
  1155. File: SAMPLES\SOLUTION\MENUS\FILLMENU.SCX
  1156. This sample illustrates adding menu items to a menu at run time.
  1157. The menu definition in this sample is defined in the 
  1158. Menu Designer
  1159. , with a single prompt and an empty submenu named 
  1160. empty_pop
  1161. Code is included to be executed when a user chooses any item in the menu:
  1162. PROCEDURE takeaction(cPrompt)
  1163. #DEFINE MSG_LOC "You chose " + cPrompt + "." 
  1164. IF cPrompt = "Release this menu"
  1165. RELEASE PAD dynmenu of _MSYSMENU
  1166. WAIT WINDOW MSG_LOC TIMEOUT 1
  1167. ENDIF
  1168. The code associated with the Click event of cmdRefresh on the form runs the menu.
  1169. DO dynamic.mpr
  1170. Then, for each item in the list, the code defines a menu item with the prompt and message text.
  1171. FOR i = 1 TO THISFORM.lstMenu.ListCount
  1172. DEFINE BAR i OF empty_pop PROMPT (ALLTRIM(THISFORM.lstMenu.List(i,1))) ;
  1173. MESSAGE (THISFORM.lstMenu.List(i,2))
  1174. ENDFOR
  1175. There is also code to provide the prompt to allow a user to release the menu.
  1176. DEFINE BAR i + 1 OF empty_pop PROMPT "\-"
  1177. DEFINE BAR i + 2 OF empty_pop PROMPT "Release this menu" ;
  1178. MESSAGE "Remove the Dynamic Items menu from the menu bar."
  1179. Add New Items to a Combo BoxF
  1180. Add New Items to a Combo Box
  1181. File: SAMPLES\SOLUTION\CONTROLS\COMBOBOX\LOOKUP.SCX
  1182. This sample illustrates adding user-entered text to a combo box drop-down and providing lookup capability.
  1183. Adding User Text to a Combo Box Drop-Down
  1184. A combo box allows a user to enter text or select an item from a drop-down list. You can also add the text a user types in the combo bE
  1185. ox as a new item in the drop-down list so the user won
  1186. t have to type the same text multiple times.
  1187. There are multiple ways to add user text to the drop-down list of a combo box, depending on the RowSourceType property setting of the combo box. In this sample, the RowSourceType of the combo boxes is 1 - Value. If the value the user enters isn
  1188. t already in the drop-down list for cboCombo, the following code adds a comma and the new value to the RowSource:
  1189. cCountryName = ALLTRIM(Custs.Country)
  1190. IF ATC(m.cCountryName,THIS.RowSource)=0 AND !EMPTY(m.cCountryName)
  1191. THIS.RowSource=THIS.RowSource+","+m.cCountryName 
  1192. ENDIF
  1193. The combo-box in the 
  1194. Programmatically Manipulate Text
  1195.  example has a RowSourceType of 0 - None. The following code in the Valid event of cboSearchString in SAMPLES\SOLUTION\CONTROLS\TXT_EDT\TEXT.SCX adds a user-entered value to the drop-down list of the combo box:
  1196. IF !EMPTY(THIS.Text)
  1197. FOR i = 1 TO THIS.ListCount
  1198. IF THIS.List(i) = THIS.Text
  1199. RETURN
  1200. ENDIF
  1201. ENDFOR
  1202. THIS.AddItem(THIS.Text)
  1203. ENDIF
  1204. If the RowSource of the combo box is an array, you need to add the user text to the array and call the Requery method of the combo box.
  1205. If the RowSource is a table or a cursor, you need to add a record, REPLACE the blank field with the user-entered value and Requery the combo box.
  1206. Provide Lookup Capability
  1207. In addition to illustrating how to add items to a combo box, this sample demonstrates three ways of allowing a user to filter a table for particular values. A user can:
  1208. Enter values in a combo box.
  1209. Select an item from a drop-down list.
  1210. Enter partial values in a combo box for incremental search.
  1211. Enter Values in a Combo Box
  1212. The key code is associated with the LostFocus event of cboCombo. After making sure that the user has entered a value, the LostFocus code selects the records that match the user
  1213. s text and sets the RecordSource property of the grid to the result set.
  1214. cDisplayValue = ALLTRIM(THIS.DisplayValue)
  1215. IF THIS.Value = "(All)"
  1216. SELECT country AS location,* FROM CUSTOMER;
  1217. INTO CURSOR Custs
  1218. thisform.grdcust.recordsource = "Custs"
  1219. SELECT country AS location,* FROM CUSTOMER ;
  1220.  WHERE UPPER(ALLTRIM(Customer.Country)) = UPPER(m.cDisplayValue);
  1221.  INTO CURSOR Custs
  1222. THISFORM.grdCust.RecordSource = "Custs"
  1223. ENDIF
  1224. Select an Item from a Drop-down List
  1225. Basically the same lookup code is associated with the InteractiveChange event of cboDrop 
  1226.  if the Value of the combo box is 
  1227. (All)
  1228. , Select all records into the cursor, otherwise, select the records that match the user
  1229. s choice.
  1230. Enter Partial Values for Incremental Search
  1231. Code in the InteractiveChange event of cboIntSearch performs the lookup every time the user types a character in the combo box.
  1232. #DEFINE DELKEY 127
  1233. LPARAMETERS nKeyCode, nShiftAltCtrl
  1234. LOCAL cDisplayValue
  1235. IF nKeyCode = DELKEY
  1236. cDisplayValue = ALLTRIM(THIS.DisplayValue)
  1237. IF LEN(m.cDisplayValue)=1
  1238. cDisplayValue = ""
  1239. cDisplayValue = LEFT(cDisplayValue,LEN(cDisplayValue)-1)
  1240. ENDIF
  1241. cDisplayValue = ALLTRIM(THIS.DisplayValue)+CHR(nKeyCode)
  1242. ENDIF
  1243. THISFORM.LockScreen = .T.
  1244. DO CASE
  1245. CASE EMPTY(m.cDi N
  1246. splayValue)
  1247. THISFORM.grd
  1248. ecord
  1249. ource = " "
  1250. CASE THIS.Value = "(All)"
  1251. SELECT country AS location,* FROM CUSTOMER;
  1252. INTO CURSOR Custs
  1253. THISFORM
  1254. ecord
  1255. ource = "Custs"
  1256. OTHERWISE
  1257. SELECT country AS location,* FROM CUSTOMER ;
  1258.  WHERE UPPER(ALLTRIM(Customer.Country)) = UPPER(m.cDisplayValue);
  1259.  INTO CURSOR Custs
  1260. THISFORM
  1261. ecord
  1262. ource = "Custs"
  1263. ENDCASE
  1264. THISFORM.ResetCombos(THIS)
  1265. THISFORM.LockScreen = .F.
  1266. Allow Users to Choose List ValuesK
  1267. Allow Users to Choose List Values
  1268. File: SAMPLES\SOLUTION\FORMS\DATALOOK.SCX
  1269. This sample illustrates providing users with a set of values, selected from another table, in a list box and in a drop-down list box. The value the user chooses is stored in the current table.
  1270. It is often more convenient for a user to choose from a list of predetermined values, and, of course, you minimize the risk that the user will mistype a value. Setting a few list box properties is all that is required to provide this capability. For example, the following properties were set for cboEmp_id on the 
  1271. Using Combo Box
  1272.  page:
  1273. Property
  1274. Setting
  1275. BoundColumn
  1276. ColumnCount
  1277. ControlSource
  1278. orders.emp_id
  1279. RowSource
  1280. SELECT DISTINCT ALLTRIM( employee.first_name) + " " + ALLTRIM( employee.last_name) , EMP_ID FROM employee INTO CURSOR cEmpCombo ORDER BY first_name
  1281. RowSourceType
  1282. 3 - SQL Statement
  1283. Rather than having the user choose an employee id number from the drop-down list, the SELECT statement allows you to show the user the employees
  1284.  first and last names.
  1285. Because the SELECT statement creates a cursor, code in the Destroy event closes the cursor:
  1286. IF USED("cEmpCombo") THEN
  1287. USE IN cEmpCombo
  1288. ENDIF
  1289. Allow Users to Drag and Drop ControlsO
  1290. Allow Users to Drag and Drop Controls
  1291. File: SAMPLES\SOLUTION\FORMS\DDROP.SCX
  1292. This sample explains how to implement drag and drop operations. One page on the form illustrates manual dragging of controls by calling the Drag method. Explicitly calling the Drag method allows you to process other code in the Click event of the control. The other page illustrates using the Automatic DragMode setting so that the Drag and Drop operation is started automatically when the user presses the mouse button over the controls.
  1293. Repositioning the Command Button
  1294. In the MouseMove event of cmdDrop, if the left mouse button is down, find out how far the mouse pointer is from the top and the left of the command button and begin the drag operation.
  1295. LPARAMETERS nButton, nShift, nXCoord, nYCoord
  1296. IF nButton = 1 && Left button
  1297. THISFORM.XOffset = nXCoord - THIS.Left
  1298. THISFORM.YOffset = nYCoord - THIS.Top
  1299. THIS.Drag
  1300. ENDIF
  1301. In the DragDrop event of the page that the command button is on, reposition the command button.
  1302. oSource.Left = nXCoord - THISFORM.XOffset
  1303. oSource.Top = nYCoord - THISFORM.Yoffset
  1304. Changing the Color of the Shape
  1305. The DragMode property of the colored squares on the Change Colors page of the form is set to 1 - Automatic. As soon as the user presses the mouse button on the squares, the drag operation begins. Any code added to the Click event of the squares would never be executed.
  1306. Code in the DragDrop event of the circle changes its BackColor property to match that of the drag source.
  1307. LPARAMETERS oSource, nXCoord, nYCoord
  1308. THIS.BackColor = oSource.BackColor
  1309. Automate Microsoft Word and ExcelK
  1310. Automate Microsoft Word and Excel
  1311. File: SAMPLES\SOLUTION\OLE\OLEAUT1.SCX
  1312. This is a simple sample showing Visual FoxPro as an OLE Automation Controller. It demonstrates how to select data from a Visual FoxPro database, place the data in a Microsoft Excel worksheet, graph the data using Chart, and then display the graph in Word. To use this sample, you need at least Excel 5.0, Word 6.0, and TESTDATA.DBC!customer.dbf, located in the \SAMPLES\DATA directory.
  1313. The following line of code creates a reference to a Microsoft Excel spreadsheet.
  1314. objXLsheet=createobject("Excel.Sheet")
  1315. The following line of code adds a chart to the spreadsheet.
  1316. objChart1 = objXLsheet.ChartObjects.Add(100, 100, 200, 200)
  1317. The following line of code creates a reference to Microsoft Word
  1318. objWDdoc=createobject("word.basic")
  1319. oWordRef = GetObject('','word.basic')
  1320. Automate a Microsoft Excel SpreadsheetP
  1321. Automate a Microsoft Excel Spreadsheet
  1322. File: SAMPLES\SOLUTION\OLE\OLEXL.SCX
  1323. This form shows two samples of Visual FoxPro calling an Excel worksheet through automation.
  1324. Trend
  1325.  button performs a query followed by a cross-tab to create a dataset to pass to Excel through automation using the Excel.Sheet object. Once in Excel, Visual FoxPro can call a Trend function to perform a simple regression analysis.
  1326. Chart
  1327.  button automates the Excel.Chart object to create a chart. Excel supports passing data through automation, but MS Graph does not. However, you can distribute MS Graph with your applications.
  1328. Automate a Microsoft Word Document in a FormV
  1329. Automate a Microsoft Word Document in a Form
  1330. File: SAMPLES\SOLUTION\OLE\OLEWORD.SCX
  1331. This sample shows how you can automate an embedded Word object on a form, insert some rich text, and then format the text. Typical automation with Word is usually done via the 
  1332. Word.Basic
  1333.  object used interactively with a CREATEOBJECT(
  1334. ) function. 
  1335. oForm = THISFORM
  1336. oForm.AddObject('oWordDoc','OleControl','WordDocument')
  1337. oForm.oWordDoc.Visible =  .t.
  1338. oForm.oWordDoc.DoVerb(0)
  1339. Change Font Attributes@
  1340. Change Font Attributes
  1341. File: SAMPLES\SOLUTION\TOOLBARS\FORMAT.SCX
  1342. This example illustrates using a toolbar to set FontName, FontSize, FontBold, FontItalic, ForeColor, and BackColor properties of controls on a form.
  1343. The toolbar is the tbrEditing class in SAMPLES\CLASSES\SAMPLES.VCX. The nAppliesTo property of the class specifies whether to set the properties of the currently selected control, all text boxes and edit boxes on the form, or all controls on the form. The code in the InteractiveChange or Click event of the toolbar controls sets the properties. For example, the following code is associated with the Click event of cmdBold:
  1344. IF TYPE("_SCREEN.ActiveForm") = 'O'
  1345. oForm = _SCREEN.ActiveForm
  1346. RETURN
  1347. ENDIF
  1348. DO CASE
  1349. CASE THIS.Parent.nAppliesTo = 1
  1350. && Current Control
  1351. oForm.ActiveControl.FontBold = THIS.Value
  1352. CASE THIS.Parent.nAppliesTo = 2
  1353. && Text and edit boxes
  1354. oForm.SetAll('FontBold', THIS.Value, 'TEXTBOX')
  1355. oForm.SetAll('FontBold', THIS.Value, 'EDITBOX')
  1356. CASE THIS.Parent.nAppliesTo = 3
  1357. && All Controls
  1358. oForm.SetAll('FontBold', THIS.Value)
  1359. ENDCASE
  1360. The only code in the form is associated with the GotFocus event of the controls. Each GotFocus event contains the following line of code:
  1361. THISFORMSET.tbrEditing.Refresh(THIS)
  1362. The Refresh method of tbrEditing sets the values of the editing controls of the toolbar to reflect the current settings of the object whose reference is passed in as a parameter.
  1363. Change Pages When a User Chooses a ButtonS
  1364. Change Pages When a User Chooses a Button
  1365. File: SAMPLES\SOLUTION\CONTROLS\PAGEFRAME\MSGBOX
  1366. This sample allows you to interactively construct a message box.
  1367. There are six command button combinations possible in a message box. Each of these combinations is displayed on a separate page in a page frame on the Messagebox Builder form.
  1368. The option buttons, labeled 0 through 5, allow you to specify which combination of command buttons you want to be displayed in your message box. The selected button in the page indicates the default Messagebox button selection. The ActivePage property of the page frame is set to the Value of the Option group.
  1369. Constructing the MESSAGEBOX Code
  1370. In the InteractiveChange event of the controls on the form, the WriteCode method of the form is called to dynamically construct the MESSAGEBOX code.
  1371. * WriteCode Method
  1372. #DEFINE QM '"'
  1373. cString = '=MESSAGEBOX('
  1374. cString = cString + QM + ALLTRIM(STRTRAN(THIS.edtMessage.Value, CHR(13)+CHR(10), QM + '+CHR(13)+' + QM)) + QM + ','
  1375. cString = cString + THIS.cboIcon.Value + '+' 
  1376. cString = cString + THIS.DefaultButton + '+' 
  1377. cString = cString + ALLTRIM(STR(THIS.opgButtons.Value - 1)) + ','
  1378. cString = cString + QM + ALLTRIM(THIS.txtCaption.Value) + QM + ')'
  1379. THIS.edtCode.Value = cString
  1380. Change the Number of Tabs at Run TimeO
  1381. Change the Number of Tabs at Run Time
  1382. File: SAMPLES\SOLUTION\PGFRAME\PFSAM1.SCX
  1383. This sample illustrates using a page frame with tabs. The number of tabs 
  1384. changes dynamically when a user chooses a new value in a spinner. When the user selects a tab, a list box displays values specific to the tab.
  1385. To change the number of tabs at run time
  1386. Set the PageCount property to the desired number of pages.
  1387. The list box in this sample is positioned on the form, not on any of the pages in the page frame. This placement allows you to have a single control visible in all of your pages.
  1388. Two user-defined form methods set the captions on the tabs and make sure the values in the list box match: UpdateList and SetCaption.
  1389. UpdateList Method
  1390. UpdateList is called when the number of tabs changes and when the user selects a new tab.
  1391. LOCAL lnPage, lcHigh, lcLow
  1392. #define NO_MATCH_LOC 'No Matching Names for '
  1393. DIMENSION THISFORM.aCustomers[1,2]
  1394. lnPage = THISFORM.pgfRolodex.activepage
  1395. THISFORM.aCustomers[1,1] = NO_MATCH_LOC + ;
  1396. THISFORM.pgfRolodex.Pages(lnPage).Caption
  1397. THISFORM.aCustomers[1,2] = ""
  1398. lcHigh = substr(THISFORM.pgfrolodex.Pages(lnPage).caption,3,1)
  1399. lcLow = substr(THISFORM.pgfrolodex.Pages(lnPage).caption,1,1)
  1400. SELECT company, phone FROM customer;
  1401. WHERE company <= lcHigh and company => lcLow;
  1402. ORDER BY company;
  1403. INTO ARRAY THISFORM.aCustomers
  1404. THISFORM.lstCustomers.Requery
  1405. THISFORM.lstCustomers.Value = 1
  1406. SetCaption Method
  1407. SetCaption is called in the spinner's UpClick and DownClick events to calculate what captions should appear on the tabs. 
  1408. THISFORM.LockScreen = .T.
  1409. FOR n = 1 to THISFORM.pgfRolodex.PageCount
  1410. FirstLetter = SUBSTR(THISFORM.Alphabet,((n - 1)*ROUND(LEN(THISFORM.Alphabet)/THISFORM.pgfRolodex.PageCount,0))+1,1)
  1411. IF n = THISFORM.pgfRolodex.PageCount
  1412. &&last page
  1413. LastLetter = right(THISFORM.Alphabet,1)
  1414. LastLetter = SUBSTR(THISFORM.Alphabet,((n)*ROUND(LEN(THISFORM.Alphabet)/THISFORM.pgfRolodex.PageCount,0)),1)
  1415. ENDIF
  1416. THISFORM.pgfRolodex.Pages(n).Caption = FirstLetter + "-" + LastLetter
  1417. ENDFOR
  1418. THISFORM.LockScreen = .F.
  1419. Alphabet is a user-defined form property that is used to determine the captions for each tab To get the same functionality in different languages, set the Alphabet property to a string containing all the letters in the target language alphabet.
  1420. Coordinate Menu Items and Toolbar ButtonsS
  1421. Coordinate Menu Items and Toolbar Buttons
  1422. File: SAMPLES\SOLUTION\MENUS\TOOLMENU.SCX
  1423. This sample illustrates coordinating menu items and toolbar buttons that provide the same functionality.
  1424. Sometimes you
  1425. ll want to make particular functionality accessible from both menu items and toolbar buttons. For sample, in Visual FoxPro you can save a file by choosing the 
  1426.  toolbar button or by choosing 
  1427.  from the 
  1428.  menu. 
  1429. There are three components to this sample:
  1430. Component
  1431. Description
  1432. TOOLMENU.SCX
  1433. the form
  1434. tbrBackColor in SOLUTION.VCX
  1435. the toolbar
  1436. TOOLMENU.MNX
  1437. the menu
  1438. In the Init event of the form, a toolbar object is created whose object reference is a property on the form, 
  1439. oToolbar
  1440. SET CLASSLIB TO ..\solution
  1441. This.oToolbar = CREATEOBJECT('tbrbackcolor')
  1442. * Position the toolbar and show it
  1443. THIS.oToolbar.Left = THIS.Left + 10
  1444. THIS.oToolbar.Top = THIS.Top - 50
  1445. THIS.oToolbar.Visible = .T.
  1446. * Push the current menu on the stack so it can be 
  1447. * restored in the Destroy event of the form.
  1448. PUSH MENU _MSYSMENU
  1449. * Run the menu
  1450. DO toolmenu.mpr
  1451. Rather than coding duplicate functionality in the toolbar and the menu, updating it both places if changes are required, the code associated with the menu items calls the code associated with the toolbar buttons. For example, the following command is associated with the first menu item:
  1452. _VFP.ActiveForm.oToolbar.cmdRed.click
  1453. The SKIP FOR clause of the menu items causes them to be disabled when the associated toolbar button is disabled. For example, the following expression is associated with the SKIP FOR clause of the first menu item:
  1454. !_VFP.ActiveForm.oToolbar.cmdRed.Enabled
  1455. Create a 1-To-Many Data Entry FormL
  1456. Create a 1-To-Many Data Entry Form
  1457. File: SAMPLES\SOLUTION\FORMS\MANY.SCX
  1458. This sample illustrates the basic tasks associated with a one-to-many data entry form.
  1459. When you choose the 
  1460.  button beside the parent table text boxes, the following code is executed:
  1461. SELECT CUSTOMER
  1462. APPEND BLANK
  1463. THISFORM.Refresh
  1464. When you choose the 
  1465.  button beside the grid that displays the child records, more code is executed.
  1466. After selecting the orders table, the code calculates a new id value for the order, adds the blank record, then stores the parent id and order id to the appropriate fields.
  1467. CALCULATE MAX(order_id) ALL TO lMaxID
  1468. lMaxID = ALLTRIM(STR(VAL(lMaxID) + 1))
  1469. APPEND BLANK
  1470. REPLACE cust_id WITH Customer.Cust_id IN orders
  1471. REPLACE order_id with lMaxID in orders
  1472.    This method of creating a new id value would not be reliable if multiple users were adding new orders at the same time. Instead, you can create a new id as illustrated in the 
  1473. Create a Default Unique ID Value for a Field
  1474.  sample.
  1475. Create a Default Unique Id Value for a FieldV
  1476. Create a Default Unique ID Value for a Field
  1477. File: SAMPLES\SOLUTION\DB\NEWID.SCX
  1478. This sample uses a stored procedure in a database to provide a default primary key value.
  1479. To create a default unique ID
  1480. Add a separate table to the database that stores the next ID for each table in the database.
  1481. The name of this table in the sample is IDS.DBF. It contains two fields: 
  1482. Table C(10), NextID I
  1483. Create a function in the stored procedures of the database to return the next id value from the id table.
  1484. The name of this function in the sample is 
  1485. NewID
  1486. . It is listed below.
  1487. Set the default value for the field to the function.
  1488. NewID Stored Procedure
  1489. FUNCTION NewID(tcAlias)
  1490. LOCAL lcAlias, lnID, lcOldReprocess, lnOldArea
  1491.   lnOldArea = SELECT()
  1492.   IF PARAMETERS() < 1
  1493.     lcAlias = UPPER(ALIAS())
  1494.   ELSE
  1495.     lcAlias = UPPER(tcAlias)
  1496.   ENDIF
  1497.         
  1498.   lcOldReprocess = SET('REPROCESS')
  1499.   * Lock until user presses Esc
  1500.   SET REPROCESS TO AUTOMATIC
  1501.   IF !USED("IDS")
  1502.     USE newid!ids IN 0
  1503.   ENDIF
  1504.   SELECT ids
  1505.       
  1506.   IF SEEK(lcAlias, "Ids", "table")
  1507.     IF RLOCK()
  1508.       lnID = ids.nextid
  1509.       REPLACE ids.nextid WITH ids.nextid + 1
  1510.       UNLOCK
  1511.     ENDIF
  1512.   ENDIF
  1513.   SELECT (lnOldArea)
  1514.   SET REPROCESS TO lcOldReprocess
  1515.   RETURN lnID
  1516. ENDFUNC
  1517. Create a Query-By-Example FormH
  1518. Create a Query-By-Example Form
  1519. File: SAMPLES\SOLUTION\FORMS\QBF.SCX
  1520. This sample enables users to search and filter records in the same interface that they view the records.
  1521. When a user chooses 
  1522. Enter QBF
  1523. , the code associated with the Click event of cmdQBFMode begins a transaction and appends a blank record to the table to store the user
  1524. s query text.
  1525. * extract from cmdQBFMode.Click
  1526. BEGIN TRANSACTION
  1527. APPEND BLANK
  1528. THISFORM.Refresh
  1529. When the user chooses 
  1530. Query
  1531. , code associated with the Click event of cmdExecuteQBF rolls back the transaction, throwing away the new record.
  1532. You can use transactions only with tables contained in a database. If you want to include QBF capabilities for a table that is not in a database, you can loop through all the controls on the form, save the old ControlSource property setting and set the ControlSource property of the controls to an empty string. After getting the user query string, you can loop back through the controls and reset the ControlSource properties.
  1533. Code associated with the Click event of cmdExecuteQBF also loops through the controls on the form, checks for user-entered values, and calls the ParseCondition method to assemble the filter string.
  1534. A user can enter a single value to match or an expression. For example, a user can enter either of the values below in the Title text box to set a filter:
  1535. Sales Manager
  1536. Sales Manager
  1537. If the user doesn
  1538. t enter an expression, quotation marks are not required.
  1539. The ParseCondition Method
  1540. LPARAMETERS cCondition, cControlSource
  1541. LOCAL lcRetCondition, lcFieldName
  1542. IF TYPE('cCondition') = 'C'
  1543. cCondition = ALLTRIM(cCondition)
  1544. ENDIF
  1545. lcFieldName = SUBSTRC(cControlSource,(RATC(".",cControlSource)+1))
  1546. IF !EMPTY(cCondition) THEN
  1547. IF TYPE('cCondition')$ "CM" 
  1548. IF ("<"
  1549. $ cCondition OR ;
  1550. "==" 
  1551. $ cCondition OR ;
  1552. "LIKE" 
  1553. $ cCondition OR ;
  1554. "<>" 
  1555. $ cCondition OR ;
  1556. "!=" 
  1557. $ cCondition OR ;
  1558. $ cCondition OR ;
  1559. $ cCondition OR ;
  1560. $ cCondition)
  1561. lcRetCondition = lcFieldName + cConditi:
  1562. ENDIF
  1563. ENDIF
  1564. IF EMPTY(lcRetCondition)
  1565. DO CASE
  1566. * put quotes around character expressions
  1567. CASE TYPE(cControlSource) $ "CM"
  1568. lcRetCondition = lcFieldName + " = " + CHR(34) + cCondition + CHR(34)
  1569. * put braces around date expressions
  1570. CASE TYPE(cControlSource) $ "DT"
  1571. lcRetCondition = lcFieldName + " = {" + DTOC(cCondition) + "}"
  1572. OTHERWISE
  1573. lcRetCondition = lcFieldName + " = " + STR(cCondition)
  1574. ENDCASE
  1575. ENDIF
  1576. lcRetCondition = ""
  1577. ENDIF
  1578. RETURN lcRetCondition
  1579. Create a Single Table Data Entry FormO
  1580. Create a Single Table Data Entry Form
  1581. File: SAMPLES\SOLUTION\FORMS\SINGLE.SCX
  1582. This sample illustrates the simplest scenario for a single-user, single-table data entry form.
  1583. The ControlSource property of each of the text boxes and combo boxes on the form is set to a field in the Customer table.
  1584. An APPEND BLANK command is issued in the Click event of cmdNew.
  1585. APPEND BLANK
  1586. THISFORM.Refresh
  1587. The DELETE command is issued in the Click event of cmdDelete.
  1588. * cmdDelete.Click
  1589. #DEFINE MSGBOX_YES
  1590. #DEFINE C_MSGBOX1
  1591. #DEFINE C_DELETE_LOC
  1592. "Are you sure you want to delete this record?"
  1593. IF MESSAGEBOX(C_DELETE_LOC,C_MSGBOX1) = MSGBOX_YES
  1594. DELETE
  1595. IF !EOF()
  1596. SKIP 1
  1597. ENDIF
  1598. IF EOF() AND !BOF()
  1599. SKIP -1
  1600. ENDIF
  1601. THISFORM.Refresh
  1602. ENDIF
  1603. Extending the Data Entry Form
  1604. To create a more robust data entry form, one that allows a user to cancel changes or allows multiple users to access the same data, you need to use transactions and table or row buffering. For more information on these features, see Chapter 17, 
  1605. Programming for Shared Access,
  1606.  in the Visual FoxPro 
  1607. Developer
  1608. s Guide
  1609. Create an SDI Form<
  1610. Create an SDI Form
  1611. File: SAMPLES\SOLUTION\FORMS\SDIFORM.SCX
  1612. This sample illustrates Visual FoxPro support of SDI forms. In order to create an SDI form, all you have to do is set the form
  1613. s ShowWindow property to 2 - As Top-Level Form. SDI forms do not require the Visual FoxPro window to be visible.
  1614. Adding Forms
  1615. There are two ways to add forms to a Top-Level (SDI) form. The first and easiest is to create a new form and set its ShowWindow property to 1 (In Top-Level form). While this may seem the most appropriate, it is not always the best solution because the ShowWindow property can only be set at design time.
  1616. Another method is to use the ACTIVATE WINDOW command. The code below from the SDIForm sample shows just this. Since this command is not object-based, you must reference a form by its window name (Name property).
  1617. ACTIVATE WINDOW (thisform.oWindows[m.nGetWin].NAME) ;
  1618. IN WINDOW (thisform.name)
  1619. Adding Menus
  1620. Menus can also be added to SDI forms. There is now a new Top-Level Form check box in the 
  1621. Menu Designer
  1622. s View
  1623.  menu 
  1624. General Options
  1625.  dialog box. A 
  1626. Top-Level Form
  1627.  menu will be generated if you check this option and can be called as shown here.
  1628. DO sdiform.mpr WITH 
  1629. THISFORM,.T.
  1630.    If system menu items rely on the main Visual FoxPro window being visible, they won
  1631. t give the expected results when the main Visual FoxPro window is hidden.
  1632. Adding Toolbars
  1633. In addition to menus and windows, you can also add toolbars to your SDI forms. Toolbars are objects like forms, so you can take advantage of the Visual FoxPro object model and scope that toolbar to the form. The SDI form sample uses a custom property to create and keep the toolbar in scope.
  1634. SET CLASSLIB TO sditbar ADDITIVE
  1635. thisform.oToolbar=create("sditb1")
  1636. thisform.oToolbar.show
  1637. Create Dynamic Shortcut MenusG
  1638. Create Dynamic Shortcut Menus
  1639. File: SAMPLES\SOLUTION\MENUS\DYNSHORT.SCX
  1640. This sample illustrates an alternative way to create shortcut menus.
  1641. The shortcut menus in the 
  1642. Display Shortcut Menus
  1643.  sample were created in the Menu Designer. The advantages of using the Menu Designer are ease of design, the ability to create cascading menus, and simple integration on a form. With the Menu Designer, however, you need a separate .MNX, .MNT, and .MPR file for each shortcut menu. If you make a change, you need to generate and compile the menu code again.
  1644. The dynamic shortcut menu engine is a custom class that you can add to any form: menulib in SAMPLES\CLASSES\UTILITY.VCX. The ShowMenu method of this class defines a menu and displays it at the MousePointer location as determined by the MROW(
  1645. ) and MCOL(
  1646. ) functions.
  1647. In the RightClick event of the objects you want to create a shortcut menu for:
  1648. Create an array with the shortcut menu items.
  1649. Pass the array to the ShowMenu method of the menulib class.
  1650. Process the user choice by checking the BAR(
  1651. ) value.
  1652. For example, the following code is associated with the RightClick event of the form:
  1653. LOCAL laMenu[5]
  1654. laMenu=""
  1655. laMenu[1]="\<Center"
  1656. laMenu[2]="\<Font..."
  1657. laMenu[3]="\<Minimize"
  1658. laMenu[4]="\-"
  1659. laMenu[5]="E\<xit"
  1660. THISFORM
  1661. .oMenuShortcut.ShowMenu(@laMenu)
  1662. DO CASE
  1663. CASE BAR()=1
  1664. THISFORM
  1665. .AutoCenter=.T.
  1666. CASE BAR()=2
  1667. THISFORM
  1668. .SetFont
  1669. CASE BAR()=3
  1670. THISFORM
  1671. .WindowState=1
  1672. CASE BAR()=5
  1673. THISFORM
  1674. .Release
  1675. ENDCASE
  1676. Customize the Open Dialog BoxG
  1677. Customize the Open Dialog Box
  1678. File: SAMPLES\SOLUTION\OLE\COMMDLOG.SCX
  1679. This sample illustrates customizing the appearance and behavior of the 
  1680.  dialog box as exposed through the Common Dialog control.
  1681. You can set the Flags property of the Common Dialog control to specify the behavior of the 
  1682.  dialog box. For a list of the various Flags values, see 
  1683. Open Dialog Box Flag Values
  1684. The following code in the Click event of cmdFiles checks the values of the various check boxes on the form and sets the Flags property of the Common Dialog control.
  1685. Set the Read-only checkbox flag
  1686. IF !thisform.chkRead.Value
  1687. m.nFlags = m.nFlags + 4
  1688. ENDIF
  1689. Set the Multiple files flag
  1690. IF thisform.chkMulti.Value
  1691. m.nFlags = m.nFlags + 
  1692. ENDIF
  1693. Set the Help button flag
  1694. IF thisform.chkHelp.Value
  1695. m.nFlags = m.nFlags + 16
  1696. ENDIF
  1697. Set the enforce file existence flag
  1698. IF thisform.chkMulti.Value
  1699. m.nFlags = m.nFlags + 4096
  1700. ENDIF
  1701. Set the Flags property of the Common Dialog control
  1702. THISFORM
  1703. .oleCommDlog.Flags = m.nFlags
  1704. Set the Filter property of the Common Dialog control
  1705. You can use the Filter property of the Common Dialogs control to specify what files a user is allowed to choose. 
  1706. THISFORM
  1707. .oleCommDlog.Filter = "All files
  1708. "(*.*)|*.*|Text (*.txt)|*.txt
  1709. "|Pictures(*.bmp;*.ico)|*.bmp;*.ico"
  1710. Open Dialog Box Flag ValuesE
  1711. Open Dialog Box Flag Values
  1712. You can customize the 
  1713.  dialog box by setting the Flag property to the sum of a selection of these values: 
  1714. Value
  1715. Description
  1716. Causes the 
  1717. Read Only
  1718.  check box to be initially checked when the dialog box is created.  This flag also indicates the state of the 
  1719. Read Only
  1720.  check box when the dialog box is closed.
  1721. Causes the 
  1722. Save As
  1723.  dialog box to generate a message box if the selected file already exists.  The user must confirm whether to overwrite the file.
  1724. Hides the 
  1725. Read Only
  1726.  check box.
  1727. Forces the dialog box to set the current directory to what it was when the dialog box was opened.
  1728. Causes the dialog box to display the Help button. 
  1729. Specifies that the common dialog box allows invalid characters in the returned filename.
  1730. Specifies that the 
  1731. File Name
  1732.  list box allows multiple selections. The user can select more than one file at run time by pressing the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files.  When this is done, the FileName property returns a string containing the names of all selected files.  The names in the string are delimited by spaces.
  1733. Indicates that the extension of the returned filename is different from the extension specified by the DefaultExt property.  This flag isn't set if the DefaultExt property is Null, if the extensions match, or if the file has no extension.  This flag value can be checked upon closing the dialog box.
  1734. Specifies that the user can enter only valid paths.  If this flag is set and the user enters an invalid path, a warning message is displayed.
  1735. Specifies that the user can enter only names of existing files in the File Name text box.  R
  1736. If this flag is set and the user enters an invalid filename, a warning is displayed.  This flag automatically sets the 
  1737.  flag.
  1738. Specifies that the dialog box prompts the user to create a file that doesn't currently exist.  This flag automatically sets the 
  1739.  and 
  1740.  flags.
  1741. 16384
  1742. Specifies that sharing violation errors will be ignored.
  1743. 32768
  1744. Specifies using the Windows 95 explorer-like 
  1745. Open A File
  1746.  dialog box template.  (Windows 95 only.)
  1747. 524288
  1748. Use the Explorer-like 
  1749. Open A File
  1750.  dialog box template.  Common dialogs that use this flag do not work under Windows NT using the Windows 95 shell.
  1751. 1048576
  1752. Do not dereference shell links (also known as shortcuts).  By default, choosing a shell link causes it to be dereferenced by the shell.
  1753. 1048576
  1754. Do not dereference shortcuts (shell links).  By default, choosing a shortcut causes it to be dereferenced by the shell.  (Windows 95 only.)
  1755. 2097152
  1756. Allows the user to use long filenames.  (Windows 95 only.)
  1757. Disable or Display a Check Beside a Menu ItemW
  1758. Disable or Display a Check Beside a Menu Item
  1759. File: SAMPLES\SOLUTION\MENUS\CHKMENU.SCX
  1760. This sample illustrates dynamically disabling menu items and displaying check marks beside specific menu items.
  1761. The menu in this sample was created in the 
  1762. Menu Designer
  1763.  and is run when the form is initialized.
  1764. DO chkmenu.mpr
  1765. To disable a menu item, include an expression that evaluates to false (.F.) in the SET SKIP OF command. For example, the following line of code in the InteractiveChange event of a check box issues SET SKIP OF with the inverse of the value of the check box, disabling the menu item when the check box is not selected.
  1766. SET SKIP OF BAR 1 OF checkitems !THIS.Value
  1767. To display a check mark beside a menu item, include an expression that evaluates to true (.T.) after the TO keyword of the SET MARK OF command. For example, the following line of code in the InteractiveChange event of a check box issues the SET MARK OF command with the Value property setting of the check box.
  1768. SET MARK OF BAR 1 OF checkitems TO THIS.Value
  1769. Display a Stop Watch>
  1770. Display a Stop Watch
  1771. File: SAMPLES\SOLUTION\CONTROLS\TIMER\SWATCH.SCX
  1772. This sample includes the Stopwatch class (described in Chapter 3, 
  1773. Object-Oriented Programming,
  1774.  in the 
  1775. Developer's Guide
  1776. The Stopwatch Class
  1777. The Stopwatch class includes a timer and several display labels. The Timer increments numeric custom properties of the class and sets the Caption property of the labels accordingly.
  1778. The Start method of the class sets the Enabled property of the Timer to true (.T.). The Stop method sets the Enabled property of the Timer to false 
  1779. (.F.). And the Reset method sets the numeric properties to 0.
  1780. The Swatch Form
  1781. The Swatch form contains an object derived from the Stopwatch class, along with some command buttons. The code written for the Click event of the first command button on the form calls the Start and Stop methods of the Stopwatch class. The second button calls the Reset method of the Stopwatch class.
  1782. Display a System Clock@
  1783. Display a System Clock
  1784. File: SAMPLES\SOLUTION\CONTROLS\TIMER\CLOCK.SCX
  1785. This sample contains the Clock custom control in SAMPLES.VCX on a form. The class includes a text box for displaying the date and time and a timer for updating the display.
  1786. The TimeFormat property of the clock class can be set to 0 for 24-hour time format or 1 for 12-hour format. The code in the Timer event of the timer updates the time:
  1787. #DEFINE LONGDATE_LOC CDOW(DATE())+" "+CMONTH(DATE())+" "+ ;
  1788. ALLTRIM(STR(DAY(DATE())))+", "+ALLTRIM(STR(YEAR(DATE())))
  1789. IF This.Parent.TimeFormat = 0
  1790. This.Parent.txtTime.Value = IIF(VAL(SUBSTR(TIME(),1,2))>12, ;
  1791. ALLTRIM(STR((VAL(SUBSTR(TIME(),1,2))-12)))+SUBSTR(TIME(),3,6),TIME())
  1792. This.Parent.txtTime.Value = TIME()
  1793. ENDIF
  1794. THIS.Parent.txtDate.Value = LONGDATE_LOC
  1795. This class contains a separate text box for date and time values. If you want to hide one or the other, you can easily set its Visible property to false (.F.). An easier way to display the time and date is  to use a single text box and set the value of this text box in a timer control to DATETIME(
  1796. ). This will  allow you to take advantage of the Hours, Seconds, and DateFormat properties of a text box.
  1797. Display Calculated Values in a ColumnO
  1798. Display Calculated Values in a Column
  1799. File: SAMPLES\SOLUTION\CONTROLS\GRID\CALC.SCX
  1800. This sample illustrates how to display a calculated value in a column.  
  1801. Set the ControlSource property of the column to an expression with a calculation. For example, the following expression for the ControlSource of the Profit column displays the difference between the price and cost.
  1802. Products.Unit_Price - Products.Unit_Cost
  1803. When you change one or more values in the expression, the value in the column is automatically updated.
  1804.    Columns that display an expression containing a calculation are read-only.
  1805. Display Child Records from a RelationshipS
  1806. Display Child Records from a Relationship
  1807. File: SAMPLES\SOLUTION\CONTROLS\GRID\1_MANY.SCX
  1808. This sample demonstrates coordinating a one-to-many-to-many form with two grids displaying the many sides of the relationships. Very little code is needed in this sample. Setting a few properties is all that is involved.
  1809. Property settings
  1810. Text boxes for the "one" side of the relationship:
  1811. ControlSource = Customer.cust_id
  1812. ControlSource = Customer.company
  1813. Grid for the first "many" side of the relationship:
  1814. ChildOrder = cust_id
  1815. LinkMaster = customer
  1816. RecordSource = orders
  1817. RecordSourceType = 1 - Alias
  1818. RelationalExpr = customer.cust_id
  1819. ColumnCount = 4
  1820. Column1.ControlSource = "orders.order_no"
  1821. Column1.Header1.Caption = "Order"
  1822. Column2.ControlSource = "orders.order_date"
  1823. Column2.Header1.Caption = "Date"
  1824. Column3.ControlSource = "orders.to_name"
  1825. Column3.Header1.Caption = "Ship To"
  1826. Column4.ControlSource = "orders.order_amt"
  1827. Column4.Sparse = .F.
  1828. Column4.Header1.Caption = "Total"
  1829. Column4.Text1.InputMask = "$$999,999.99"
  1830. Grid for the 2nd 'many' side of the relationship
  1831. ChildOrder = order_id
  1832. LinkMaster = Orders
  1833. RecordSource = Orditems
  1834. RecordSourceType = 1 - Alias
  1835. RelationalExpr =Orders.order_id
  1836. ColumnCount = 4
  1837. Column1.ControlSource = "orditems.line_no"
  1838. Column1.Header1.Caption = "Item"
  1839. Column2.ControlSource = "products.prod_name"
  1840. Column2.Header1.Caption = "Product"
  1841. Column3.ControlSource = "orditems.quantity"
  1842. Column3.Header1.Caption = "Qty."
  1843. Column4.ControlSource = "orditems.unit_price"
  1844. Column4.Sparse = .F.
  1845. Column4.Header1.Caption = "Price"
  1846. Column4.Text1.InputMask = "$$9,999.99"
  1847. In addition to the text boxes and the grids, the form contains an object based on the VCR class in BUTTONS.VCX. The SkipTable property of this class is set to the table you want the record pointer to be moved in when the user chooses a table navigation button. Because the user can easily manually move through the records in the grids (Orders and Orditems), SkipTable is set to Customer.
  1848. Display Controls in a GridD
  1849. Display Controls in a Grid
  1850. File: SAMPLES\SOLUTION\CONTROLS\GRID\CONTROLS.SCX
  1851. This sample demonstrated controls displayed in grid columns.
  1852. You can add controls to a column in the 
  1853. Form Designer
  1854.  by selecting a column and adding a control or programmatically with the AddObject method.
  1855. There are a few properties that are important for displaying controls in a column:
  1856. CurrentControl Property
  1857. After you add a control to a grid column, you need to set the column
  1858. s CurrentControl property to the new control for the new control to be displayed.
  1859. Sparse Property
  1860. The check boxes on the form allow you to toggle the Sparse property of the grid columns that contain controls. When Sparse is set to .T., the control is only displayed when the focus is on a cell in the column. When Sparse is set to .F., the control is always displayed in each cell in the column.
  1861. Controls and Events
  1862. Notice that the control in the column processes the events when you are set the focus to a cell in the column. For example, if you select a cell in a column with a spinner, when you press the up and down arrows, you increment or decrement the value in the spinner. This is the default behavior for a spinner, not the default behavior for a text box in a grid cell.
  1863. For a more detailed description of adding controls to grid columns, see Chapter 10, "Using Controls," in the 
  1864. Developer's Guide
  1865. Display Different Pages Without TabsN
  1866. Display Different Pages Without Tabs
  1867. File: SAMPLES\SOLUTION\CONTROLS\PGFRAME\PFSAM2.SCX
  1868. This sample demonstrates manipulating pages without tabs in a form page. The frame in the middle of the form contains three pages that are brought to the front as the user chooses command buttons. Each page can have its own controls and appearance.
  1869. The method that brings a particular page to the front is ZOrder. For example, the following line of code in the click event of one of the command buttons brings pagCustomers to the front:
  1870. THISFORM.pgfPeople.pagCustomers.ZOrder
  1871. You can also use the ActivePage property of the page frame to determine which pages are displayed:
  1872. THISFORM.pgfPeople.ActivePage = 1
  1873. Display Line Animation on a FormJ
  1874. Display Line Animation on a Form
  1875. File: SAMPLES\SOLUTION\GRAPHICS\ANIM.SCX
  1876. This sample illustrates drawing lines on a form. More specifically, it demonstrates saving coordinates of sets of lines drawn on a form and redrawing them, along with additional lines at intermediate positions, giving the illusion of motion.
  1877. Adding lines to the table.
  1878. Each time a user draws a line on the form, its coordinates are stored in a table with the following structure:
  1879. Description
  1880. Frameno
  1881. Incremented each time the user chooses 
  1882. New Frame
  1883. Objno
  1884. Incremented each time a line is added to a frame.
  1885. The starting X coordinate for a line.
  1886. The ending X coordinate for a line.
  1887. The starting Y coordinate for a line
  1888. The ending Y coordinate for a line.
  1889. Playing the frames.
  1890. The code that plays the frames, uses the table again in another work area, selects the second work area, and goes to the next frame:
  1891. USE (lcTable) AGAIN IN 0 ALIAS shadow
  1892. SELECT shadow
  1893. LOCATE FOR frameno # &lcTable..frameno
  1894. The variable 
  1895. nBetween
  1896.  determines how many intermediate lines are drawn on the form between a line in one frame and the corresponding line in the next frame.
  1897. FOR nb = 1 TO nBetween
  1898. Inside the FOR loop, the code scans for all of the lines associated with a frame and calculates coordinates for the intermediate lines, for example:
  1899. nx1 = frames.x1 + nb * (shadow.x1 - frames.x1) / nBetween
  1900. ny1 = frames.y1 + nb * (shadow.y1 - frames.y1) / nBetween
  1901. The code then prints each intermediate line, and after a WAIT of .05 seconds clears the form and continues thek
  1902.  loop.
  1903. THISFORMSET.frmAnimation.line(nx1,ny1,nx2,ny2)
  1904. Display Multiple Columns in a List BoxP
  1905. Display Multiple Columns in a List Box
  1906. File: SAMPLES\SOLUTION\CONTROLS\LISTS\LMULCOL.SCX
  1907. This sample demonstrates displaying multiple columns in a list box. The form displayed contains a list box and a spinner. The number of columns in the list box is set to the Value property of the spinner: 1, 2, 3, or 4. 
  1908. To set the width of the columns in a multi-column list box, use the ColumnWidths property. For example, if there are 3 columns in the list box, the following command will set the column widths to 10, 15, and 20, respectively:
  1909. Form.List.ColumnWidths = "10, 15, 20"
  1910. To set the fields to be displayed in the columns, set the RowSource property. For example, the following command sets the sources of three columns in a 3-column list box to the contact, city, and country fields of the customer table.
  1911. Form.List.RowSource = "contact,city,country"
  1912. The ColumnLines property determines whether lines are displayed between the columns in the list.
  1913. Display Pictures in a ListD
  1914. Display Pictures in a List
  1915. File: SAMPLES\SOLUTION\LISTS\PICLIST.SCX
  1916. This sample illustrates how you can spice up your list boxes by adding picture graphics beside the individual text items. In this sample, you can pick any database (.DBC) file, and the list box will show different images beside the names of tables, local views and remote views.
  1917. The following code from cmdDatabase.Click enumerates through a .DBC and selectively adds pictures to list items using the Picture property. The Picture property relies on an index setting to determine which list item to affect.
  1918. FOR i = (m.nTblCount+1) TO thisform.lstDatabase.ListCount
  1919. IF DBGETPROP(ALLTRIM(thisform.lstDatabase.List[m.i]),; "view","sourcetype") = 1  
  1920. *Local view
  1921. thisform.lstDatabase.Picture[m.i] = m.cLViewBMP
  1922. * Remote view
  1923. thisform.lstDatabase.Picture[m.i] = m.cRViewBMP
  1924. ENDIF
  1925. ENDFOR
  1926.    You need to ensure that the images used are sized correctly to fit within the space of a single list box item, which differs with the FontSize of the list.
  1927. Display Pictures in an Image ControlN
  1928. Display Pictures in an Image Control
  1929. File: SAMPLES\SOLUTION\FORMS\IMAGE.SCX
  1930. This sample illustrates displaying bitmaps or icons in an image control.
  1931. The list box on the form displays files. In the InteractiveChange event of the list box, the Picture property of the image control is set to the selected file, if the file is a .BMP or .ICO.
  1932. * lstFiles.InteractiveChange
  1933. cSelected = UPPER(THIS.List(THIS.ListIndex))
  1934. CD THIS.List(2)
  1935. IF ".BMP"$cSelected OR ".ICO"$cSelected
  1936. THISFORM.imgDisplay.Picture = THIS.List(2) + cSelected
  1937. ENDIF
  1938. Display Shortcut Menus@
  1939. Display Short
  1940. cut Menus
  1941. File: SAMPLES\SOLUTION\MENUS\SHORTCUT.SCX
  1942. This sample illustrates displaying shortcut menus when a user 
  1943. right-clicks
  1944.  an object. When you have created a shortcut menu in the 
  1945. Menu Designer
  1946. , the code in the form to activate the menu is very simple. The following code is associated with the RightClick event of the form:
  1947. DO frmshort.mpr WITH THIS
  1948. The following code is associated with the RightClick event of the edit boxes on the form:
  1949. DO edtshort.mpr WITH THIS
  1950. The FRMSHORT Menu
  1951. The FRMSHORT menu was designed to take an object parameter. The following code is included in the menu
  1952. s setup code:
  1953. PARAMETER oREF
  1954. #PREPOP
  1955. #PREPOP
  1956.  generative directive causes the code in the menu
  1957. s cleanup to be generated before the ACTIVATE POPUP command. This allows you to disable or enable menu items at run time, as well as displaying check marks beside menu items.
  1958. The code associated with the menu items, sets properties of the object that was passed to the .MPR as a parameter. For example, the 
  1959. Always on top
  1960.  item sets the AlwaysOnTop property of the form.
  1961. The following code, included in the menu
  1962. s cleanup code, displays a check mark beside the 
  1963. Always on top
  1964.  item when the form
  1965. s AlwaysOnTop property is set to true (.T.).
  1966. SET MARK OF BAR 4 OF frmshort TO oRef.AlwaysOnTop
  1967. The EDTSHORT Menu
  1968. The EDTSHORT menu also accepts an object parameter in its setup code. Because there is no need to display a check mark beside the items in this menu, the #PREPOP generator directive is not used.
  1969. For an alternative way to display shortcut menus, see the 
  1970. Create Dynamic Shortcut Menus
  1971.  sample.
  1972. Display System InformationD
  1973. Display System Information
  1974. File: SAMPLES\SOLUTION\OLE\SYSINFO.SCX
  1975. This sample illustrates using the SysInfoControl to display system information and to notify when a system setting changes.
  1976. The bulk of the code in this sample is in the CheckStatus method. Code in this method checks the settings of various SysInfoControl properties to see their current settings, and populates a treeview control with this information. For example, the following section of code checks the BatteryLifePercent setting:
  1977. IF ThisForm.SysInfo.BatteryLifePercent = 255
  1978. * Add a node to display the information
  1979. ENDIF
  1980. When a system setting changes, an event of the SysInfoControl occurs. Code associated with each of these events sets the caption of a label and calls the CheckStatus method to refresh the treeview control. For example, the following code is associated with the SysColorsChanged event:
  1981. ThisForm.Status.Caption = SysColorsChanged_LOC
  1982. ThisForm.CheckStatus
  1983. Draw Lines and Shapes on a FormI
  1984. Draw Lines and Shapes on a Form
  1985. File: SAMPLES\SOLUTION\FORMS\GRAPHICS\ANIM.SCX
  1986. This sample illustrates how to use form graphics methods (PSet, Line, and Circle) and properties (DrawMode, DrawStyle, DrawWidth) to allow a user to draw figures and shapes on a form in different colors and different pen widths. 
  1987. The sample includes a toolbar (defined in FDPROC.PRG) and a form (based on frmFD in FD.VCX). The user can select settings in the toolbar that affect the graphics properties of the form. When the form is set to accept user drawing, the MousePointer is set to 2 (cross-hairs).
  1988. The drawing functionality is coded in the methods associated with the MouseDown and MouseMove events of the form:
  1989. * MouseDown
  1990. PARAMETERS nButton, nShift, nXCoord, nYCoord
  1991. IF THIS.MousePointer = 2
  1992. THIS.PSet(nXCoord, nYCoord)
  1993. ENDIF
  1994. * MouseMove
  1995. PARAMETERS nButton, nShift, nXCoord, nYCoord
  1996. IF THIS.MousePointer = 2
  1997. THISFORM.LINE(nXCoord, nYCoord)
  1998. ENDIF
  1999. Dynamically Format Grid ColumnsI
  2000. Dynamically Format Grid Columns
  2001. File: SAMPLES\SOLUTION\CONTROLS\GRID\DYNGRID.SCX
  2002. This sample illustrates setting the DynamicForeColor and DynamicBackColor properties of grid columns.
  2003. The code of interest in this sample is associated with the InteractiveChange event of the drop-down list cboFormat.
  2004. First, the code clears the dynamic fore and back color settings:
  2005. oGrd.SetAll("dynamicbackcolor", "", "Column")
  2006. oGrd.SetAll("dynamicforecolor", "", "Column")
  2007. Then, code in a CASE statement sets the new DynamicForeColor or DynamicBackColor properties. For example, the following line of code displays discontinued items with a gray ForeColor.
  2008. oGrd.SetAll("dynamicforecolor", ;
  2009.    "IIF(discontinu, RGB(192,192,192), RGB(0,0,0))", "Column")
  2010. Discontinu
  2011.  is a logical field in the Products table.
  2012. Edit a Memo Field or Text FileH
  2013. Edit a Memo Field or Text File
  2014. File: SAMPLES\SOLUTION\CONTROLS\TXT_EDT\EDITBOX.SCX
  2015. This sample enables you to view and edit text from a memo field or a text file in an edit box.
  2016. Displaying text from a memo field is as easy as setting the ControlSource of the edit box to the memo field.
  2017. There are two ways you can edit a text file in an edit box: using low-level file functions and creating a cursor to hold the text. This sample creates a cursor instead of using low-level file functions.
  2018. Editing a Text File with Low-Level File Functions.
  2019. You can open a file using FOPEN(
  2020. ), read the contents of the file using FREAD(
  2021. ), and store the contents to a memory variable or to the Value property of the edit box. You can then write changes to the file using FWRITE(
  2022. ) and close the file using FCLOSE(
  2023. Editing a Text File by Loading It into a Cursor Field
  2024. The advantage to creating a cursor for a text file, other than the fact that the code is a little simpler, is that Visual FoxPro manages writing large amounts of text in a cursor to temporary files if there isn
  2025. t enough memory.
  2026. IF SELECT("textfile") = 0
  2027. CREATE 
  2028. CURSOR textfile (filename c(60),mem m)
  2029. APPEND BLANK
  2030. ENDIF
  2031. REPLACE textfile.FileName WITH GETFILE("TXT")
  2032. IF EMPTY(textfile.FileName)
  2033. RETURN
  2034. ENDIF
  2035. SELECT textfile
  2036. APPEND MEMO mem FROM (textfile.FileName) OVERWRITE
  2037. THIS.Parent.edtText.ControlSource = "textfile.mem"
  2038. THIS.Parent.cmdSave.Enabled = .T.
  2039. THIS.Parent.lblFileName.Caption = ALLTRIM(textfile.FileName)
  2040. THIS.Parent.Refresh
  2041. Execute Commands at Specified IntervalsQ
  2042. Execute Commands at Specified Intervals
  2043. File: SAMPLES\SOLUTION\CONTROLS\TIMER\TIMECOMM.SCX
  2044. This sample form contains a text box and a spinner. Text you type in the text box is displayed in a WAIT WINDOW. You can set the spinner to the number of seconds you want to elapse between each WAIT WINDOW command.
  2045. In the InteractiveChange event of the spinner, the appropriate timer interval is set. The Interval property is 1/1000th of a second, so the interval is set to the spinner value * 1000:
  2046. THISFORM.Timer1.Interval = (THIS.Value * 1000)
  2047. In the Timer event, the 
  2048. WAIT WINDOW
  2049.  command is issued:
  2050. WAIT WINDOW ALLTRIM(THISFORM.Text1.Value) TIMEOUT 0.5
  2051. The code associated with the Timer event can include any command or procedure: code to update data, check for mail, display system resources, and so on.
  2052. Fill a List with Values from Different SourcesX
  2053. Fill a List with Values from Different Sources
  2054. File: SAMPLES\SOLUTION\CONTROLS\LISTS\MULTDAT1.SCX
  2055. This sample demonstrates setting the RowSourceType of a list box at run time to a value, an alias, a SQL statement, a query (.QPR), an array, fields in a table, files in a directory, and the structure of a table.
  2056. The combo box on the form contains all the possible RowSourceTypes of a list (except for 9 - popup, which is included for backward compatibility). The code associated with the InteractiveChange event sets the new RowSourceType and RowSource properties for the list.
  2057. When you change both the RowSourceType and RowSource of a list box at run time, you need to:
  2058. Set the RowSourceType to 0
  2059. Set the RowSource to the new source
  2060. Set the RowSourceType to the new type
  2061. If you don't follow this order, the existing RowSource and RowSourceType settings could conflict after one new value is set and before the corresponding value is set.
  2062. Format Input and Validate Data in a Text BoxV
  2063. Format Input and Validate Data in a Text Box
  2064. File: SAMPLES\SOLUTION\CONTROLS\TXT_EDIT\TEXTBOX.SCX
  2065. This sample shows how to set text box properties to make it easy for a user to enter data in the required format.
  2066. Format
  2067. Property
  2068. Setting
  2069. Allow Only Digits
  2070. InputMask
  2071. 999999999
  2072. Select On Entry
  2073. SelectOnEntry 
  2074. All Uppercase
  2075. Format
  2076. Read Only
  2077. ReadOnly
  2078. US Telephone Number
  2079. InputMask
  2080. (999) 999-9999
  2081. Password text
  2082. PasswordChar
  2083. Date Formatting
  2084. DateFormat
  2085. a number between 0 and 14
  2086. Validating Input
  2087. The following code in the Valid event of a text box prevents a user from leaving the text box if the letter 
  2088.  is in the text.
  2089. IF "a"$ THIS.Value
  2090. #DEFINE MESSAGE_LOC 
  2091. "The text box value cannot contain the letter 'a'"
  2092. MESSAGEBOX(MESSAGE_LOC,48+0+0)
  2093. RETURN 0
  2094. RETURN .T.
  2095. ENDIF
  2096. Get Application Information from the Windows Registry_
  2097. Get Application Information from the Windows Registry
  2098. File: SAMPLES\SOLUTION\WINAPI\REGFILE.SCX
  2099. This sample shows how to access the Windows registry using the native Visual FoxPro DECLARE-DLL command. The Windows API provides a number of functions you can use to access, read and write to the registry. The REGISTRY.PRG class library in \SAMPLES\CLASSES contains a complete set of these functions you can use in your applications.
  2100. In this specific sample, you can use registry functions to check for the existence of a particular application. For example, you might want to distribute an application which relies on using Excel to automate the creation of a Pivot Table. The registry contains the location, version and other information about a particular application.
  2101. Get Version InformationA
  2102. Get Version Information
  2103. File: SAMPLES\SOLUTION\WINAPI\GETVER.SCX
  2104. This sample allows you to display version information from a .DLL or .EXE.
  2105. A new function called GetFileVersion(
  2106. ) has been added to FOXTOOL.FLL which allows you to obtain version information on a file. The following code illustrates how you can call the function. See TOOLS\FOXTOOLS.HLP for details on the specific array elements.
  2107. SET LIBRARY TO FoxTools ADDITIVE
  2108. DIMENSION aFileVer[12]
  2109. nRetVal = GetFileVersion(GetFile("EXE"),@aFileVer) 
  2110. IF nRetVal = 0
  2111. DISPLAY MEMO LIKE aFileVer
  2112. ENDIF
  2113. SET LIBRARY TO
  2114.    Visual FoxPro now allows you to add File Version information to EXE and DLL files at build time. This version information is stored in a file resource and can be accessed via the Windows Explorer. EXE files created in Visual FoxPro 3.0 will not have a file version resource.
  2115. Graph Equations on a FormC
  2116. Graph Equations on a Form
  2117. File: SAMPLES\SOLUTION\FORMS\GRAPHICS\GRAPH.SCX
  2118. This sample shows how to graph equations with form graphics. The user can scale the equation by choosing the Zoom command buttons. The user can also move the graph's origin by clicking and dragging.
  2119. The graphing engines for this sample are in two programs: CGRAPH.PRG and PGRAPH
  2120. .PRG. CGRAPH graphs equations based on Cartesian coordinates. PGRAPH graphs equations based on Polar coordinates. These programs use the PSet and Line methods of a form to draw the equation.
  2121. The following code, associated with the OneGraph method of the form set, runs the CGRAPH program when a user chooses the 
  2122. Graph
  2123.  button.
  2124. THISFORMSET.frmGraph.Draw
  2125. DO cgraph WITH ;
  2126. graph.equation, ; 
  2127. graph.step, ;
  2128. graph.ecolor, ;
  2129. graph.connect, ;
  2130. THISFORMSET.nFormX, ;
  2131. THISFORMSET.nFormY, ;
  2132. .F., ;
  2133. THISFORMSET.frmgraph, ;
  2134. THISFORMSET.nFormScale
  2135. The following table lists the parameters for CGRAPH:
  2136. Parameter
  2137. Description
  2138. equation
  2139. The equation in terms of X. Will plot the answer as Y.
  2140. Step increment.
  2141. ecolor
  2142. Equation color.
  2143. connect
  2144. Whether the previous point is connected to the current point with a line.
  2145. nFormX
  2146. Point on form where x = 0
  2147. nFormY
  2148. Point on form where y = 0
  2149. lAddCoords
  2150. Whether to draw coordinate lines.
  2151. frmgraph
  2152. Name of the form to write to.
  2153. nFormScale
  2154. Scale to graph the equation at
  2155. Index on Expressions>
  2156. Index on Expressions
  2157. File: SAMPLES\SOLUTION\DB\INDEX2.SCX
  2158. This index sample shows several options you might consider when using a character field to represent a Unique ID (one often comprised of numeric data). An index tag based on a character field will sort based on the 
  2159. ASCII
  2160.  values of the data whereas a numeric expression, using the VAL(
  2161. ) function, will sort on numeric sequences. The following table shows the sort difference of two indexes.
  2162. CExpression
  2163. VAL(cExpression
  2164.    When you use the VAL(
  2165. ) function, all non-numeric values will be converted to 0.
  2166. By incorporating the BINTOC(
  2167. ) function, you can also reduce the size of  your index tags considerably.
  2168. Create Small Indexes Using BINTOC( )N
  2169. Create Small Indexes Using BINTOC(
  2170. File: SAMPLES\SOLUTION\DB\INDEX1.SCX
  2171. This sample show various indexing schemes you can use with numeric and integer data types to get significant saN
  2172. vings in index size and disk space consumed. In addition, smaller sized indexes usually result in faster searches. The new BINTOC() function allows you to convert an integer (numeric) value to a binary character representation.
  2173. Syntax
  2174. BINTOC(
  2175. nExpression
  2176. nSize
  2177. Depending on the size of  your expression, you can set the 
  2178. nSize
  2179.  parameter to accommodate the value of your expression in the least amount of characters.
  2180. The following line of code creates an index on a numeric field.
  2181. INDEX on line_no TAG line_no
  2182. The next time you are working with indexes on numeric integer data, consider using something like the following:
  2183. INDEX on BINTOC(line_no,1) TAG line_no
  2184. Interactively Build a SELECT StatementP
  2185. Interactively Build a SELECT Statement
  2186. File: SAMPLES\SOLUTION\FORMS\MAKESQL.SCX
  2187. This sample shows how to allow a user to build a custom query at run time. Combo boxes on the form allow a user to choose fields from the currently open table. The BldSQL method processes the names of the fields and the values users type into text boxes to create an executable SQL SELECT statement.
  2188. Additional methods, ValidateType and SetTextboxFormat, make sure that the appropriate values are entered into the text boxes and correctly incorporated into the SELECT statement.
  2189. After the WHERE clause has been constructed and stored to the variable lcWhere, the following command creates the SELECT statement:
  2190. lcSQL = "SELECT * FROM " + lcAlias + " " + lcWHERE
  2191. Once the SELECT statement is constructed, it can be executed with macro substitution:
  2192. &lcSQL
  2193. Manipulate Display Characteristics of a GraphW
  2194. Manipulate Display Characteristics of a Graph
  2195. File: SAMPLES\SOLUTION\OLE\OLEGRAPH.SCX
  2196. This sample shows how to incorporate MS Graph into your applications. MS Graph ships with Visual FoxPro and can also be included in your distributed applications. MS Graph 5.0 is an OLE Automation Server that Visual FoxPro can automate using the standard CREATEOBJECT(
  2197. ) function. With Visual FoxPro, Graph objects can be embedded in either bound or unbound OLE Controls. An OleBoundControl (bound to a General field) is the only way to programmatically insert data into a graph.
  2198. MS Graph
  2199. s automation support provides access only to a graph object, not its datasheet. Data can be inserted into a Graph only with the APPEND GENERAL command on a General field. The following code uses the HasLegend property and is an example of automation.
  2200. cGData = ""+TAB+"Cats"+TAB+"Dogs"+CRLF+;
  2201. "1994"+TAB+"11"+TAB+"22"+CRLF+;
  2202. "1995"+TAB+"33"+TAB+"44"+CRLF+;
  2203. "1996"+TAB+"55"+TAB+"55"+CRLF
  2204. APPEND GENERAL gen1 CLASS "msgraph.chart" DATA m.cGData
  2205. THIS.OleBoundControl1.ControlSource = "Gen1"
  2206. THIS.OleBoundControl1.HasLegend = .F.
  2207. The APPEND GENERAL command in this case creates a new chart object. If you do not include the 
  2208. CLASS 
  2209. msgraph.chart
  2210.  clause, then the chart is merely updated. The CLASS clause
  2211.  will create a new chart and override any existing formatting.
  2212. Move Items Between List BoxesG
  2213. Move Items Between List Boxes
  2214. File: SAMPLES\SOLUTION\CONTROLS\LISTS\LMOVER.SCX
  2215. This sample demonstrates moving items from one list box to another. A user can double-click one item to move it, or select one or more items and drag them, or use the appropriate command buttons to move the items between the lists.
  2216. The two list boxes and four associated command buttons are saved as a class: MoverLists in SAMPLES.VCX. The base class of MoverLists is CONTAINER. To be able to add and remove items from lists, the RowSourceType of the lists must be set to 0 - None. If you want to fill the list box with array elements or values from a table, you can use code like the following:
  2217. *array
  2218. FOR i = 1 to ALEN(myarray)
  2219. List.AddItem(myarray[i])
  2220. ENDFOR
  2221. *table
  2222. List.AddItem(table.field)
  2223. ENDSCAN
  2224. To Move Items by Double-Clicking
  2225. The following code is associated with the DblClick event of the left list box (lstSource). Similar code is associated with the DblClick event of the right list box (lstSelected).
  2226. THIS.Parent.lstSelected.AddItem(THIS.List(THIS.ListIndex))
  2227. This.RemoveItem(THIS.ListIndex)
  2228. THIS.Parent.Refresh
  2229. "THIS" refers to lstSource. "THIS.Parent" refers to the moverlists class, the container of the lists.
  2230. To Move All Items from One List to Another
  2231. The following code is associated with the Click event of cmdAddAll:
  2232.   DO WHILE THIS.PARENT.lstSource.ListCount > 0
  2233.     THIS.PARENT.lstSelected.AddItem;
  2234. (THIS.PARENT.lstSource.List(1))
  2235. THIS.PARENT.lstSource.RemoveItem(1)
  2236.   ENDDO
  2237.   THIS.PARENT.Refresh
  2238. To Move Selected Items from One List to Another
  2239. If you remove an item from a list box, the ListCount property of the list box is decremented, as is the ListIndex of all the subsequent items in the list. To move multiply-selected items, you need to use a DO WHILE loop. The following code is associated with the Click event of cmdAdd:
  2240. nCnt = 1
  2241. DO WHILE nCnt <= THIS.PARENT.lstSource.ListCount
  2242. IF THIS.PARENT.lstSource.Selected(nCnt)
  2243. THIS.PARENT.lstSelected.AddItem;
  2244. (THIS.PARENT.lstSource.List(nCnt))
  2245. THIS.PARENT.lstSource.RemoveItem(nCnt)
  2246. nCnt = nCnt + 1
  2247. ENDIF
  2248. ENDDO
  2249. THIS.PARENT.Refresh
  2250. To Drag-and-Drop Items from One List to Another
  2251. Implementing drag-and-drop between the list boxes involves code associated with the MouseDown, MouseMove, DragOver, and DragDrop events. Three user-defined properties (DragThreshold, MouseX, and MouseY) extend the usability of the class.
  2252. The MouseDown code stores the X and Y coordinates of the mouse pointer to class properties. 
  2253. *MouseDown
  2254. Parameters nButton, nShift, nXCoord, nYCoord
  2255. THIS.PARENT.MouseX = nXCoord
  2256. THIS.PARENT.MouseY = nYCoord
  2257. The MouseMove code makes sure the left mouse button in pressed before initiating the drag procedure. In addition, to guard against accidental dragging, this code checks to make sure that the user has moved the mouse a distance greater than a set
  2258.  threshold (8 pixels by default).
  2259. *MouseMove
  2260. Parameters nButton, nShift, nXCoord, nYCoord
  2261. IF nButton = 1 && Left Mouse
  2262. IF ABS(nXCoord - THIS.PARENT.MouseX) > ;
  2263. THIS.Parent.DragThreshold OR ;
  2264. ABS(nYCoord - THIS.PARENT.MouseY) > ;
  2265. THIS.Parent.DragThreshold
  2266. THIS.Drag
  2267. ENDIF
  2268. ENDIF
  2269. The DragOver code changes the DragIcon of the source when the mouse pointer enters and leaves the list box 
  2270. air space.
  2271. *DragOver
  2272. Parameters oSource, nXCoord, nYCoord, nState
  2273. DO CASE
  2274. CASE nState = 0 && Enter
  2275. oSource.DragIcon = THIS.Parent.CanDropIcon
  2276. CASE nState = 1 && Leave
  2277. oSource.DragIcon = THIS.Parent.NoDropIcon
  2278. ENDCASE
  2279. The DragDrop code makes sure that the source of the drag is not the same as the target of the drag and calls the method associated with the Click event of the cmdAdd command button (in the case of lstSelected) or cmdRemove (in the case of lstSource).
  2280. *DragDrop
  2281. Parameters oSource, nXCoord, nYCoord
  2282. IF oSource.Name != THIS.Name
  2283. THIS.PARENT.cmdAdd.Click
  2284. ENDIF
  2285. Multiselect Items in a List BoxI
  2286. Multiselect Items in a List Box
  2287. File: SAMPLES\SOLUTION\CONTROLS\LISTS\LMSEL.SCX
  2288. This sample shows how to manage multiple items selected in a list box. The form contains a list box with the MultiSelect property set to True (.T.). A combo box on the form contains all the items that are selected in the list box.
  2289. To process the multiple selected items in a list box 
  2290.  to copy them to an array or incorporate them elsewhere in your application 
  2291.  loop through the list items and process the ones for which the Selected property is set to true (.T.). The following code is included in the Click event of the list box to display the selected items in a combo box and the number of selected items in a text box:
  2292. nNoSelected = 0    && variable to track number of selected items
  2293. THISFORM.cboSelected.Clear    && clear the combo box
  2294. * main processing loop
  2295. FOR i = 1 TO THIS.ListCount
  2296. IF THIS.Selected(i)
  2297. nNoSelected = nNoSelected + 1
  2298. THISFORM.cboSelected.Additem (THIS.List(i))
  2299. ENDIF
  2300. ENDFOR
  2301. THISFORM.txtNoSelected.Value = nNoSelected
  2302. In the code associated with the Init event of this form, and in many places throughout this sample application, the character string values initially added to the list are first defined with a 
  2303. #DEFINE
  2304.  directive. Each of the defined constants ends with "_LOC". Microsoft internal localization tools extract these definitions so that the strings can be translated into whatever language the application is being localized in.
  2305. Nest Transactions;
  2306. Nest Transactions
  2307. File: SAMPLES\SOLUTION\DB\TRANS.SCX
  2308. This sample illustrates beginning, ending, and rolling back transactions. You can decide to commit or discard changes to a single table when you use table buffering, but you can decide to commit or discard changes to any number of tables when you use transactions.
  2309. Before editing either table, click the 
  2310. Begin
  2311.  button. After editing, you can click 
  2312. Begin
  2313.  again to nest another transaction, or you can click 
  2314.  to commit your edits to the table or 
  2315. Rollback
  2316.  to discard your changes.
  2317. The key commands in this example are:
  2318. BEGIN TRANSACTION
  2319. END TRANSACTION
  2320. ROLLBACK
  2321. The function that returns the current number of nested transactions is:
  2322. TXNLEVEL(
  2323. Open Multiple Files InteractivelyK
  2324. Open Multiple Files Interactively
  2325. File: SAMPLES\SOLUTION\CONTROLS\LISTS\MULTFILE.SCX
  2326. This sample shows how to populate a list with files. When you populate a list with files, built-in functionality allows a user to select new drives and directories. In this sample, a user can select one or more files in the list and open them for editing. 
  2327. The following code loops through the items in the list box and opens the selected files for editing:
  2328. FOR nFile = 5 to THISFORM.lstFiles.ListCount
  2329. IF THISFORM.lstFiles.Selected(nFile)
  2330. MODIFY FILE (THISFORM.lstFiles.List(2) + ;
  2331. THISFORM.lstFiles.List(nFile)) NOWAIT
  2332. ENDIF
  2333. ENDFOR
  2334. When the RowSourceType property is set to 7 - Files:
  2335. lstFiles.List(1) refers to the drive
  2336. lstFiles.List(2) refers to the path
  2337. lstFiles.List(3) is a separator line
  2338. lstFiles.List(4) is [..]. Click to go to the parent directory
  2339. Files can start at lstFiles.List(5)
  2340. Pass Parameters between FormsG
  2341. Pass Parameters between Forms
  2342. File: SAMPLES\SOLUTION\FORMS\PARAM.SCX
  2343. This solution illustrates passing parameters to a form and returning a value back.
  2344. PARAM Form
  2345. This form has the user enter a question and possible responses.  Then, in the Click event of the cmdAsk button, the ParamAsk form is opened by passing the Question and Possible responses.
  2346. cParam1 = THISFORM.txtPassValue1.value
  2347. nParam2 = THISFORM.opgPassValue2.value
  2348. DO FORM LOCFILE("ParamAsk.scx") WITH cParam1, nParam2 TO nRetValue
  2349. PARAMASK Form
  2350. The PARAMETERS are passed to the Init of the form where they are processed.
  2351. PARAMETERS cQuestion, nButtons
  2352. THISFORM.txtQuestion.caption = cQuestion
  2353. In the Unload event of the form, the value stored in retvalue is returned back to the calling form:
  2354. RETURN THISFORM.retValue
  2355. Play an AVI File in an ActiveX ControlP
  2356. Play an AVI File in an ActiveX Control
  2357. File: SAMPLES\SOLUTION\OLE\MMSAMPLE.SCX
  2358. The sample shows how to use the Multimedia control to play an AVI file in a control that has an hWnd property.
  2359. The control with the hWnd is a custom ActiveX control called hWin, created with the OLE control wizard in Microsoft Visual C++ 4.0. In creating the hWin .OCX, all the default options in the OLE Control wizard were chosen, all the default properties were added to the control, and the code waD
  2360. s compiled.
  2361. In the Init of the form, the following line of code directs the Multimedia control to play the AVI in the hWin control (named Test).
  2362. ThisForm.VCR.hWndDisplay = ThisForm.Test.hWnd
  2363. Play Multimedia Files Using MCI CommandsR
  2364. Play Multimedia Files Using MCI Commands
  2365. File: SAMPLES\SOLUTION\FORMS\MCI_PLAY.SCX
  2366. This sample form uses MCI (Multimedia Command Interface) to play multimedia files and can play any visual or non-visual media that is installed on your system. However, the GETFILE(
  2367. ) function prompts for the most common media files of .AVI, .WAV, .MOV, and .MID. To choose another file, select 
  2368. All Files
  2369.  and choose the desired file. 
  2370. The documentation for the MCI commands is in Chapter 7 of the Windows SDK 
  2371. Multimedia Programmer's Reference
  2372. Three Windows API functions are declared in the Init of the form:
  2373. mciSendString
  2374. mciGetErrorString
  2375. SetWindowPos
  2376. The DoMCI method of the form executes an MCI command that is passed in as a parameter.
  2377. Classes
  2378. You can open the form to see all the code necessary to run multimedia files, but the functionality has also been extracted into classes that you can easily incorporate into your own applications.
  2379. VideoFrame Class
  2380. The VideoFrame class in the Visual FoxPro SAMPLES\CLASSES\SAMPLES.VCX class library can be used to play a visual multimedia file, such as a Video for Windows file. The class allows you to position and size the video to be played, and then provides built-in methods to easily play the media file.
  2381. For an example of using this class, see VIDEO.SCX in the Visual FoxPro SAMPLES\SOLUTION\FORMS directory.
  2382. Property
  2383. Description
  2384. AutoOpen
  2385. Specifies whether the video file should automatically opened and displayed when the object is instantiated.  The default value is true (.T.).
  2386. AutoPlay
  2387. Specifies whether the video file should automatically play when it is opened.  The default value is true (.T.).
  2388. AutoRepeat
  2389. Specifies whether the video file will loop the video.  Setting this to .T. will cause the video to play continuously.  The default value is false (.F.).
  2390. ControlSource
  2391. Specifies a Field that contains the video file reference.  If empty, the class expects a static file name to be in the VideoFile property
  2392. MCIalias
  2393. Specifies the alias to be used by MCI. If left empty, the alias defaults to the Name
  2394. property of the class.  Normally this can be left empty, but if the user wants to play the same video file twice at the same time, a different alias would need to be specified for each.
  2395. VideoFile
  2396. Holds the name of a video file to play, for example  
  2397. D:\VFP\SAMPLES\SOLUTION\FORMS\FOX.AVI
  2398. Method
  2399. Description
  2400. CloseVideo
  2401. Closes the video file and releases all resources associated with it.
  2402. DoMCI
  2403. Called by the other methods to execute MCI commands.  It can also be called by a user to execute a specific MCI command.
  2404. OpenVideo
  2405. Opens the video file and shows the first frame.
  2406. PauseVideo
  2407. Pauses a playing video.  The video can be restarted by using the PlayVideo
  2408. method
  2409. PlayVideo
  2410. Plays the video file.  The video file must be opened in the OpenVideo method before it can be played.
  2411. SetPosition
  2412. Allows the user to specify the position of the media file.  It can be executed at any time after the video file has been opened.  Valid values are "Start", "End", or a specific millisecond into the video.
  2413. Sound Player Class
  2414. This class is also contained in the SAMPLES\CLASSES\SAMPLES.VCX class library. It can be used to play a non-visual multimedia file, such as a waveaudio file. The class allows you to specify the file to be played, and then provides built-in methods to easily play the media file.
  2415. Property
  2416. Description
  2417. AutoOpen
  2418. Specifies whether the sound file should be automatically opened and displayed when the object is instantiated.  The default value is true (.T.).
  2419. AutoPlay
  2420. Specifies whether the sound file should be automatically played when it is opened.  The default value is true (.T.).
  2421. AutoRepeat
  2422. Specifies whether the sound file plays continuously.  The default value is false (.F.).
  2423. ControlSource
  2424. Specifies the column that contains the sound file reference.  If empty, the class expects a static file name to be in the SoundFile property.
  2425. MCIAlias
  2426. Specifies the alias to be used by MCI. If left empty, the alias defaults to the Name
  2427. property of the class.  Normally this can be left empty, but if the user wants to play the same sound file twice at the same time, a different alias would need to be specified for each.
  2428. SoundFile
  2429. Holds the name of a sound file to play, for example  
  2430. C:\WINDOWS\CHIMES.WAV
  2431. Method
  2432. Description
  2433. OpenSound
  2434. Opens the sound file.
  2435. PlaySound
  2436. Plays the sound file. The file must be opened with the OpenSound method before it can be played.
  2437. PauseSound
  2438. Pauses the playing of a sound file. Play can be contiued by calling the PlaySound method.
  2439. SetPosition
  2440. Allows the user to specify the position of the media file.  It can be executed at any time after the file has been opened.  Valid values are "Start", "End", or a specific millisec
  2441. ond into the sound.
  2442. CloseSound
  2443. Closes the sound file and releases all resources associated with it.
  2444. Present a User with Multiple ChoicesN
  2445. Present a User with Multiple Choices
  2446. File: SAMPLES\SOLUTION\CONTROLS\BUTTONS\QUIZ.SCX
  2447. This sample illustrates using an option button group with no default selection and binding a character field to the option group.
  2448. To display an option group with no selected button, do one of the following
  2449. Set the Value property of each of the option buttons in the group to 0 of .F.
  2450. Set the Value property of the option button group to 0.
  2451. To store the caption of option buttons to a table field
  2452. Set the ControlSource of the option button group to the field.
  2453. Print a Percent of Total in a ReportN
  2454. Print a Percent of Total in a Report
  2455. File: SAMPLES\SOLUTION\REPORTS\PERCENT.FRX
  2456. The sample report, PERCENT.FRX, shows one way to calculate and display values at the beginning report before all the records from the record source have been printed. This sample report prints a percentage based on a total that is usually calculated and printed at the end of a report.
  2457. The sample report uses the tables, EMPLOYEE and ORDERS in its Data Environment. A public variable and expressions using the ORDER_AMT field are used to calculate the percentages.
  2458. To sort the data appropriately for the group defined in the report, the Order property on Cursor1 is set to the EMP_ID index.
  2459. The public variable, nTotalSales, defined in the Init event of Cursor2, stores the total for all orders. The variable is declared public to make it visible beyond the Cursor2 Init code. 
  2460. A field control in the Group Footer band calculates and displays the percentage for each employee using the following expression:
  2461. STR(INT((emp_total / nTotalSales)*100)) + " " + "%"
  2462. A field control in the Summary band calculates and displays the total percentage for all employees using the following expression. 
  2463. STR(INT((nTotalSales / nTotalSales)*100)) + " " + "%"
  2464. Print an Invoice:
  2465. Print an Invoice
  2466. File: SAMPLES\SOLUTION\REPORTS\INVOICE.FRX
  2467. This report shows an invoice report that uses a view to combine information from multiple tables, a function to collect data from the user, and a one-to-many report layout. When the report is run, the view runs first and prompts the user for a date range using a function called DATEPICK.PRG. After the user provides the dates, the view runs and selects the records to display in the report.
  2468. The Record Source
  2469.    View, INVOICE, used in this report resides in the TESTDATA database provided with the Solution project. This view combines data from four tables, CUSTOMER, ORDERS, ORDITEMS, and PRODUCTS. To filter the tables for records within a date range, the view has two filters each with a parameter, dStart_Date and dEnd_Date. 
  2470. The Data Environment
  2471.    The view is included in the data environment. To store values collected for the view and to restore the path setting, the BeforeOpenTables method of the data environment declares three public variables dStart_date, dEnd_Date, cOldPath, The first two match the parameters specified in the view. The third, cOldPath saves the current path setting so the path can be restored in the Destroy method. The path is then changed so the report is able to find the function which prompts the user for a range of dates. The final command runs the function.
  2472. The Destroy method of the data environment has public variables for the start and end dates, path setting to return the default path to what it was before the report was run, and release statements for all three of the public variables.
  2473. The DATEPICK.PRG
  2474.    This function defines and runs a form class called frmDATEPICK. The form class includes four comboboxes that display and collect values to use in the public variables, dStart_Date and dEnd_Date. The four variables collected are nFromMonth, nFromYear, nToMonth, and nToYear. These variables store the user input and are used to determine the value of dStart_Date and dEnd_Date. The function also checks to make sure the user entered values for each element of the date and verifies that the end date is after the start date.
  2475. The Report Layout
  2476.    In the report layout, a Group Header band holds the controls for the customer information, the Detail band has the controls for the order items, and the Group Footer band holds the controls that display the calculated values for the invoice.
  2477. To format the address appropriately, an expression in the control concatenates several fields with appropriate punctuation. To calculate values in the Group Footer band, two report variables, nSubtotal and nDiscount, store values for the subtotal and the percentage discount. 
  2478. Print Customer Mailing LabelsG
  2479. Print Customer Mailing Labels
  2480. File: SAMPLES\SOLUTION\REPORTS\CUST.LBX
  2481. This example illustrates printing mailing labels, one for each customer in the customer table.
  2482. The labels include 4 items: 
  2483. Company
  2484. Contact + 
  2485.  + Title 
  2486. Address
  2487. City + 
  2488.  + Region+ 
  2489.  + Country
  2490. The logo is displayed on each label by using the OLE container control.
  2491. Print Data Dictionary InformationK
  2492. Print Data Dictionary Information
  2493. File: SAMPLES\SOLUTION\REPORTS\DBCTOFRX.SCX
  2494. This sample illustrates a simple way to generate a report with the contents of a Visual FoxPro database (DBC). Simply pick a DBC file when prompted and a report will be generated for you to preview. You can click on the Print button to generate a hard copy of it.
  2495. The sample creates a temporary cursor and inserts new records as the DBC is scanned. Table and view records are added along with their associated field and index information.
  2496. Print Product Orders By QuarterI
  2497. Print Product Orders By Quarter
  2498. File: SAMPLES\SOLUTION\REPORTS\ORDGRAPH.SCX
  2499. This sample illustrates generating and printing graphs on-the-fly. Visual FoxPro allows you add graphs to forms as either OleControls or OleBoundControls. The latter representing a g!
  2500. raph which is bound to data via a General field. 
  2501. If you intend to use the VFP report writer to print graphs, you need to use General fields to store the graphs. The easiest way to create a new graph in a General field is to use the APPEND GENERAL command, for example:
  2502. APPEND GENERAL graphfield CLASS 
  2503. msgraph
  2504. The example above will create a graph in a General field, however, it won
  2505. t contain your data. The DATA clause actually passes data to the graph.
  2506. The following code loops through records already containing data and constructs a string to pass to the graph with APPEND GENERAL .... DATA.
  2507. SCAN NEXT m.totrecs
  2508. m.cData = ""+TAB+m.f2+TAB+m.f3+TAB+m.f4+CRLF+;
  2509. EVAL(fields(1))+ TAB + ;
  2510. ALLTRIM(STR(EVAL(field(2))))+ TAB +;
  2511. ALLTRIM(STR(EVAL(field(3))))+ TAB + ;
  2512. ALLTRIM(STR(EVAL(field(4))))
  2513. m.cDetails = ;
  2514. f2+"-" +ALLTRIM(STR(EVAL(FIELD(2)))) ;
  2515. + CRLF + f3+"-" +ALLTRIM(STR(EVAL(FIELD(3)))) ;
  2516. + CRLF + f4+" - "+ALLTRIM(STR(EVAL(FIELD(4)))) +CRLF
  2517. INSERT INTO prodsales ;
  2518. VALUES(SalesData.prod_name,tmpgrph.graph,m.cDetails)
  2519. APPEND GENERAL prodsales.sales DATA m.cData
  2520. ENDSCAN
  2521. Once you have a table or cursor containing a General field with your graphs, you can then print it to a Visual FoxPro report using the REPORT FORM command. You cannot include an ActiveX control in a report.
  2522. Print in Catalog FormatA
  2523. Print in Catalog Format
  2524. File: SAMPLES\SOLUTION\REPORTS\WRAPPING.FRX
  2525. The sample report, WRAPPING.FRX, prints an employee directory and shows how you can wrap text around graphics, alternate the print position of controls, and float controls below fields that stretch. The data environment for this report contains the EMPLOYEE table from the TESTDATA.DBC in the Solution project. 
  2526. The Report Layout
  2527. The Title band holds the name and description of the report. The Detail band holds the field and label controls that print for each record. For each record the report displays four categories of information. 
  2528. Employee name and title
  2529. Biography 
  2530. Box of quick reference information such as phone and address
  2531. Photograph
  2532. After printing the name and title, this report wraps the text of the biography around the photograph, alternates information from left to right, and floats the box down the page relative to the biography.
  2533. Wrap Text Around Graphics
  2534. To wrap the memo field around the picture, the report uses two field controls to display the contents of the memo field. The first control is above the picture to display two lines of text. The second field is also sized to show two lines of text, but is narrower and positioned next to the picture.
  2535. The first field control prints all of the words in the memo field up to the position where a break should occur to continue the words in the second control. The expression is shown below.
  2536. LEFTC(employee.notes,nWrapCharPos)
  2537. The second field control prints the remaining words from the memo field. The expression for the second field control is shown below.
  2538. LTRIM(RIGHTC(employee.notes,(nMemoLen-(nWrapCharPos))))
  2539. The expressions for the controls use report variables to determine the words the controls display from the memo field.
  2540. nFirstMemoLen determines the number of characters that can be displayed in the first field without truncating. For this report, the variables value is always 185. If you use this in your own report, you will need to change this constant to match the maximum number of characters you want above the picture.
  2541. nMemoLen determines the length of the memo field for the current record. This variable's expression is LENC
  2542. (employee.notes)
  2543. nSpace determines the character position of the first space after the characters displayed in the first control. This variable's expression is 
  2544. AT_C(CHR(32),RIGHTC(employee.notes,(nMemoLen - nFirstMemoLen))).
  2545. nWrapCharPos determines the character position within the memo field where the break should occur. This variable's expression is 
  2546. nSpace + nFirstMemoLen
  2547. Alternate the Position of Printed Objects
  2548. In this report, the positions of the employee biography, the quick reference group, and the photograph alternate from left to right with each record. To alternate the positions, the report has two sets of controls for the parts of the report that alternate. Because two controls are used to wrap the biography text, the first control does not alternate and, therefore, does not need to be included in the two sets. 
  2549. One set of controls specifies printing with the photograph on the left side. A second set specifies the printing for the photograph on the right side. The controls in both sets use a report variable, nCounter, that calculates a count which determines when the set should print. One set prints when nCounter's value is 0; the other when the value is 1. The Print When expression for the first set of controls is 
  2550. MOD(nCounter,2) = 0
  2551. . For the second set, the expression is 
  2552. MOD(nCounter,2) = 1
  2553. Float Controls Below Controls that Stretch
  2554. This report prints the box of information prints below the biography. Since the length of the biography varies with each record, the control that displays the biography information next to the picture is set to stretch and uses only the space necessary to print the contents of the field. The box that prints below the biography floats down the page depending on the length of the biography. This box is a group of field, label, and rectangle controls. To prevent the biography from printing on top of the group, the field position for each of the controls in the group is set to float.
  2555. Print Report Details in a Ledger StyleP
  2556. Print Report Details in a Ledger Style
  2557. File: SAMPLES\SOLUTION\REPORTS\LEDGER.FRX
  2558. The report , LEDGER.FRX, prints an employee phone list that alternates printing a gray background behind records. The data environment for this report contains the EMPLOYEE table from the TESTDATA.DBC in the Solution project.
  2559. In the report layout, the Page Header band has label controls that print the report title, description, and column headings. The Detail band has the field and label controls that print the information for each employee.
  2560. To print with ledger style, the controls for the employee information are on top of a rectangle. The rectangle's color is gray and it's mode is opaque. The report prints the rectangle for every other record by evaluating an expression in the Print When opti
  2561. ons of the rectangle control. The expression is MOD(nCounter,2) = 1 which uses a report variable, nCounter that increments for each record printed. The report uses the value of this variable to determine when to print the rectangle.
  2562. Programmatically Check Table PropertiesQ
  2563. Programmatically Check Table Properties
  2564. File: SAMPLES\SOLUTION\DB\INFO.SCX
  2565. This sample illustrates getting information about a table at run time.
  2566. Field Information
  2567. The AFIELDS(
  2568. ) function provides most of the information about table fields displayed in this sample. In addition to the information displayed in this sample, AFIELDS(
  2569. ) provides information about field and table validation expressions and messages, trigger expressions and messages, as well as long table name and table comment in the database. 
  2570. Index Information
  2571. The TAG(
  2572. ) and KEY(
  2573. ) functions provide index information:
  2574. lo = THISFORM.edtProperties
  2575. FOR i = 1 TO 254
  2576. IF !EMPTY(TAG(i))  && Checks for tags in the index
  2577. lo.Value = lo.Value + TAG(i) + 
  2578.  + KEY(i)
  2579. EXIT 
  2580. ENDIF
  2581. ENDFOR
  2582. Programmatically Manipulate ObjectsM
  2583. Programmatically Manipulate Objects
  2584. File: SAMPLES\SOLUTION\FORMS\OBJECTS.SCX
  2585. This sample shows how to set properties at run time for objects in a form set. The sample form set contains two forms. Code associated with the Click event of controls on both forms change the property settings of other controls.
  2586. When setting properties of controls at run time, remember to reference the control through its container hierarchy. For example, to set the Value property of a control on one form from code in a method of another form, reference the highest-level container (the form set), and all subsequent containers.
  2587. THISFORMSET.frmLeft.chkBold.Value = .F.
  2588. For a more detailed description of this sample, see Chapter 9, "Creating Forms," in the 
  2589. Developer's Guide
  2590. Programmatically Manipulate TextJ
  2591. Programmatically Manipulate Text
  2592. File: SAMPLES\SOLUTION\CONTROLS\TXT_EDT\TEXT.TXT
  2593. This sample illustrates using the SelStart, SelLength, and SelText properties of an edit box to manipulate the text at run time. The sample also counts the characters, words, and paragraphs in a text file and allows a user to search for a string in a text file.
  2594. Formatting Text
  2595. The following code is included in the Click event of the button that formats selected text to uppercase:
  2596. lo = THIS.Parent.edtText
  2597. lnOldStart = lo.SelStart
  2598. lnOldLength = lo.SelLength
  2599. lo.SelText = UPPER(lo.SelText)
  2600. lo.SelStart = lnOldStart
  2601. lo.SelLength = lnOldLength
  2602. If you want to specify the font attributes of selected sections of text, use a RichText control.
  2603. Searching for Text
  2604. After getting the text to search for, the following code loops through all the text in the edit box, comparing it to tha
  2605. e target string.
  2606. llKeepLooking = .T.
  2607. DO WHILE llKeepLooking
  2608.   FOR i = lnStart TO LEN(loEDT.Value)
  2609.     loEDT.SelStart = i
  2610.      loEDT.SelLength = lnLen
  2611.     IF loEDT.SelText = ALLTRIM(loCBO.Text) OR ;
  2612.          (!llCaseSensitive AND ;
  2613.          (UPPER(loEDT.SelText) = UPPER(ALLTRIM(loCBO.Text))))
  2614.       llFound = .T.
  2615.       llKeepLooking = .F.
  2616.       EXIT
  2617.     ENDIF
  2618.   ENDFOR
  2619.   IF !llFound
  2620.     lnChoice=MESSAGEBOX("Search string not found.", ;
  2621.         64+0+4)
  2622.     IF lnChoice = 6 && Yes
  2623.       llKeepLooking = .T.
  2624.       lnStart = 0
  2625.     ELSE
  2626.       llKeepLooking = .F.
  2627.     ENDIF
  2628.   ENDIF
  2629. ENDDO
  2630.    Be sure to set the form
  2631. s LockScreen property to true (.T.) before searching and false (.F.) after searching. Otherwise, the form will repaint every time the SelStart property of the edit box is changed.
  2632. Provide a Hierarchical Display of ItemsQ
  2633. Provide a Hierarchical Display of Items
  2634. File: SAMPLES\SOLUTION\OLE\OUTLINE.SCX
  2635. This sample shows two different types of ActiveX controls which you can use for outlining. In this sample, a directory structure is displayed. A custom method on the form named FillTree is called recursively to iterate through the entire tree structure. 
  2636. The Outline control can be used for simple outlining, however, it does not offer the Windows 95 shell look available with the Treeview control. In addition, the Treeview control also allows display of images with each node.
  2637. Outline Control
  2638. You can add items to the outline control with the AddItem method. Indentation is handled through the Indent method which takes an index number representing the item to affect.
  2639. THIS.PageFrame1.Page1.OleOutline.AddItem(LOWER(m.path))
  2640. THIS.PageFrame1.Page1.OleOutline.Indent(m.cnt-1)= m.lvl
  2641. Treeview Control
  2642. The new Treeview control can give your applications a truly genuine Windows 95 look. Unlike the Outline control which uses methods and item indexes, the Treeview control uses a Nodes collection.
  2643.    To display images in a treeview control, you must add an ImageList control to the form.
  2644. * Add items to treeview control
  2645. o = THIS.PageFrame1.Page2.oleTreeview
  2646. IF cnt = 1
  2647. oNode = o.nodes.add(,1,LOWER(m.path)+"_",LOWER(m.path),,)
  2648. oNode.Image = "world"
  2649. &&name of image
  2650. oNode = o.nodes.add(m.pkey,4,LOWER(m.path)+"_",LOWER(m.path),,)
  2651. oNode.Image = "fldr"
  2652. &&name of image
  2653. ENDIF
  2654. Provide What's This Help on a FormL
  2655. Provide What's This Help on a Form
  2656. File: SAMPLES\SOLUTION\FORMS\WHATTHIS\WHATTHIS.SCX
  2657. When you provide What
  2658. s This Help on a form, a button with a question mark is displayed in the upper right corner of the form.
  2659. When a user clicks this button or presses SHIFT+ F1, the form is set to WhatsThis mode. You can also programmatically enter this state by calling the WhatsThisMode method of the form. When the form is in WhatsThis mode, the mouse pointer changes. A user can click a control and get context-sensitive help
  2660.  for that control in a popup window.
  2661.    If the WhatsThisHelpID of a control or a form is set to -1 (the default), the text in the popup window indicates that no help topic is available for the control.
  2662. To provide What
  2663. s This Help
  2664. Create a Help file with a topic for each control on the form.
  2665. In the Map section of the Help project, map HelpContextID values to the topics.
  2666. Set the WhatsThisHelp property of the form to true (.T.).
  2667. Set the WhatsThisButton property of the form to true (.T.).
  2668. Set the WhatsThisHelpID of the controls to the appropriate helpcontextID values.
  2669. In the Load or Init of the form, use the SET HELP TO command to specify the help file for the form.
  2670. In addition to WHATTHIS.SCX, this sample includes the following files:
  2671. Description
  2672. WHATTHIS.HLP
  2673. The Help file for the form
  2674. WHATTHIS.HPJ
  2675. The Help project file
  2676. WHATTHIS.RTF
  2677. The source document for the Help file
  2678. Read and Write VFP Registry ValuesV
  2679. Read and Write Visual FoxPro Registry Values
  2680. File: SAMPLES\SOLUTION\WINAPI\REGFOX.SCX
  2681. This example shows how to access the Windows Registry using the native Visual FoxPro DECLARE-DLL command. The Windows API provides a number of functions you can use to access, read and write to the registry. The REGISTRY.PRG class library in \SAMPLES\CLASSES contains a class definition that exposes these functions as methods that you can call in your applications.
  2682. The contents of the Visual FoxPro Options dialog, Field Mapping settings and Label definitions (to name a few) are stored in the Registry. Since many of these settings are not available via SET functions, you can use Registry functions to access these values. The following code populates an array of all the settings in the Options dialog. 
  2683. regfile = HOME()+"samples\classes\registry.prg"
  2684. SET PROCEDURE TO (m.regfile) ADDITIVE
  2685. oReg = CreateObject("FoxReg")
  2686. DIMENSION aFoxOptions[1,2]
  2687. m.nErrNum = oReg.EnumFoxOptions(@aFoxOptions)  
  2688. The following code calls the SetFoxOption method of the FoxReg class (defined in REGISTRY.PRG) to set TALK OFF in the registry.
  2689. regfile = HOME()+"samples\classes\registry.prg"
  2690. SET PROCEDURE TO (m.regfile) ADDITIVE
  2691. oReg = CreateObject("FoxReg")
  2692. m.nErrNum = oReg.SetFoxOption("TALK","OFF")
  2693. Read ODBC Registry ValuesC
  2694. Read ODBC Registry Values
  2695. File: SAMPLES\SOLUTION\WINAPI\REGODBC.SCX
  2696. This example shows how to access the Windows Registry using the native Visual FoxPro DECLARE-DLL command. The Windows API provides a number of functions you can use to access, read and write to the registry. The REGISTRY.PRG class library in \SAMPLES\CLASSES contains a class definition that exposes these functions as methods that you can call in your applications.
  2697. The Registry contains a PN    
  2698. listing of all installed ODBC drivers and data sources. If your application relies on using ODBC, then you might want to perform a Registry check to see if a particular driver or data source is installed. This example shows how to query for ODBC information.
  2699. LOCAL oReg,regfile,nErrNum,lDrivers
  2700. PUBLIC aODBCData
  2701. regfile = HOME()+"samples\classes\registry.prg"
  2702. SET PROCEDURE TO (m.regfile) ADDITIVE
  2703. oReg = CreateObject("ODBCReg")
  2704. DIMENSION aODBCData[1]
  2705. m.nErrNum = oReg.GetODBCDrvrs(@aODBCData)
  2706. Refresh a Graph in a FormC
  2707. Refresh a Graph in a Form
  2708. File: SAMPLES\SOLUTION\OLE\STOCK.SCX
  2709. This sample illustrates selecting data from a table and passing it to MS Graph to refresh the values in a chart. Most of the code to do this is associated with the InteractiveChange event of the cboMonth combo box:
  2710. Select the data into a cursor
  2711. SELECT date, close;
  2712.   FROM Stock1 WHERE MONTH(date) = THIS.Value ;
  2713.   ORDER BY date INTO CURSOR wtemp
  2714. Create a character string containing the selected data
  2715. SELECT wtemp
  2716. lcData = " " + TAB + "Closing Price" + CRLF
  2717.  lcData = lcData + DTOC(date)
  2718.  lcData = lcData + TAB
  2719.  lcData = lcData + ALLTRIM(STR(close)) + CRLF
  2720. ENDSCAN
  2721. Send the character string to MS Graph
  2722. SELECT Graph
  2723. APPEND GENERAL msgraph DATA lcData
  2724. Resize and Reposition Controls at Run TimeT
  2725. Resize and Reposition Controls at Run Time
  2726. File: SAMPLES\SOLUTION\FORMS\CRESIZE.SCX
  2727. A user can resize this sample form as desired. The controls on the form are resized or repositioned relative to the new Height and Width properties of the form.
  2728. This form uses the resizable class in SAMPLES\CLASSES\SAMPLES.VCX to manage resizing and repositioning of the controls. The following line of code is added to the Resize event of the form, calling the AdjustControls method of the resizable class:
  2729. THIS.Resizable2.AdjustControls
  2730. In the Init of the resizable class, code loops through all the controls in the form, storing their positions and sizes relative to the form in an array. When the form is resized, the AdjustControls method resizes and repositions the controls to their relative sizes and positions.
  2731. You can add more controls to the form and the new controls will also be resized and repositioned.
  2732. The RepositionList and ResizeList properties contain a space-delimited list of all the classes that you want to reposition and resize. If you don
  2733. t want a certain class to be resized, remove it from the ResizeList.
  2734. You can prevent a user from making the form too small for the objects contained on it by setting the form's MinHeight and MinWidth properties.
  2735. Return a Value from a FormD
  2736. Return a Value from a Form
  2737. File: SAMPLES\SOLUTION\FORMS\LOGFORM.SCX
  2738. This sample illustrates returning a value from a login form. The launching form (LOGFORM.SCX) uses the DO Fm
  2739. ORM command to run the login form and store the return value to a variable (cUser).
  2740. DO FORM
  2741.  Login 
  2742.  cUser
  2743.    To return a value from a form, the WindowType property of the form must be set to 1 - Modal.
  2744. The login form (LOGIN.SCX) allows a user to enter a user name and a password. Code associated with the Click event of cmdOK checks to make sure that the correct password was entered:
  2745. LOCATE FOR UPPER(login.userid) = UPPER(ALLTRIM(THISFORM.txtUserName.Value))
  2746. IF FOUND() AND ALLTRIM(password) == ALLTRIM(THISFORM.txtPassword.Value)
  2747. THISFORM.cUser = ALLTRIM(login.userid)
  2748. THISFORM.Release
  2749. #DEFINE MISMATCH_LOC "The user name or password is incorrect. Please try again."
  2750. WAIT WINDOW MISMATCH_LOC TIMEOUT 1.5
  2751. THISFORM.txtUserName.Value = ""
  2752. THISFORM.txtPassword.Value = ""
  2753. THISFORM.txtUserName.SetFocus
  2754. ENDIF
  2755. Code associated with the Unload event of the login form returns the name of the user, if the user entered the correct password, or an empty string:
  2756. RETURN THIS.cUser
  2757. Run Multiple Instances of a FormJ
  2758. Run Multiple Instances of a Form
  2759. File: SAMPLES\SOLUTION\FORMS\LAUNCH.SCX
  2760. This sample demonstrates running multiple instances of a form. 
  2761. aForms
  2762.  is an array property of the form that launches the multiple instances. The following code is associated with the Click event of the command button that launches multiple forms:
  2763. Get the number of the last element in the array
  2764. nInstance = ALEN(THISFORM.aForms)
  2765. Determine the Top and Left Properties to cascade the new forms. These settings are passed as parameters when the form instances are launched.
  2766. IF nInstance > 1 AND ;
  2767. TYPE('THISFORM.aForms[nInstance -1]') = 'O'
  2768. nFormTop = THISFORM.aForms[nInstance -1].Top + 1
  2769. nFormLeft = THISFORM.aForms[nInstance -1].Left + 1
  2770. nFormTop = 1
  2771. nFormLeft = 1
  2772. ENDIF
  2773. Set the caption to reflect the instance number
  2774. cFormCaption = "Instance" + ALLTRIM(STR(nInstance))
  2775. Run the form and assign the object variable to the array element. The Linked keyword indicates that all instances will be released when the array is released. Without 
  2776. LINKED
  2777. , the multiple instance forms would persist after the array is released.
  2778. DO FORM Multi NAME THISFORM.aForms[nInstance] WITH ;
  2779. nFormTop, nFormLeft, cFormCaption LINKED
  2780. Redimension the array so that more instances of the form can be launched.
  2781. DIMENSION THISFORM.aForms[nInstance + 1]
  2782. See Check Box Design OptionsF
  2783. See Check Box Design Options
  2784. File: SAMPLES\SOLUTION\CONTROLS\CHECKBOX\CHECKBOX.SCX
  2785. This sample illustrates a variety of properties that can be set to customize ch
  2786. eck box display.
  2787. Property
  2788. Description
  2789. ControlSource
  2790. A variable or table field that is numeric or logical
  2791. Picture
  2792. Bitmap displayed if Style is Graphical
  2793. Style
  2794. Graphical for pictures or standard for a box
  2795. Value
  2796. .T., .F., 0, 1, 2, or .NULL.
  2797. See Command Button Design OptionsK
  2798. See Command Button Design Options
  2799. File: SAMPLES\SOLUTION\CONTROLS\BUTTONS\CMDBTN.SCX
  2800. This sample illustrates a variety of properties that can be set to customize command button display.
  2801. Property
  2802. Description
  2803. Cancel
  2804. The Click event code of the command button with Cancel set to true (.T.) is executed when a user presses ESC.
  2805. Default
  2806. The Click event code of the command button with Default set to true (.T.) is executed when a user presses ENTER
  2807. Picture
  2808. Bitmap displayed if Style is Graphical
  2809. Select Customers in a Specific CountryP
  2810. Select Customers in a Specific Country
  2811. File: SAMPLES\SOLUTION\DATA\TESTDATA.DBC
  2812. This sample illustrates using a parameterized view (
  2813. customers in specific country
  2814.  in the testdata database) to display a subset of records that match a variable set at run time.
  2815. To create a parameterized view in the View Designer, enter a variable prefixed with a question mark (?) in the 
  2816. Example
  2817.  box of the 
  2818. Filter
  2819.  tab.
  2820. If the variable doesn
  2821. t exist at run time, the user is prompted to enter a value for the variable, 
  2822. whichcountry
  2823.  in this example. If the variable already exists, the view displays matching records without prompting for a new value.
  2824. Select Records from a Full Outer JoinO
  2825. Select Records from a Full Outer Join
  2826. File: SAMPLES\DATAT\FOUTERJ.QPR
  2827. The query, FOUTERJ, in the Solution project combines information from the country table and the customer table using a full outer join. Each result record has a field for each of the fields from the country table, and the 
  2828. country
  2829.  and 
  2830. cust_id
  2831.  field for the field from the customer table as specified in the SELECT clause of the SELECT-SQL statement.
  2832. SELECT
  2833.  Country.*, Customer.country, Customer.cust_id;
  2834.  testdata!customer 
  2835. FULL JOIN
  2836.  country ;
  2837.  Customer.country = Country.country
  2838. Typically, a full outer join answers three questions about the records in your database. Some of the questions this query could answer are
  2839. Which customers are in which countries?
  2840. Which countries do not have any of our customers in them?
  2841. Which customer records are missing country information?
  2842. This information might help someone decide if they should expand their business to other countries, change their marketing strategy in some countries, or simply that some records in the database need the country information updated.
  2843. The full outer join returns all records from both tables and combines records that match the join condition. The result set includes three subsets of records.
  2844. Records matching the join condition that combine information from a record in each table. 
  2845. Records from the country table that do not match the join condition. 
  2846. Records from the customers table that do not match the join condition. 
  2847. Because each record in the results has the same fields, the records that did not have a match in the other table have NULL values in the fields that would otherwise hold values the other table. For example, if a record for the country, Russia, did not have any related customer records in the customer table, that record appears in the results with NULL as the value of the field, 
  2848. cust_id
  2849.  and 
  2850. country_b
  2851. NULL values appear in fields for non-matching records.
  2852. You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.
  2853. Select Records from a Left Outer JoinO
  2854. Select Records from a Left Outer Join
  2855. File: SAMPLES\DATA\LOUTERJ.QPR
  2856. The query, LOUTERJ, in the Solution project combines information from the orders table and the customer table using a left outer join. Each result record has a fields for the 
  2857. order_id
  2858.  from the orders table and for the 
  2859. cust_id
  2860. company
  2861. country
  2862.  fields from the customer table as specified in the SELECT clause of the SELECT-SQL statement.
  2863. SELECT
  2864.  Customer.cust_id, Customer.company, Customer.country,;
  2865.  Orders.order_id;
  2866.  testdata!orders 
  2867. LEFT OUTER JOIN
  2868.  testdata!customer ;
  2869.  Orders.cust_id = Customer.cust_id
  2870. Typically, a left outer join can answer two questions about the records in your database. Some of the questions this query could answer are:
  2871. Which orders belong to which customers?
  2872. Which orders do not have related customer information?
  2873. This information helps the database administrator determine which order records are missing information.
  2874. The left outer join returns all records from the table on the left of the join condition combined with the records from the table on the right of the condition that match the condition. The results set includes two subsets of records. 
  2875. Records matching the join condition that combine information from a record in each table. 
  2876. Records from the orders table that do not match the join condition. 
  2877. Because each record in the results has the same fields, the records with an
  2878.  order_id
  2879.  that did not have a match in the customer table have NULL values in the fields that would otherwise hold values from the customer table. For example, if the record for order 11079, did not have any related customer records in the customer table, that record appears in the results with the value NULL in the fields,.N
  2880. cust_id
  2881. company
  2882. , and 
  2883. country
  2884. The order for 11079 does not have a match any record in the Customer table
  2885. You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.
  2886. Select Records from a Nested JoinK
  2887. Select Records from a Nested Join
  2888. File: SAMPLES\DATA\NESTED.QPR
  2889. The query, 
  2890. NESTED
  2891. , in the Solution project combines information from the customer, orders, and orditems tables using two inner join conditions. One join condition is between customer and orders; the other between orders and orditems. Each result record has fields for the 
  2892. cust_id
  2893.  and 
  2894. company
  2895.  from the customers table, 
  2896. order_id
  2897.  from the orders table, and 
  2898. line_no
  2899.  from the orditems table as specified in the SELECT clause of the SELECT-SQL statement.
  2900. SELECT
  2901.  Customer.cust_id, Customer.company, Orders.order_id, Orditems.line_no;
  2902.  testdata!customer 
  2903. INNER JOIN
  2904.  testdata!orders;
  2905. INNER JOIN
  2906.  testdata!orditems ;
  2907.  Orders.order_id = Orditems.order_id ;
  2908.  Customer.cust_id = Orders.cust_id
  2909. The order in which the tables are joined determines the order the join conditions are evaluated. In this query, the join between orders and orditems is evaluated first and produces a subset of records that meets the join condition. This subset of records is matched to the records in the customer table and produces the final results set.
  2910. You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.
  2911. Select Records from a Right Outer JoinP
  2912. Select Records from a Right Outer Join
  2913. File: SAMPLES\DATA\ROUTERJ.QPR
  2914. The query, ROUTERJ, in the Solution project uses the testdata database, and combines information from the orders table and the employee table using a right outer join. Each result record has a field for the 
  2915. order_id
  2916.  from the orders table and for the 
  2917. lastname
  2918.  field from the employee table.
  2919. SELECT
  2920.  Orders.order_id, Employee.last_name;
  2921.  testdata!employee 
  2922. RIGHT OUTER JOIN
  2923.  testdata!orders ;
  2924.  Employee.emp_id = Orders.emp_id
  2925. Typically, a right outer join can answer two questions about the records in your database. Some of the questions this query could answer are
  2926. Which orders were entered by which employees?
  2927. Which orders do not have an employee specified?
  2928. This information may help track specific orders and identify orders that do not have an employee specified as placing the order.
  2929. The right outer join retrieves all records from the table on the right of the join condition combined with the records from the table on the left that match the join condition. The results set includes two subsets of records. 
  2930. Records matching the join condition that combine information from a record in each table. 
  2931. Records from the orders table that do not match the join condition. 
  2932. Because each record in the results has the same fields, the records with a 
  2933. lastname 
  2934. that did not have a match in Y
  2935. the orders table have NULL values in the field that would otherwise hold values from the orders table. For example, if a record for order number 11078 did not have any related employee records in the employee table, that record appears in the results with the value NULL in the field, 
  2936. lastname
  2937. The record for order 11078 without a matching record in the EMPLOYEE table.
  2938. You can change the results of the query by specifying filters, sort order, group, or other miscellaneous options for the query.
  2939. Select Records from an Inner JoinK
  2940. Select Records from an Inner Join
  2941. File: SAMPLES\DATA\INNERJ.OPR
  2942. The query, INNERJ, in the Solution project uses the database, TESTDATA, and combines information from the tables, ORDERS and CUSTOMER using an inner join condition. Each result record has fields for the CUST_ID, COMPANY, and COUNTRY from the CUSTOMERS table, and ORDER_ID from the ORDERS table as specified in the SELECT clause of the SELECT-SQL statement.
  2943. SELECT
  2944.  Customer.cust_id, Customer.company, Customer.country,;
  2945.  Orders.order_id;
  2946.  testdata!orders 
  2947. INNER JOIN
  2948.  testdata!customer ;
  2949.  Orders.cust_id = Customer.cust_id
  2950. This query retrieves and combines the records between the two tables that match the join condition. The condition specifies that the records must have the same value in the 
  2951. cust_id
  2952.  field.
  2953. The inner join returns only records that match the join condition.
  2954. An inner join typically answers one basic question. In this query, the question is what orders did each customers place? If a customer has a record in the database but has not placed an order, the record does not appear in the results because it is not part of the subset that matches the join condition.
  2955. You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.
  2956. Select Records from Both Inner and Outer JoinsX
  2957. Select Records from Both Inner and Outer Joins
  2958. File: SAMPLES\DATA\COMBOJ.QPR
  2959. The query, COMBOJ, uses the testdata database, and combines information from the tables, customer, orders, and orditems. Each result record has fields for the 
  2960. company
  2961.  from the customer table, the 
  2962. order_date
  2963.  from the orders table, and the 
  2964. line_no
  2965.  from the orditems table as specified in the SELECT clause of the SELECT-SQL statement.
  2966. SELECT
  2967.  Customer.company, Orders.order_id, Orditems.line_no;
  2968.  testdata!customer 
  2969. LEFT OUTER JOIN 
  2970. testdata!orders;
  2971. INNER JOIN
  2972.  testdata!orditems ;
  2973.  Orders.order_id = Orditems.order_id ;
  2974.  Customer.cust_id = Orders.cust_id
  2975. The order the tables are joined determines the order the join conditions are evaluated. In this query, the join between orders and orditems is evaluated first and produces a subset of records that meets the join condition. Because of the inner join, the subset of records has only records from both table that match the condition. This subset of records is matched to the records in the customer table. Because of the outer join between customer and orders, any customers not having orders also appear in the results and have the value NULL.
  2976. stomers without orders are included in the results.
  2977. You can change the results of the query by specifying filters, a sort order, group, or other miscellaneous options for the query.
  2978. Select the Ten Worst Selling ProductsO
  2979. Select the Ten Worst Selling Products
  2980. File: SAMPLES\DATA\WORSTTEN.QPR
  2981. This query displays the worst ten selling products based on sales recorded in the Order Items table. The query uses the TOP 
  2982.  feature of the SELECT statement, and, because the default order is from smallest to largest, ordering by the sum of price and quantity returns the 10 lowest values.
  2983. SELECT TOP 10
  2984.  Products.prod_name,;
  2985. (Orditems.unit_price*Orditems.quantity);
  2986.  testdata!products 
  2987. INNER JOIN
  2988.  testdata!orditems ;
  2989.  Products.product_id = Orditems.product_id;
  2990. GROUP BY
  2991.  Products.prod_name;
  2992. ORDER BY
  2993. Select the Top Ten Best Selling ProductsR
  2994. Select the Top Ten Best Selling Products
  2995. File: SAMPLES\DATA\TOPTEN.QPR
  2996. This query displays the top ten selling products based on sales recorded in the Order Items table. The query uses the TOP 
  2997.  feature of the SELECT statement. Because the order is set to DESCENDING, ordering by the sum of price and quantity returns the 10 highest values.
  2998. SELECT TOP 10
  2999.  Products.prod_name,;
  3000. ( Orditems.unit_price*  Orditems.quantity);
  3001.  testdata!products 
  3002. INNER JOIN 
  3003. testdata!orditems ;
  3004.  Products.product_id = Orditems.product_id;
  3005. GROUP BY
  3006.  Products.prod_name;
  3007. ORDER BY
  3008. Send Mail3
  3009. Send Mail
  3010. File: SAMPLES\SOLUTION\OLE\SENDMAIL.SCX
  3011. This sample illustrates using the mailbtn class in SAMPLES\CLASSES\BUTTONS.VCX to create a simple messaging form that can send Visual FoxPro data to an e-mail address.
  3012. Mailbtn is a container class that contains a command button and two ActiveX controls: MAPI Session and MAPI Messages, both of which are defined in MSMAPI32.OCX.  The MAPI Session control establishes a MAPI session, and the MAPI Messages control allows the user to perform a variety of messaging system functions.
  3013. The mailbtn class starts a new Mail session, collects data from the current record, and brings up the Send Mail dialog with the data inserted as the message text.
  3014. This class includes two custom methods AddTabs and StripPath for formatting the information gathered from the table and inserted in the mail message.
  3015. This class also takes advantage of another custom method called Signon as well as a custom property called logsession, which is set to .F. initially.
  3016. When the user clicks the cmdMail button, code in the Click event calls the signon method, setting logsession to true (.T.).:
  3017. this.logsession = .T.
  3018. this.OLEMSess.signon
  3019. If there is a failure on signon, the Error event of the class is called and logsession is set to .F.
  3020. The MAPI controls are invisible at run time. In addition, there are no events for the controls. To use them, you must specify the appropriate methods. For t
  3021. hese controls to work, MAPI services must be present. MAPI services are provided in Microsoft Mail and Exchange electronic mail systems for Microsoft Windows version 3.0 or later.
  3022. Sort List Box Items=
  3023. Sort List Box Items
  3024. File: SAMPLES\SOLUTION\CONTROLS\LISTS\LSORT.SCX
  3025. This sample demonstrates allowing a user to rearrange or sort the items in a list. The key properties to set are:
  3026. List.MoverBars = .T. 
  3027. List.Sorted = .T.
  3028. Set the MoverBars property to true (.T.) to allow a user to reorder an item in the list by dragging the button to the left of the item to the new position.
  3029. Set the Sorted property to true (.T.) to display the list items in alphabetical order. You can still rearrange the items in the list after they have been sorted. Set the Sorted property to .T. again to sort the list in alphabetical order again.
  3030. The Sorted property applies only if the RowSourceType property of the list is set to 0 (None) or 1 (Value).
  3031. Sort or Order A Table At Run TimeK
  3032. Sort or Order A Table At Run Time
  3033. File: SAMPLES\SOLUTION\DB\ORDER.SCX
  3034. This sample illustrates changing the order that records in a table are listed. The customer table has index tags on the fields displayed in the grid. In the MouseUp event of each of the headers in the grid, the order of the table is set to the index tag associated with the field displayed in the column. For example, the following code is associated with the MouseUp event of the Company header:
  3035. LPARAMETERS nButton, nShift, nXCoord, nYCoord
  3036. IF nShift = 2 && CTRL
  3037. SET ORDER TO
  3038.  Company 
  3039. DESCENDING
  3040. SET ORDER TO
  3041.  Company 
  3042. ASCENDING
  3043. ENDIF
  3044. GO TOP
  3045. THISFORM.Refresh
  3046. Use API Functions that Require a StructQ
  3047. Use API Functions that Require a STRUCT
  3048. File: SAMPLES\SOLUTION\WINAPI.SYSTIME.SCX
  3049. This example illustrates calling the Windows API function GetSystemTime. GetSystemTime fills in a structure of WORD (16-bit unsigned integer) values with system time information. 
  3050. C Function Declaration and Struct Definition
  3051. VOID GetSystemTime(
  3052.     LPSYSTEMTIME 
  3053. lpSystemTime
  3054. // address of system time structure  
  3055.    );
  3056. This is the struct definition
  3057. typedef struct _SYSTEMTIME {
  3058.     WORD wYear; 
  3059.     WORD wMonth; 
  3060.     WORD wDayOfWeek; 
  3061.     WORD wDay; 
  3062.     WORD wHour; 
  3063.     WORD wMinute; 
  3064.     WORD wSecond; 
  3065.     WORD wMilliseconds; 
  3066. } SYSTEMTIME; 
  3067. Calling the Function in Visual FoxPro
  3068. The Visual FoxPro code passes GetSystemTime a reference to a character variable, which is filled in with the WORD values. 
  3069. * Visual FoxPro Code: cmdSystemTime.Click
  3070. DECLARE INTEGER GetSystemTime IN win32api STRING @
  3071. cBuff=SPACE(40)
  3072. GetSystemTime(@cBuff)
  3073. To retrieve the information from the character variable, cBuff, the following code converts 8 bit ASCII characters for year and month in the variable into 16 bit equivalents.
  3074. THIS.Parent.lblYear.Caption = ALLTRIM(STR(ASC(SUBSTR(cBuff,2)) * 256 + ASC(SUBSTR(cBuff,1))))
  3075. THIS.Parent.lblMonth.Caption = MONTH_LOC + ALLTRIM(STR(ASC(SUBSTR(cBuff,4)) * 256 + ASC(SUBSTR(cBuff,3))))
  3076. Use API Functions that Require Pointers to Arrays[
  3077. Use API Functions that Require Pointers to Arrays
  3078. File: SAMPLES\SOLUTION\WINAPI\SYSCOLOR.SCX
  3079. This example uses two Windows API functions to first get the system color settings (GetSysColor) and then to reset the system colors to new values (SetSysColors). Two of the three arguments required by SetSysColors are pointers to native C arrays. 
  3080. GetSysColor
  3081. The GetSysColor function accepts an integer parameter, a number between 0 and 18, and returns a DWORD (32-bit unsigned integer) indicating the current color setting.
  3082. DWORD GetSysColor(
  3083.     int 
  3084. nIndex
  3085. // display element
  3086.    );
  3087. nIndex is a value representing an area of the interface, as defined in the following list.
  3088. #define COLOR_SCROLLBAR         0
  3089. #define COLOR_BACKGROUND        1
  3090. #define COLOR_ACTIVECAPTION     2
  3091. #define COLOR_INACTIVECAPTION   3
  3092. #define COLOR_MENU              4
  3093. #define COLOR_WINDOW            5
  3094. #define COLOR_WINDOWFRAME       6
  3095. #define COLOR_MENUTEXT          7
  3096. #define COLOR_WINDOWTEXT        8
  3097. #define COLOR_CAPTIONTEXT       9
  3098. #define COLOR_ACTIVEBORDER      10
  3099. #define COLOR_INACTIVEBORDER    11
  3100. #define COLOR_APPWORKSPACE      12
  3101. #define COLOR_HIGHLIGHT         13
  3102. #define COLOR_HIGHLIGHTTEXT     14
  3103. #define COLOR_BTNFACE           15
  3104. #define COLOR_BTNSHADOW         16
  3105. #define COLOR_GRAYTEXT          17
  3106. #define COLOR_BTNTEXT           18
  3107. #define COLOR_INACTIVECAPTIONTEXT 19
  3108. #define COLOR_BTNHIGHLIGHT      20
  3109. #if(WINVER >= 0x0400) /* Windows 95 differences */
  3110. #define COLOR_3DDKSHADOW        21
  3111. #define COLOR_3DLIGHT           22
  3112. #define COLOR_INFOTEXT          23
  3113. #define COLOR_INFOBK            24
  3114. #define COLOR_DESKTOP           COLOR_BACKGROUND
  3115. #define COLOR_3DFACE            COLOR_BTNFACE
  3116. #define COLOR_3DSHADOW          COLOR_BTNSHADOW
  3117. #define COLOR_3DHIGHLIGHT       COLOR_BTNHIGHLIGHT
  3118. #define COLOR_3DHILIGHT         COLOR_BTNHIGHLIGHT
  3119. #define COLOR_BTNHILIGHT        COLOR_BTNHIGHLIGHT
  3120. #endif /* WINVER >= 0x0400 */
  3121. SetSysColors
  3122. The SetSysColors function requires three arguments: the number of elements in two arrays and the addresses of the two arrays.
  3123. BOOL WINAPI SetSysColors(
  3124.     int 
  3125. cElements
  3126. // number of elements to change 
  3127.     CONST INT *
  3128. lpaElements
  3129. // address of array of elements 
  3130.     CONST COLORREF *
  3131. lpaRgbValues
  3132. // address of array of RGB values  
  3133.    );
  3134. Calling SetSysColors in Visual FoxPro
  3135. The following code is extracted from cmdSetSysColors.Click:
  3136. DECLARE INTEGER 
  3137. SetSysColors
  3138.  IN win32api INTEGER, STRING, STRING
  3139. Construct the elements of the first  array in a character variable.
  3140. cElements = ""
  3141. FOR i = 0 TO 18
  3142. cElements = cElements + THISFORM.DecToHex(i)
  3143. ENDFOR
  3144. Construct the elements of the second array in a character variable.  The cursor that is scanned was filled with GetSysColor values in the Init of the form.
  3145. cColors = ""
  3146. cColors = cColors + THISFORM.DecToHex(INT(color))
  3147. ENDSCAN
  3148. SetSysColors
  3149. (18,cElements,cColors)
  3150. Use Conditional Formatting in a ReportP
  3151. Use Conditional Formatting in a Report
  3152. File: SAMPLES\SOLUTION\REPORTS\COLORS.FRX
  3153. This sample report demonstrates how you can use Print When conditions for controls to change field formatting based on the values in the record. The sample prints a "Product Inventory Report." If the product item is discontinued, it is printed in strikeout. If the In Stock amount is below the reorder level and the product is not discontinued, the item is printed in red. Otherwise, the product item is printed in standard black.
  3154. This report uses the table, PRODUCTS, from the database, TESTDATA, in the Data Environment. The Detail band has field controls for the product information such as ID, name, amount in stock, and amount on order. Another field control prints an reminder of the inventory level the reader of the reorder amount.
  3155. To handle the three cases, three sets of field controls for the product information are layered on top of each other in the Detail band. For the first set, the text color is red; for the second, the color is black; and for the third, the font effect is Strikeout.
  3156. Each control set has a different Print When expression.
  3157. For the plain black fields:
  3158. (products.in_stock > products.reorder_at) and products.discontinu = .F.
  3159. For the strikeout fields:
  3160. products.discontinu = .T.
  3161. For the red text color fields:
  3162. products.in_stock <= products.reorder_at and products.discontinu = .F.
  3163. Use Slider and Status Bar ControlsL
  3164. Use Slider and Status Bar Controls
  3165. File: SAMPLES\SOLUTION\OLE\SLIDER.SCX
  3166. This sample illustrates using the Slider control and the StatusBar control. 
  3167. Slider Controls
  3168. Code in the Scroll event of each slider control sets the Value property of the other controls:
  3169. #DEFINE TXT_LOC "slider value: "
  3170. THISFORM.Olecontrol2.Panels(2).Text = TXT_LOC + ALLTRIM(STR(THIS.value))
  3171. THIS.Parent.spn1.Value = THIS.Value
  3172. THIS.Parent.oleV.Value = THIS.Value
  3173. StatusBar Control
  3174. The StausBar Control Properties dialog box makes setting status bar properties easy.
  3175. To open the StatusBar Control Properties dialog, choose StatusBar Control Prop
  3176. erties from the shortcut menu of a StatusBar Control.
  3177. Use the RichText ControlB
  3178. Use the RichText Control
  3179. File: SAMPLES\SOLUTION\OLE\RTF.SCX
  3180. This sample illustrates using a RichText control to display and edit RTF text stored in the memo field of a table.
  3181. You can set the ControlSource of a RichText control directly to a character field, but not a memo field. Instead, create a form property to mediate between the RichText control and the memo field.
  3182. To store RTF text in a memo field
  3183. Set the ControlSource property of the RichText control to the form property.
  3184. THISFORM.oleRTF.ControlSource = THISFORM.cText
  3185. Store the memo field contents to the form property.
  3186. THISFORM.cText = rtf.source
  3187. Before moving the record pointer, store the TextRTF property of the RichText control to the memo field.
  3188. REPLACE rtf.Source WITH THISFORM.oleRTF.TextRTF
  3189. The text stored in the memo file is standard RTF format, for example:
  3190. {\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss Arial;}{\f3\fswiss Arial;}} {\colortbl\red0\green0\blue0;\red255\green0\blue0;} \deflang1033\pard\qc\plain\f3\fs32\i The RichTextBox Control \par \pard\plain\f3\fs20 
  3191. View Type Library InformationG
  3192. View Type Library Information
  3193. File: SAMPLES\SOLUTION\WINAPI\TYPELIB.SCX
  3194. The TYPELIB sample uses a Visual FoxPro class named Typelib which is stored in SAMPLES\CLASSES\TYPELIB.VCX. This container class has an ActiveX control called FoxTlib that contains a number of methods to read Type Library information from any DLL, EXE, or TLB file.
  3195. The Typelib wrapper class saves you time by handling much of the dirty work for you. There is a method called ExportTypeLib in this class which exports the contents of a specified Type Library to a text file:
  3196. THISFORM.typelib1.TypeLibName = THISFORM.txtFileName.Value
  3197. THISFORM.typelib1.ExportTypeLib( )
  3198. If you take a look at the generated text file, you will notice that a Type Library can consist of multiple Type Infos. Each Type Info represents a specific class. When you generate a new EXE or DLL from a project using VFP, each class in the project which is marked as OLEPUBLIC will generate a separate Custom OLE Server. Note: you only have a single EXE/DLL file, however, this file can contain multiple servers (one for each OLEPUBLIC class). And VFP generates a single TLB file for the project. This Type Library file contains a separate Type Info for each OLEPUBLIC class.
  3199. Within each Type Info (OLEPUBLIC class), there are also Function descriptions. These represent all of the properties and methods of a class. For methods, the Type Library contains both parameter and return types. Some of the possible types are boolean , string, and variant. Because VFP does not strong type memory variables, many of the types used in your custom methods will be variant. 
  3200. If you take a close look at the functions exported, you will notice double entries for many of the properties. Thi
  3201. s is because users can 
  3202.  the value of this property. And some languages such as Visual Basic allow you to have code executed when one of these properties is accessed or assigned. Hence, the Type Library will represent a single property with 2 entries. If only a single entry exists, then that property is read-only. Properties and methods which are marked as Hidden or Protected will not appear in the Type Library.
  3203. MS Sans Serif
  3204. Tms Rmn
  3205. Symbol
  3206. Courier
  3207. Times New Roman
  3208. Arial
  3209. MS Serif
  3210. Times
  3211. Helvetica
  3212. System
  3213. Courier New
  3214. New York
  3215. Geneva
  3216. LinePrinter
  3217. CG Times
  3218. Univers
  3219. Univers Condensed
  3220. Antique Olive
  3221. Garamond
  3222. CG Omega
  3223. Albertus Medium
  3224. Albertus Extra Bold
  3225. Clarendon Condensed
  3226. Coronet
  3227. Letter Gothic
  3228. Marigold
  3229. Wingdings
  3230. Marlett
  3231. Lucida Console
  3232. Arial Narrow
  3233. Arial Black
  3234. Book Antiqua
  3235. Bookman Old Style
  3236. Century Schoolbook
  3237. 1-to-many form
  3238. ActiveX
  3239. ActiveX, automation
  3240. ActiveX, custom
  3241. ActiveX, Excel automation
  3242. ActiveX, RichText
  3243. ActiveX, slider and status bar controls
  3244. Add and Remove Items in a Treeview Control
  3245. Add Items Interactively to a List Box
  3246. Add Menu Items at Run Time
  3247. Add New Items to a Combo Box
  3248. Allow Users to Choose List Values
  3249. Allow Users to Drag and Drop Controls
  3250. Animation, form graphics
  3251. API Functions
  3252. Automate a Microsoft Excel Spreadsheet
  3253. Automate a Microsoft Word Document in a Form
  3254. Automate Microsoft Word and Excel
  3255. BEGIN TRANSACTION
  3256. BINTOC( )
  3257. Bitmaps, displaying
  3258. Calculations, in columns
  3259. Change Font Attributes
  3260. Change Pages When a User Chooses a Button
  3261. Change the Number of Tabs at Run Time
  3262. Check box, design options
  3263. Check mark, displaying beside a menu item
  3264. Clock
  3265. Column, displaying calculated values in
  3266. Combo Box, adding new items
  3267. Components in the Solutions sample application
  3268. Controls, adding to grid columns
  3269. Controls, resizing and repositioning
  3270. Coordinate Menu Items and Toolbar Buttons
  3271. Create a 1-To-Many Data Entry Form
  3272. Create a Default Unique Id Value for a Field
  3273. Create a Query-By-Example Form
  3274. Create a Single Table Data Entry Form
  3275. Create an SDI Form
  3276. Create Dynamic Shortcut Menus
  3277. Create Small Indexes Using BINTOC( )
  3278. Customize the Open Dialog Box
  3279. Dialog Box, customize
  3280. Disable or Display a Check Beside a Menu Item
  3281. Display a Stop Watch
  3282. Display a System Clock
  3283. Display Calculated Values in a Column
  3284. Display Child Records from a Relationship
  3285. Display Controls in a Grid
  3286. Display Different Pages Without Tabs
  3287. Display Line Animation on a Form
  3288. Display Multiple Columns in a List Box
  3289. Display Pictures in a List
  3290. Display Pictures in an Image Control
  3291. Display Shortcut Menus
  3292. Display System Information
  3293. Drag and drop, between list boxes
  3294. Drag and Drop, reposition a control
  3295. Draw Lines and Shapes on a Form
  3296. Dynamically Format Grid Columns
  3297. DynamicForeColor and DynamicBackColor
  3298. Edit a Memo Field or Text File
  3299. Edit box
  3300. Edit box, counting words
  3301. END TRANSACTION
  3302. Excel, automation
  3303. Execute Commands at Specified Intervals
  3304. Expressions, Indexing on
  3305. Files, opening
  3306. Fill a list with database elements
  3307. Fill a List with Values from Different Sources
  3308. Font, attributes, change
  3309. Form graphics, animation
  3310. Form graphics, graphing equations
  3311. Form graphics, lines and shapes
  3312. Form, 1-to-many
  3313. Form, data entry
  3314. Form, query by example
  3315. Format Input and Validate Data in a Text Box
  3316. Forms, running multiple instances
  3317. Forms, SDI
  3318. FoxDraw
  3319. Get Application Information from the Windows Registry
  3320. Get Version Information
  3321. GetSysColors
  3322. Graph
  3323. Graph Equations on a Form
  3324. Graph, refreshing
  3325. Grid, displaying calculated values in columns
  3326. Grid, displaying controls in columns
  3327. Grid, dynamic formatting
  3328. Grid, setting order
  3329. Help, What's This
  3330. How the Solutions Sample Works
  3331. Image control, displaying pictures
  3332. Index on Expressions
  3333. Indexes, small
  3334. Interactively Build a SELECT Statement
  3335. Labels
  3336. List box
  3337. List box, adding items
  3338. List box, displaying files
  3339. List box, multiple columns
  3340. List box, RowSourceType settings
  3341. List box, selecting multiple items
  3342. List box, Sorted property
  3343. List boxes, moving items between
  3344. Logon form
  3345. Lookup values
  3346. Mail, send
  3347. Manipulate Display Characteristics of a Graph
  3348. Memo field editing
  3349. Menu item, checking
  3350. Menu item, disabling
  3351. Menu items, adding at run time
  3352. Menu items, coordinating with toolbars
  3353. Menus, display shortcut
  3354. menus, dynamic shortcut
  3355. Microsoft Word and Excel, automate
  3356. MODIFY FILE command
  3357. Move Items Between List Boxes
  3358. Moverbars property, list box
  3359. MS Graph, manipulating
  3360. Multimedia
  3361. Multiple table data entry
  3362. Multiselect Items in a List Box
  3363. MultiSelect property, list box
  3364. Nest Transactions
  3365. Nodes, adding to a treeview control
  3366. OLE, Manipulating graph characteristics
  3367. Open Dialog Box Flag Values
  3368. Open Multiple Files Interactively
  3369. Option buttons, multiple choices
  3370. Outline control
  3371. Page frame, adjusting tabs at run time
  3372. Page frame, changing pages with option buttons
  3373. Page frames, without tabs
  3374. Parameters, passing
  3375. Pass Parameters between Forms
  3376. Play an AVI File in an ActiveX Control
  3377. Play Multimedia Files Using MCI Commands
  3378. Present a User with Multiple Choices
  3379. Print a Percent of Total in a Report
  3380. Print an Invoice
  3381. Print Customer Mailing Labels
  3382. Print Data Dictionary Information
  3383. Print in Catalog Format
  3384. Print Product Orders By Quarter
  3385. Print Report Details in a Ledger Style
  3386. Programmatically Check Table Properties
  3387. Programmatically Manipulate Objects
  3388. Programmatically Manipulate Text
  3389. Properties, setting at run time
  3390. Provide a Hierarchical Display of Items
  3391. Provide What's This Help on a Form
  3392. Queries, build a SELECT statement
  3393. Queries, Select records from a full outer join
  3394. Queries, Select records from a left outer join
  3395. Queries, Select records from a nested join
  3396. Queries, Select records from a right outer join
  3397. Queries, Select records from an inner join
  3398. Queries, Select records from both inner and outer joins
  3399. Queries, Select the ten worst selling products
  3400. Queries, Select the top ten best selling products
  3401. Queries, Top N
  3402. Query By Example
  3403. Read and Write VFP Registry Values
  3404. Read ODBC Registry Values
  3405. Refresh a Graph in a Form
  3406. Relationship, displaying in a form
  3407. Reports, catalog
  3408. xcel, automate
  3409. Reports, conditional formatting
  3410. Reports, invoice
  3411. Reports, ledger
  3412. Reports, percent of total
  3413. Resize and Reposition Controls at Run Time
  3414. Return a Value from a Form
  3415. RichText control
  3416. ROLLBACK
  3417. RowSourceType, filling a list box
  3418. Run Multiple Instances of a Form
  3419. SDI form, creating
  3420. Search for values
  3421. See Check Box Design Options
  3422. See Command Button Design Options
  3423. Select Customers in a Specific Country
  3424. Select Records from a Full Outer Join
  3425. Select Records from a Left Outer Join
  3426. Select Records from a Nested Join
  3427. Select Records from a Right Outer Join
  3428. Select Records from an Inner Join
  3429. Select Records from Both Inner and Outer Joins
  3430. Select the Ten Worst Selling Products
  3431. Select the Top Ten Best Selling Products
  3432. SelStart and SelLength properties
  3433. Send Mail
  3434. SET ORDER TO
  3435. Single table data entry
  3436. Slider
  3437. Solution.scx
  3438. Solutions Sample
  3439. Sort List Box Items
  3440. Sort or Order A Table At Run Time
  3441. Sparse property, setting
  3442. Status bar
  3443. Stop watch
  3444. Stored procedures, creating a default field value
  3445. System Information, display
  3446. Table properties, getting
  3447. Text box, formatting text
  3448. Text file editing
  3449. Timer, clock
  3450. Timer, displaying a stop watch
  3451. Timer, executing commands
  3452. Toolbars, coordinating with menus
  3453. Transactions, nesting
  3454. Treeview
  3455. Treeview control
  3456. Unique ID, creating
  3457. Use API Functions that Require a Struct
  3458. Use API Functions that Require Pointers to Arrays
  3459. Use Conditional Formatting in a Report
  3460. Use Slider and Status Bar Controls
  3461. Use the RichText Control
  3462. Validate data in a text box
  3463. Version, get information
  3464. View Type Library Information
  3465. Views, Select customers in a specific country
  3466. What's This Help
  3467. WinAPI, registry
  3468. WinAPI, Registry information
  3469. Word, automation
  3470. xcel, automate
  3471. Drag and drop, between list boxes
  3472. MODIFY FILE command
  3473. Reports, conditional formatting
  3474. Solutions Sample
  3475. How the Solutions Sample Works
  3476. Components in the Solutions Sample Application
  3477. Add and Remove Items in a Treeview Control
  3478. Add Items Interactively to a List Box
  3479. Add Menu Items at Run Time
  3480. Add New Items to a Combo Box
  3481. Allow Users to Choose List Values
  3482. Allow Users to Drag and Drop Controls
  3483. Automate Microsoft Word and Excel
  3484. Automate a Microsoft Excel Spreadsheet
  3485. Automate a Microsoft Word Document in a Form
  3486. Change Font Attributes
  3487. Change Pages When a User Chooses a Button
  3488. Change the Number of Tabs at Run Time
  3489. Coordinate Menu Items and Toolbar Buttons
  3490. Create a 1-To-Many Data Entry Form
  3491. Create a Default Unique Id Value for a Field
  3492. Create a Query-By-Example Form
  3493. Create a Single Table Data Entry Form
  3494. Create an SDI Form
  3495. Create Dynamic Shortcut Menus
  3496. Customize the Open Dialog Box
  3497. Open Dialog Box Flag Values
  3498. Disable or Display a Check Beside a Menu Item
  3499. Display a Stop Watch
  3500. Display a System Clock
  3501. Display Calculated Values in a Column
  3502. Display Child Records from a Relationship
  3503. Display Controls in a Grid
  3504. Display Different Pages Without Tabs
  3505. Display Line Animation on a Form
  3506. Display Multiple Columns in a List Box
  3507. Display Pictures in a List
  3508. Display Pictures in an Image Control
  3509. Display Shortcut Menus
  3510. Display System Information
  3511. Draw Lines and Shapes on a Form
  3512. Dynamically Format Grid Columns
  3513. Edit a Memo Field or Text File
  3514. Execute Commands at Specified Intervals
  3515. Fill a List with Values from Different Sources
  3516. Format Input and Validate Data in a Text Box
  3517. Get Application Information from the Windows Registry
  3518. Get Version Information
  3519. Graph Equations on a Form
  3520. Index on Expressions
  3521. Create Small Indexes Using BINTOC( )
  3522. Interactively Build a SELECT Statement
  3523. Manipulate Display Characteristics of a Graph
  3524. Move Items Between List Boxes
  3525. Multiselect Items in a List Box
  3526. Nest Transactions
  3527. Open Multiple Files Interactively
  3528. Pass Parameters between Forms
  3529. Play an AVI File in an ActiveX Control
  3530. Play Multimedia Files Using MCI Commands
  3531. Present a User with Multiple Choices
  3532. Print a Percent of Total in a Report
  3533. Print an Invoice
  3534. Print Customer Mailing Labels
  3535. Print Data Dictionary Information
  3536. Print Product Orders By Quarter
  3537. Print in Catalog Format
  3538. Print Report Details in a Ledger Style
  3539. Programmatically Check Table Properties
  3540. Programmatically Manipulate Objects
  3541. Programmatically Manipulate Text
  3542. Provide a Hierarchical Display of Items
  3543. Provide What's This Help on a Form
  3544. Read and Write VFP Registry Values
  3545. Read ODBC Registry Values
  3546. Refresh a Graph in a Form
  3547. Resize and Reposition Controls at Run Time
  3548. Return a Value from a Form
  3549. Run Multiple Instances of a Form
  3550. See Check Box Design Options
  3551. See Command Button Design Options
  3552. Select Customers in a Specific Country
  3553. Select Records from a Full Outer Join
  3554. Select Records from a Left Outer Join
  3555. Select Records from a Nested Join
  3556. Select Records from a Right Outer Join
  3557. Select Records from an Inner Join
  3558. Select Records from Both Inner and Outer Joins
  3559. Select the Ten Worst Selling Products
  3560. Select the Top Ten Best Selling Products
  3561. Send Mail
  3562. Sort List Box Items
  3563. Sort or Order A Table At Run Time
  3564. Use API Functions that Require a Struct
  3565. Use API Functions that Require Pointers to Arrays
  3566. Use Conditional Formatting in a Report
  3567. Use Slider and Status Bar Controls
  3568. Use the RichText Control
  3569. View Type Library Information
  3570. ext Box
  3571. Get Application Information from the Windows Registry
  3572. Get Version Information
  3573. Graph Equations on a Form
  3574. Index on Expressions
  3575. Create Small Indexes Using BINTOC( )
  3576. Interactively Build a SELECT Statement
  3577. Manipulate Display Characteristics of a Graph
  3578. Move Items Between List Boxes
  3579. Multiselect Items in a List Box
  3580. Nest Transactions
  3581. dPO2T
  3582. fN(]U
  3583. wpwpww
  3584. :Base solution
  3585. :Title Visual FoxPro Solutions
  3586. 1 Solutions
  3587. 2 Solutions Sample=samSolutions_Sample@solution.hlp
  3588. 1 ActiveX
  3589. 2 ActiveX controls
  3590. 3 Add and Remove Items in a Treeview Control=samAdd_and_Remove_Items_in_a_Treeview_Control@solution.hlp
  3591. 3 Provide a hierarchical display of items=samProvide_a_Hierarchical_Display_of_Items@solution.hlp
  3592. 3 Use the richtext control=samUse_the_RichText_Control@solution.hlp
  3593. 3 Use slider and status bar controls=samUse_Slider_and_Status_Bar_Controls@solution.hlp
  3594. 3 Display system information=samDisplay_System_Information@solution.hlp
  3595. 3 Send mail=samSend_Mail@solution.hlp
  3596. 3 Customize the open dialog box=samCustomize_the_Open_Dialog_Box@solution.hlp
  3597. 2 Automation
  3598. 3 Manipulate display characteristics of a graph=samManipulate_Display_Characteristics_of_a_Graph@solution.hlp
  3599. 3 Automate a Microsoft Excel spreadsheet=samAutomate_a_Microsoft_Excel_Spreadsheet@solution.hlp
  3600. 3 Automate a Microsoft Word Document in a form=samAutomate_a_Microsoft_Word_Document_in_a_Form@solution.hlp
  3601. 3 Refresh a graph in a form=samRefresh_a_Graph_in_a_Form@solution.hlp
  3602. 3 Automate Microsoft Word and Excel=samAutomate_Microsoft_Word_and_Excel@solution.hlp
  3603. 3 Manipulate display characteristics of a graph=samManipulate_Display_Characteristics_of_a_Graph@solution.hlp
  3604. 1 Controls
  3605. 2 Editbox
  3606. 3 Edit a memo field or text file=samEdit_a_Memo_Field_or_Text_File@solution.hlp
  3607. 3 Programatically manipulate text=samProgrammatically_Manipulate_Text@solution.hlp
  3608. 2 Grid
  3609. 3 Display calculated values in a column=samDisplay_Calculated_Values_in_a_Column@solution.hlp
  3610. 3 Display controls in a grid=samDisplay_Controls_in_a_Grid@solution.hlp
  3611. 3 Dynamically format grid columns=samDynamically_Format_Grid_Columns@solution.hlp
  3612. 3 Display child records from a relationship=samDisplay_Child_Records_from_a_Relationship@solution.hlp
  3613. 2 Listbox
  3614. 3 Add items interactively to a list box=samAdd_Items_Interactively_to_a_List_Box@solution.hlp
  3615. 3 Display multiple columns in a listbox=samDisplay_Multiple_Columns_in_a_List_Box@solution.hlp
  3616. 3 Move items between list boxes=samMove_Items_Between_List_Boxes@solution.hlp
  3617. 3 Multiselect items in a list box=samMultiselect_Items_in_a_List_Box@solution.hlp
  3618. 3 Open multiple files interactively=samOpen_Multiple_Files_Interactively@solution.hlp
  3619. 3 Sort list box items=samSort_List_Box_Items@solution.hlp
  3620. 3 Fill a list with values from different sources=samFill_a_List_with_Values_from_Different_Sources@solution.hlp
  3621. 3 Display pictures in a list=samDisplay_Pictures_in_a_List@solution.hlp
  3622. 2 Option buttons
  3623. 3 Present a user with multiple choices=samPresent_a_User_with_Multiple_Choices@solution.hlp
  3624. 3 Change pages when a user chooses a button=samChange_Pages_When_a_User_Chooses_a_Button@solution.hlp
  3625. 2 Page frame
  3626. 3 Change the number of tabs at run time=samChange_the_Number_of_Tabs_at_Run_Time@solution.hlp
  3627. 3 Display different pages without tabs=samDisplay_Different_Pages_Without_Tabs@solution.hlp
  3628. 2 Text box
  3629. 3 Format input and validate data in a text box=samFormat_Input_and_Validate_Data_in_a_Text_Box@solution.hlp
  3630. 2 Timer
  3631. 3 Display a stop watch=samDisplay_a_Stop_Watch@solution.hlp
  3632. 3 Display a system clock=samDisplay_a_System_Clock@solution.hlp
  3633. 3 Execute commands at specified intervals=samExecute_Commands_at_Specified_Intervals@solution.hlp
  3634. 2 Command buttons
  3635. 3 See command button design options=samSee_Command_Button_Design_Options@solution.hlp
  3636. 2 Check box
  3637. 3 See check box design options=samSee_Check_Box_Design_Options@solution.hlp
  3638. 2 Combo box
  3639. 3 Add new items to a combo box=samAdd_New_Items_to_a_Combo_Box@solution.hlp
  3640. 3 Allow users to choose list values=samAllow_Users_to_Choose_List_Values@solution.hlp
  3641. 2 General
  3642. 3 Resize and reposition controls at run time=samResize_and_Reposition_Controls_at_Run_Time@solution.hlp
  3643. 3 Allow users to drag and drop controls=samAllow_Users_to_Drag_and_Drop_Controls@solution.hlp
  3644. 1 Databases
  3645. 2 Indexes
  3646. 3 Index on expressions=samIndex_on_Expressions@solution.hlp
  3647. 3 Create small indexes using BINTOC()=samCreate_Small_Indexes_Using_BINTOCLP_RP@solution.hlp
  3648. 2 Tables
  3649. 3 Create a default unique id value for a field=samCreate_a_Default_Unique_Id_Value_for_a_Field@solution.hlp
  3650. 3 Sort or order a table at run time=samSort_or_Order_A_Table_At_Run_Time@solution.hlp
  3651. 3 Programatically check table properties=samProgrammatically_Check_Table_Properties@solution.hlp
  3652. 2 Transactions
  3653. 3 Nest Transactions=samNest_Transactions@solution.hlp
  3654. 2 Views/Queries
  3655. 3 Select records from both inner and outer joins=samSelect_Records_from_Both_Inner_and_Outer_Joins@solution.hlp
  3656. 3 Select records from a full outer join=samSelect_Records_from_a_Full_Outer_Join@solution.hlp
  3657. 3 Select records from an inner join=samSelect_Records_from_an_Inner_Join@solution.hlp
  3658. 3 Select records from a nested join=samSelect_Records_from_a_Nested_Join@solution.hlp
  3659. 3 Select records from a right outer join=samSelect_Records_from_a_Right_Outer_Join@solution.hlp
  3660. 3 Select records from a left outer join=samSelect_Records_from_a_Left_Outer_Join@solution.hlp
  3661. 3 Interactively build a SELECT statement=samInteractively_Build_a_SELECT_Statement@solution.hlp
  3662. 3 Select customers in a specific country=samSelect_Customers_in_a_Specific_Country@solution.hlp
  3663. 3 Select the top ten best selling products=samSelect_the_Top_Ten_Best_Selling_Products@solution.hlp
  3664. 3 Select the ten worst selling products=samSelect_the_Ten_Worst_Selling_Products@solution.hlp
  3665. 1 Forms
  3666. 2 Form Graphics
  3667. 3 Draw lines and shapes on a form=samDraw_Lines_and_Shapes_on_a_Form@solution.hlp
  3668. 3 Graph equations on a form=samGraph_Equations_on_a_Form@solution.hlp
  3669. 3 Display line animation on a form=samDisplay_Line_Animation_on_a_Form@solution.hlp
  3670. 2 Data Entry
  3671. 3 Create a single table data entry form=samCreate_a_Single_Table_Data_Entry_Form@solution.hlp
  3672. 3 Create a 1-to-many data entry form=samCreate_a___To_Many_Data_Entry_Form@solution.hlp
  3673. 2 Create an SDI form=samCreate_an_SDI_Form@solution.hlp
  3674. 2 Return a value from a form=samReturn_a_Value_from_a_Form@solution.hlp
  3675. 2 Provide What's This help on a form=samProvide_What_s_This_Help_on_a_Form@solution.hlp
  3676. 2 Create a query by example form=samCreate_a_Query_By_Example_Form@solution.hlp
  3677. 2 Programmatically manipulate objects=samProgrammatically_Manipulate_Objects@solution.hlp
  3678. 2 Run multiple instances of a form=samRun_Multiple_Instances_of_a_Form@solution.hlp
  3679. 2 Pass parameters between forms=samPass_Parameters_between_Forms@solution.hlp
  3680. 2 Display pictures in an image control=samDisplay_Pictures_in_an_Image_Control@solution.hlp
  3681. 1 Menus
  3682. 2 Add menu items at runtime=samAdd_Menu_Items_at_Run_Time@solution.hlp
  3683. 2 Disable or display a check beside a menu item=samDisable_or_Display_a_Check_Beside_a_Menu_Item@solution.hlp
  3684. 2 Coordinate menu items and toolbar buttons=samCoordinate_Menu_Items_and_Toolbar_Buttons@solution.hlp
  3685. 2 Add a menu to an SDI form=samAdd_a_Menu_to_an_SDI_Form@solution.hlp
  3686. 2 Display shortcut menus=samDisplay_Shortcut_Menus@solution.hlp
  3687. 2 Create dynamic shortcut menus=samCreate_Dynamic_Shortcut_Menus@solution.hlp
  3688. 1 Reports
  3689. 2 Print a percent of total in a report=samPrint_a_Percent_of_Total_in_a_Report@solution.hlp
  3690. 2 Use conditional formatting in a report=samUse_Conditional_Formatting_in_a_Report@solution.hlp
  3691. 2 Print an invoice=samPrint_an_Invoice@solution.hlp
  3692. 2 Print report details in a ledger style=samPrint_Report_Details_in_a_Ledger_Style@solution.hlp
  3693. 2 Print in catalog format=samPrint_in_Catalog_Format@solution.hlp
  3694. 2 Print customer mailing labels=samPrint_Customer_Mailing_Labels@solution.hlp
  3695. 1 Toolbars
  3696. 2 Coordinate menu items and toolbar buttons=samCoordinate_Menu_Items_and_Toolbar_Buttons@solution.hlp
  3697. 2 Change font attributes=samChange_Font_Attributes@solution.hlp
  3698. 1 Windows API
  3699. 2 Use API functions that require a STRUCT=samUse_API_Functions_that_Require_a_Struct@solution.hlp
  3700. 2 Use API functions that require pointers to arrays=samUse_API_Functions_that_Require_Pointers_to_Arrays@solution.hlp
  3701. 2 Read and write VFP Registry values=samRead_and_Write_VFP_Registry_Values@solution.hlp
  3702. 2 Get application information from the Windows Registry=samGet_Application_Information_from_the_Windows_Registry@solution.hlp
  3703. 2 Read ODBC Registry values=samRead_ODBC_Registry_Values@solution.hlp
  3704. 2 Play multimedia files using MCI commands=samPlay_Multimedia_Files_Using_MCI_Commands@solution.hlp
  3705. 2 Get version information=samGet_Version_Information@solution.hlp
  3706. 2 View type library information=samView_Type_Library_Information@solution.hlp
  3707. 2""""""""""""""""""""""""""""""""""
  3708. ?3333333333333333333333333333333332
  3709. ?3333333333333333333333333333333332
  3710. ?3333333333333333333333333333333332
  3711. ?3333333333333333333333333333333332
  3712. ?3333333333333333333333333333333332
  3713. ?33333330303
  3714. 3333333333332
  3715. ?333333303
  3716. 03003
  3717. 333333333332
  3718. ?333333303
  3719. 03303
  3720. 03333
  3721. 333333333332
  3722. ?333333303
  3723. 03333
  3724. 333333333332
  3725. ?333333303
  3726. 03003
  3727. 333333333332
  3728. ?333333303
  3729. 3333333333332
  3730. ?333333303
  3731. 333333333
  3732. 33333333333332
  3733. ?333333303
  3734. 333333333
  3735. 33333333333332
  3736. ?3333333033333333333
  3737. 333333333332
  3738. ?3333333333333333333333333333333332
  3739. ?3333333333333333333333333333333332
  3740. ?3333333333333333333333333333333332
  3741. ?3333333333333333333333333333333332
  3742. ?3333333333333333333333333333333332
  3743. ?3333333333333333333333333333333332
  3744. ?33333330303
  3745. 033303333333333332
  3746. ?333333303
  3747. 03003
  3748. 033303333333333332
  3749. ?333333303
  3750. 03303
  3751. 333333333332
  3752. ?333333303
  3753. 03333333333332
  3754. ?333333303
  3755. 03003
  3756. 033003333333333332
  3757. ?333333303
  3758. 33003333333333332
  3759. ?333333303
  3760. 3333333333
  3761. 3333333333332
  3762. ?333333303
  3763. 3333333333
  3764. 3333333333332
  3765. ?3333333033333333333303333333333332
  3766. ?3333333333333333333333333333333332
  3767. ?3333333333333333333333333333333332
  3768. ?3333333333333333333333333333333332
  3769. ?3333333333333333333333333333333332
  3770. ?3333333333333333333333333333333332
  3771. ?3333333333333333333333333333333332
  3772. ?33333330303
  3773. 3333333333332
  3774. ?333333303
  3775. 03003
  3776. 333333333332
  3777. ?333333303
  3778. 03303
  3779. 03333
  3780. 333333333332
  3781. ?333333303
  3782. 03333
  3783. 333333333332
  3784. ?333333303
  3785. 03003
  3786. 3333333333332
  3787. ?333333303
  3788. 333333333332
  3789. ?333333303
  3790. 33333333333
  3791. 333333333332
  3792. ?333333303
  3793. 333333333
  3794. 333333333332
  3795. ?33333330333333333330
  3796. 3333333333332
  3797. ?3333333333333333333333333333333332
  3798. ?3333333333333333333333333333333332
  3799. ?3333333333333333333333333333333332
  3800. ?3333333333333333333333333333333332
  3801. ?3333333333333333333333333333333332
  3802. ?3333333333333333333333333333333332
  3803. ?2""""""""""""""""""""""""""""""""2
  3804. ?3333333333333333333333333333333332
  3805. ?3333333333333333333333333333333332
  3806. ?3333333333333333333333333333333332
  3807. ?3333333333333333333333333333333332
  3808. ?3333333333333333333333333333333332
  3809. ?3333333333333333333333333333333332
  3810. ?3333333333333333333333333333333332
  3811. ?33333330303
  3812. 333333333332
  3813. ?333333303
  3814. 03003
  3815. 33333333333332
  3816. ?333333303
  3817. 03303
  3818. 033033333333333332
  3819. ?333333303
  3820. 3333333333332
  3821. ?333333303
  3822. 03003
  3823. 033303333333333332
  3824. ?333333303
  3825. 333333333332
  3826. ?333333303
  3827. 33333333333
  3828. 333333333332
  3829. ?333333303
  3830. 333333333
  3831. 333333333332
  3832. ?33333330333333333330
  3833. 3333333333332
  3834. ?3333333333333333333333333333333332
  3835. ?3333333333333333333333333333333332
  3836. ?3333333333333333333333333333333332
  3837. ?3333333333333333333333333333333332
  3838. ?3333333333333333333333333333333332
  3839. ?3333333333333333333333333333333332
  3840. ?33333330303
  3841. 3333333333332
  3842. ?333333303
  3843. 03003
  3844. 3333333333332
  3845. ?333333303
  3846. 03303
  3847. 3333333333332
  3848. ?333333303
  3849. 3333333333332
  3850. ?333333303
  3851. 03003
  3852. 3333333333332
  3853. ?333333303
  3854. 3333333333332
  3855. ?333333303
  3856. 3333333333
  3857. 3333333333332
  3858. ?333333303
  3859. 333333333
  3860. 3333333333332
  3861. ?33333330333333333333
  3862. 3333333333332
  3863. ?3333333333333333333333333333333332
  3864. ?3333333333333333333333333333333332
  3865. ?3333333333333333333333333333333332
  3866. 33333333333333333333333333333333333
  3867. DDw83
  3868. 8DDw80
  3869. 8DDw8
  3870. DDw83
  3871. 8DDw83
  3872. 8DDw80
  3873. 8DDw8
  3874. 8DDw8
  3875. 8DDw83
  3876. wwwDDwwwww
  3877. wwwDDwwwww
  3878. DDDDDDDDDDw
  3879. DDDDDDDDDDw
  3880. DDDDDDDDDDw
  3881. DDDDDDDDDD
  3882. DDDDDDDDDD
  3883. wwwDDwwwww
  3884. wwwDDwwwww
  3885. LDDDDDDDDDDw
  3886. LDDDDDDDDDDw
  3887. LDDDDDDDDDDw
  3888. LDDDDDDDDDD
  3889. LDDDDDDDDDD
  3890. wwwwwwwww
  3891. {{{{p
  3892. main.prg
  3893. d:\temp\
  3894. main.fxp
  3895. fox.bmp
  3896. fox.msk
  3897. forms\graphics\
  3898. arw08up.bmp
  3899. arw08dn.bmp
  3900. ..\classes\
  3901. dragmove.cur
  3902. nodrop01.cur
  3903. cancel.bmp
  3904. clock.bmp
  3905. help.bmp
  3906. moverbox.bmp
  3907. next.bmp
  3908. ok.bmp
  3909. shaper.bmp
  3910. watch.bmp
  3911. cancel.msk
  3912. help.msk
  3913. next.msk
  3914. ok.msk
  3915. solution.scx
  3916. solution.sct
  3917. menus\
  3918. red.bmp
  3919. green.bmp
  3920. blue.bmp
  3921. white.bmp
  3922. white.msk
  3923. pinout.bmp
  3924. pinin.bmp
  3925. bts.bmp
  3926. bts.msk
  3927. solution.hlp
  3928. solution.cnt
  3929. preview.bmp
  3930. check.bmp
  3931. item1.bmp
  3932. item2.bmp
  3933. item3.bmp
  3934. item4.bmp
  3935. item5.bmp
  3936. reports\
  3937. logo.bmp
  3938. smmail.bmp
  3939. forms\
  3940. screen.bmp
  3941. forms\
  3942. toolbar1.bmp
  3943. forms\
  3944. menus.bmp
  3945. volume01.ico
  3946.