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