home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wg_lib / wglib101.bas < prev    next >
Encoding:
BASIC Source File  |  1995-10-23  |  4.3 KB  |  193 lines

  1. DefInt A-Z
  2.  
  3. ' Misc helpful VB routines that augment or make certain
  4. ' WGLib v 1.01 or VB calls easier
  5.  
  6. '
  7. ' Copyright (c) InfoSoft 1991, 1992
  8. ' ALl Rights Reserved
  9. '
  10.  
  11. ' CenterForm
  12. ' Passed a Form it will set it's Top and Left properties
  13. ' to that required to center the form on the display context
  14. ' Invoke after the form is loaded, but before shown.
  15. '
  16. ' CenterForm (Frm as Form)
  17.  
  18.  
  19. ' EmFXCalc
  20. ' passed a control that is to be Empressed or Embossed,
  21. ' it will calc the 'optimum' coords for the call.
  22. ' Since some controls control more area than they show
  23. ' (Pictures and frames mainly) and due to different DC's
  24. ' this is mainly a design tool to get a good starting point.
  25. '
  26. ' EmFXCalc(Ctl as Control)
  27.  
  28.  
  29. ' Like CenterForm, but only does the Horz centering
  30. ' CenterFrmH
  31.  
  32.  
  33. ' Like CenterForm, but only does the Vert centering
  34. ' CenterFrmVH
  35.  
  36.  
  37. ' CtlLabel
  38. ' Prints a label on the Form just to the left of a control.
  39. ' Using an actual VB Label Control just to print "Name:" and such
  40. ' wastes system resources, when we can easily print ON the form
  41. ' Uses current Form FG color
  42. '
  43. ' CtlLabel (Frm As Form, Ctl As Control, Text$)
  44. '
  45.  
  46. ' CtlLabelFX
  47. ' Prints a label on the Form to the left of a control, just
  48. ' like CtlLabel, but with a shading effect (some call it
  49. ' blurred).  Uses FormFG color for text, shades with white
  50. '
  51. ' CtlLabelFX (Frm As Form, Ctl As Control, Text$)
  52. '
  53.  
  54.  
  55. 'CtlLabelOvr
  56. ' Like CtlLabel but puts the label over the control, for
  57. ' those wider controls that come to close to the form edge.
  58. ' Note: this is designed for NON FX controls.  The use of
  59. ' ConCave or Convex Frm would require the text to be even
  60. ' further above the control
  61. '
  62. ' CtlLabelOvr (Frm As Form, Ctl As Control, Text$)
  63. '
  64.  
  65.  
  66. 'CtlLabelOvrFX
  67. ' Like CtlLabelOvr with the label over the control, but
  68. ' with FX.  Same cautions apply.
  69. '
  70. ' CtlLabelOvrFX (Frm As Form, Ctl As Control, Text$)
  71. '
  72.  
  73. Sub CenterForm (Frm As Form)
  74.     
  75.    ScrTall = Screen.Height
  76.    ScrWide = Screen.Width
  77.  
  78.    FrmTall = Frm.Height
  79.    FrmWide = Frm.Width
  80.  
  81.    Frm.Top = (ScrTall - FrmTall) \ 2
  82.    Frm.Left = (ScrWide - FrmWide) \ 2
  83.  
  84.  
  85. End Sub
  86.  
  87. Sub CenterFrmH (Frm As Form)
  88.    
  89.    ScrWide = Screen.Width
  90.  
  91.    FrmWide = Frm.Width
  92.  
  93.    Frm.Left = (ScrWide - FrmWide) \ 2
  94.  
  95. End Sub
  96.  
  97. Sub CenterFrmV (Frm As Form)
  98.    
  99.    ScrTall = Screen.Height
  100.  
  101.    FrmTall = Frm.Height
  102.  
  103.    Frm.Top = (ScrTall - FrmTall) \ 2
  104.  
  105. End Sub
  106.  
  107. Sub CtlLabel (Frm As Form, Ctl As Control, Text$)
  108.    
  109.    ' center text in realm of adjacent control
  110.    L = Ctl.Left - (Frm.TextWidth(Text$) + 15)
  111.    T = Ctl.Top + (Frm.TextHeight(Text$) \ 2)
  112.  
  113.    Frm.CurrentY = T
  114.    Frm.CurrentX = L
  115.    Frm.Print Text$;
  116.  
  117. End Sub
  118.  
  119. Sub CtlLabelFX (Frm As Form, Ctl As Control, Text$)
  120.  
  121.    ' center text in realm of adjacent control
  122.    L = Ctl.Left - (Frm.TextWidth(Text$) + 15)
  123.    T = Ctl.Top + (Frm.TextHeight(Text$) \ 2)
  124.    OldClr& = Frm.ForeColor
  125.  
  126.    ' print in white 15 is min increment for most
  127.    Frm.ForeColor = &HFFFFFF
  128.    Frm.CurrentY = T
  129.  
  130.    ' the next line adds shadow below as well.
  131.    'Frm.CurrentY = T + 15
  132.  
  133.    Frm.CurrentX = L + 15
  134.    Frm.Print Text$;
  135.  
  136.    'Print in ???
  137.    Frm.ForeColor = OldClr&
  138.    Frm.CurrentY = T
  139.    Frm.CurrentX = L
  140.    Frm.Print Text$;
  141.  
  142. End Sub
  143.  
  144. Sub CtlLabelOvr (Frm As Form, Ctl As Control, Text$)
  145.    
  146.    ' center text in realm of adjacent control
  147.    L = Ctl.Left
  148.  
  149.    ' to allow for FX, increase 15 below to 45 or 6
  150.    ' depending on the Thickness factor (15 per increment)
  151.    T = Ctl.Top - (Frm.TextHeight(Text$) + 15)
  152.  
  153.    Frm.CurrentY = T
  154.    Frm.CurrentX = L
  155.    Frm.Print Text$;
  156.    
  157. End Sub
  158.  
  159. Sub CtlLabelOvrFX (Frm As Form, Ctl As Control, Text$)
  160.    
  161.    ' center text in realm of adjacent control
  162.    L = Ctl.Left
  163.    T = Ctl.Top - (Frm.TextHeight(Text$))
  164.    OldClr& = Frm.ForeColor
  165.  
  166.    ' print in white 15 is min increment for most
  167.    Frm.ForeColor = &HFFFFFF
  168.    Frm.CurrentY = T
  169.  
  170.    ' the next line adds shadow below as well.
  171.    'Frm.CurrentY = T + 15
  172.  
  173.    Frm.CurrentX = L + 15
  174.    Frm.Print Text$;
  175.  
  176.    'Print in ???
  177.    Frm.ForeColor = OldClr&
  178.    Frm.CurrentY = T
  179.    Frm.CurrentX = L
  180.    Frm.Print Text$;
  181.    
  182. End Sub
  183.  
  184. Sub EmFXCalc (Ctl As Control, T%, L%, B%, R%)
  185.     
  186.     T = Ctl.Top - 15
  187.     L = Ctl.Left - 15
  188.     B = T + Ctl.Height + 15
  189.     R = L + Ctl.Width + 15
  190.  
  191. End Sub
  192.  
  193.