home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 22 / CD_ASCQ_22_0695.iso / win / prg / ptcm10 / sample / 1.cmx next >
Text File  |  1995-02-25  |  7KB  |  183 lines

  1. "Power Toolz Code Manager snippet samples."
  2. " ■0.00■Misc VB routines used to demonstrate the features in PTCM.■Chris Haynes■1099 Mason Rd.■Ashby■MA■01431■ 1■This is a sample PTCM library.    ■ 4■SAMPLE.BMP■SAMPLE.HLP"
  3. ""
  4. " Centerform routine.  Used to center a form on the screen."
  5.   '+-------------------------------------------------|PT AutoDoc|-------+
  6. '|                                                                    |
  7. '|Name: centerform                Revision: 1.00     Date: 12-29-1994 |
  8. '|                                                                    |
  9. '|Author: Chris Haynes                                                |
  10. '|                                                                    |
  11. '|Operation: Used to center the specified form on the screen.         |
  12. '|                                                                    |
  13. '|Parameters Passed:                                                  |
  14. '|     f As Form: Form to center on the screen.                       |
  15. '|                                                                    |
  16. '|                                                                    |
  17. '|              Copyright (C) 1994, All Rights Reserved               |
  18. '+--------------------------------------------------------------------+
  19. '
  20. Sub centerform (f As Form)
  21.  Sw% = screen.Width
  22.  Sh% = screen.Height
  23.  f.Top = (Sh% \ 2) - (f.Height \ 2)
  24.  f.Left = (Sw% \ 2) - (f.Width \ 2)
  25. End Sub
  26.  
  27. " Input_box routine.  Used as a replacement for inputbox.                              >>Form=INBOX.FRM"
  28.   '+-------------------------------------------------|PT AutoDoc|-------+
  29. '|                                                                    |
  30. '|Name: input_box                Revision: 1.00     Date: 12-29-1994  |
  31. '|                                                                    |
  32. '|Author: Chris Haynes                                                |
  33. '|                                                                    |
  34. '|Operation: Used to load the inbox form, used as an alternitive to in|
  35. '|                                                                    |
  36. '|Parameters Passed:                                                  |
  37. '|     message As String: The message to display in the input box (use|
  38. '|                                                                    |
  39. '| Return value: A string containing text typed by the user.          |
  40. '|                                                                    |
  41. '|              Copyright (C) 1994, All Rights Reserved               |
  42. '+--------------------------------------------------------------------+
  43. '
  44. Function input_box (message As String)
  45.  Load inbox
  46.  inbox.Tag = message
  47.  inbox.Show 1
  48.  input_box = inbox.Tag
  49.  Unload inbox
  50.  Set inbox = Nothing
  51. End Function
  52.  
  53. " MakeCtrl3D, used to make a normal text box 3D."
  54.   '---------------------------------------------------------------------
  55. 'Routine Name: makectrl3d    Written: 6/2/94    Author: Chris Haynes
  56. '
  57. 'Purpose: Used to give textboxes, listboxes, dir & file boxes a 3D effect.
  58. '         set autoredraw to true before calling this routine.
  59. '
  60. 'Parameters:    Control name
  61. '               Form name
  62. '
  63. 'API Declarations: none
  64. '
  65. 'Data Structures: none
  66. '
  67. 'Constants: none
  68. '
  69. '   Copyright 1994,  Chris Haynes   [Unauthorized use prohibited]
  70. '---------------------------------------------------------------------
  71. Sub makectrl3d (c As Control, f As Form)
  72. f.ScaleMode = 3         '----- Scale in Pixels
  73. f.ForeColor = &H0       '----- black
  74.  
  75. '----- Initialize main variables
  76. x% = c.Left - 1
  77. y% = c.Top - 1
  78. w% = c.Width + x%
  79. h% = c.Height + y%
  80.  
  81. '----- black lines on top and left size
  82. f.Line (x%, h%)-(x%, y%)
  83. f.Line (x%, y%)-(w% + 1, y%)
  84.  
  85. '----- dk grey top bevel
  86. f.ForeColor = &H808080
  87. f.Line (x% - 1, h% + 2)-(x% - 1, y% - 1)
  88. f.Line -(w% + 3, y% - 1)
  89.  
  90. '----- white lines on bottom
  91. f.ForeColor = &HFFFFFF
  92. f.Line (x%, h% + 2)-(w% + 2, h% + 2)
  93. f.Line -(w% + 2, y% - 1)
  94.  
  95. End Sub
  96.  
  97. " MakeLabel3D, used to make normal labels 3D."
  98.   '---------------------------------------------------------------------
  99. 'Routine Name: MakeLabel3D  Written: 6/8/94     Author: Chris Haynes
  100. '
  101. 'Purpose: Add a 3D border to a label
  102. '
  103. 'Parameters: form and control names.  Bevelwidth in pixels. style 0 = raised
  104. '                                                                 1 = sunken
  105. '
  106. 'API Declarations: none
  107. '
  108. 'Data Structures: none
  109. '
  110. 'Constants: none
  111. '
  112. '   Copyright 1994,  Chris Haynes   [Unauthorized use prohibited]
  113. '---------------------------------------------------------------------
  114. Sub makelabel3d (f As Form, c As Control, bevelwidth As Integer, pstyle As Integer)
  115. f.ScaleMode = 3         'scale in pixels
  116.  
  117. Dim ptop As Integer
  118. Dim pleft As Integer
  119. Dim pwidth As Integer
  120. Dim pheight As Integer
  121.  
  122. ptop = c.Top - bevelwidth
  123. pleft = c.Left - bevelwidth
  124. pwidth = c.Width + pleft + bevelwidth + bevelwidth
  125. pheight = c.Height + ptop + bevelwidth + bevelwidth
  126.  
  127. If pstyle = 0 Then
  128.  f.ForeColor = &HFFFFFF  ' white color
  129. Else
  130.  f.ForeColor = &H808080
  131. End If
  132. bevelwidth = bevelwidth - 1
  133. f.Line (pleft, ptop)-(pleft + bevelwidth, pheight), , BF
  134. f.Line (pleft, ptop)-(pwidth, bevelwidth + ptop), , BF
  135.  
  136. If pstyle = 0 Then
  137.  f.ForeColor = &H808080
  138. Else
  139.   f.ForeColor = &HFFFFFF
  140. End If
  141. f.DrawWidth = 1
  142.  
  143. '----- Draw bottom bevel
  144. x% = 0
  145. For l% = 0 To bevelwidth
  146.  f.Line (pleft + l%, pheight - x%)-(pwidth, pheight - x%)
  147.  x% = x% + 1
  148. Next l%
  149.  
  150. '----- Draw top bevel
  151. x% = 0
  152. For l% = 0 To bevelwidth
  153.  f.Line (pwidth - x%, l% + ptop)-(pwidth - x%, pheight + 1)
  154.  x% = x% + 1
  155. Next l%
  156.  
  157.  
  158. End Sub
  159.  
  160. " Drive_ready, used to see if specified disk drive is ready."
  161.   '+-------------------------------------------------|PT AutoDoc|-------+
  162. '|                                                                    |
  163. '|Name: drive_ready                Revision: 1.00     Date: 12-29-1994|
  164. '|                                                                    |
  165. '|Author: Chris Haynes                                                |
  166. '|                                                                    |
  167. '|Operation: Checks to see if specified drive is ready.               |
  168. '|                                                                    |
  169. '|Parameters Passed:                                                  |
  170. '|     diskdrive$: Drive letter to test for.                          |
  171. '|                                                                    |
  172. '| Return value: Returns true if the drive is ready and false if it is|
  173. '|                                                                    |
  174. '|              Copyright (C) 1994, All Rights Reserved               |
  175. '+--------------------------------------------------------------------+
  176. '
  177. Function drive_ready (diskdrive$)
  178. On Error Resume Next
  179.  x$ = Dir(diskdrive$ + ":\*.*", 16)
  180.   If Err Then drive_ready = False Else drive_ready = True
  181. End Function
  182.  
  183.