home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / vbkontrol.exe / SDOC210.ZIP / SDSAMPLE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-02-04  |  2.3 KB  |  71 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Subdoc sample project"
  4.    Height          =   6510
  5.    KeyPreview      =   -1  'True
  6.    Left            =   1035
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   5820
  9.    ScaleWidth      =   7365
  10.    Top             =   1140
  11.    Width           =   7485
  12.    Begin Menu MStart 
  13.       Caption         =   "&Tile"
  14.    End
  15.    Begin Menu MFinish 
  16.       Caption         =   "&Finish"
  17.    End
  18. DefInt A-Z
  19. ''  This form doesn't do anything much - just a sample
  20. ''  of code for subdoc to show off with.
  21. ''  *** However try remming out the lines in MStart_Click
  22. ''      that take the loss of frame borders into account
  23. ''      and see what happens.
  24. Dim T() As TILE                    ' will contain tiles
  25. Sub MFinish_Click ()
  26.     End
  27. End Sub
  28. Sub MStart_Click ()
  29. ''  Start the sample application:-
  30. ''      ask for name, create tiles, compute form
  31. ''      dimensions then lay out tiles.
  32. ''  *** Interesting code modification in this procedure ***
  33. n$ = InputBox$("Please input a name", "", "Geoffrey")
  34. nc = Len(n$)
  35. fw = form1.Width        ' INCORRECT !!!!
  36. fh = form1.Height
  37. '   divide form EXACTLY into NC squares each way
  38. fw = form1.Width - lostframewidthintwips()
  39. fh = form1.Height - lostframeheightintwips(True)
  40. '   rem the preceeding two lines out and see what happens
  41. intvlx = fw / nc         ' intervals
  42. intvly = fh / nc
  43. form1.FontSize = Tilefontsize
  44. ReDim T(1 To nc, 1 To nc) As TILE
  45. For r = 1 To nc
  46.     For c = 1 To nc
  47.         T(r, c).top = (r - 1) * intvly
  48.         T(r, c).left = (c - 1) * intvlx
  49.         T(r, c).bottom = (r) * intvly
  50.         T(r, c).right = (c) * intvlx
  51.         T(r, c).letter = Mid$(n$, 1 + (r + c - 2) Mod nc, 1)
  52.         T(r, c).clr = QBColor(1 + ((r + c) Mod 15))
  53.         Call showtile(r, c)
  54.     Next c
  55. Next r
  56. End Sub
  57. Sub showtile (r, c)
  58. ''  Show the tile in the gloabl array T()
  59. ''  R and C are row and column indeces
  60. form1.DrawWidth = 1
  61. Dim ti As TILE
  62. ti = T(r, c)    ' current tile working var
  63. Line (ti.left, ti.top)-(ti.right, ti.bottom), ti.clr, BF
  64. Line (ti.left, ti.top)-(ti.right, ti.bottom), QBColor(0), B
  65. lw = form1.TextWidth(ti.letter)
  66. lh = form1.TextHeight(ti.letter)
  67. form1.CurrentX = (ti.left + ti.right - lw) / 2
  68. form1.CurrentY = (ti.top + ti.bottom - lh) / 2
  69. form1.Print ti.letter;
  70. End Sub
  71.