home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / activex / demos / oletrial / samples / vb / mhfram / fmh3dfra.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-11-28  |  18.0 KB  |  518 lines

  1. VERSION 4.00
  2. Begin VB.Form fMh3dFrame 
  3.    Caption         =   "Mh3dFrame Example"
  4.    ClientHeight    =   3636
  5.    ClientLeft      =   1956
  6.    ClientTop       =   3132
  7.    ClientWidth     =   4116
  8.    Height          =   4236
  9.    Left            =   1908
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3636
  12.    ScaleWidth      =   4116
  13.    Top             =   2580
  14.    Width           =   4212
  15.    Begin VB.PictureBox Picture1 
  16.       Height          =   495
  17.       Left            =   4320
  18.       Picture         =   "fMh3dFra.frx":0000
  19.       ScaleHeight     =   444
  20.       ScaleWidth      =   444
  21.       TabIndex        =   3
  22.       Top             =   120
  23.       Width           =   495
  24.    End
  25.    Begin VB.CommandButton cmdIncreasePercent 
  26.       Caption         =   "Command1"
  27.       Height          =   615
  28.       Left            =   2160
  29.       TabIndex        =   1
  30.       Top             =   2880
  31.       Width           =   1815
  32.    End
  33.    Begin VB.CommandButton cmdDecreasePercent 
  34.       Caption         =   "Command1"
  35.       Height          =   615
  36.       Left            =   120
  37.       TabIndex        =   0
  38.       Top             =   2880
  39.       Width           =   1815
  40.    End
  41.    Begin Mh3dfrmLibCtl.Mh3dFrame Mh3dFrame1 
  42.       Height          =   2652
  43.       Left            =   120
  44.       TabIndex        =   4
  45.       Top             =   120
  46.       Width           =   3852
  47.       _Version        =   65536
  48.       _ExtentX        =   6800
  49.       _ExtentY        =   4683
  50.       _StockProps     =   77
  51.       TintColor       =   16711935
  52.       Alignment       =   0
  53.       AutoSize        =   0   'False
  54.       BevelSize       =   0
  55.       BevelStyle      =   0
  56.       BorderColor     =   -2147483642
  57.       BorderStyle     =   1
  58.       FillColor       =   -2147483633
  59.       FontStyle       =   0
  60.       FontTransparent =   0   'False
  61.       LightColor      =   -2147483643
  62.       ShadowColor     =   -2147483632
  63.       TextColor       =   -2147483640
  64.       WallPaper       =   0
  65.       Picture         =   "fMh3dFra.frx":0282
  66.       NoPrefix        =   0   'False
  67.       FormatString    =   ""
  68.       Caption         =   "Mh3dFrame1"
  69.       Begin Mh3dlblLib.Mh3dLabel lblXplain 
  70.          Height          =   1572
  71.          Left            =   600
  72.          TabIndex        =   5
  73.          Top             =   600
  74.          Width           =   2652
  75.          _Version        =   65536
  76.          _ExtentX        =   4683
  77.          _ExtentY        =   2778
  78.          _StockProps     =   77
  79.          TintColor       =   16711935
  80.          Caption         =   "Mh3dLabel1"
  81.          Alignment       =   0
  82.          BevelSize       =   1
  83.          BorderColor     =   0
  84.          BorderStyle     =   0
  85.          LightColor      =   8421504
  86.          ShadowColor     =   16777215
  87.          TextColor       =   0
  88.          Picture         =   "fMh3dFra.frx":029E
  89.          VAlignment      =   0
  90.       End
  91.    End
  92.    Begin MhcommdlLib.MhCommonDialog Mhcommdl1 
  93.       Height          =   336
  94.       Left            =   0
  95.       TabIndex        =   2
  96.       Top             =   0
  97.       Width           =   336
  98.       _Version        =   65536
  99.       _ExtentX        =   593
  100.       _ExtentY        =   593
  101.       _StockProps     =   4
  102.       TintColor       =   16711935
  103.       Filename        =   ""
  104.       DialogTop       =   0
  105.       DialogLeft      =   0
  106.       DialogWidth     =   0
  107.       DialogHeight    =   0
  108.       InitDir         =   ""
  109.       Filter          =   ""
  110.       DefaultExt      =   ""
  111.       DialogTitle     =   ""
  112.       FilterIndex     =   0
  113.       Flags           =   0
  114.       CancelError     =   0   'False
  115.       MaxFileSize     =   256
  116.       Color           =   0
  117.       Max             =   0
  118.       Min             =   0
  119.       Copies          =   0
  120.       FromPage        =   0
  121.       PrinterDefault  =   -1  'True
  122.       ToPage          =   0
  123.       HelpCommand     =   0
  124.       HelpContext     =   0
  125.       HelpFile        =   ""
  126.       HelpKey         =   ""
  127.    End
  128.    Begin VB.Menu mnuFile 
  129.       Caption         =   "&File"
  130.       Begin VB.Menu itmExit 
  131.          Caption         =   "E&xit"
  132.       End
  133.    End
  134.    Begin VB.Menu mnuOptions 
  135.       Caption         =   "&Options"
  136.       Begin VB.Menu itmAlignment 
  137.          Caption         =   "&Alignment"
  138.          Begin VB.Menu itmAlign 
  139.             Caption         =   "&Left"
  140.             Checked         =   -1  'True
  141.             Index           =   0
  142.          End
  143.          Begin VB.Menu itmAlign 
  144.             Caption         =   "&Right"
  145.             Index           =   1
  146.          End
  147.          Begin VB.Menu itmAlign 
  148.             Caption         =   "&Center"
  149.             Index           =   2
  150.          End
  151.       End
  152.       Begin VB.Menu itmBevelStyle 
  153.          Caption         =   "&BevelStyle"
  154.          Begin VB.Menu itmBevels 
  155.             Caption         =   "&Lowered"
  156.             Checked         =   -1  'True
  157.             Index           =   0
  158.          End
  159.          Begin VB.Menu itmBevels 
  160.             Caption         =   "&Raised"
  161.             Index           =   1
  162.          End
  163.          Begin VB.Menu itmBevels 
  164.             Caption         =   "&Chiseled"
  165.             Index           =   2
  166.          End
  167.          Begin VB.Menu itmBevels 
  168.             Caption         =   "Shadow Righ&t"
  169.             Index           =   3
  170.          End
  171.          Begin VB.Menu itmBevels 
  172.             Caption         =   "Shadow &Left"
  173.             Index           =   4
  174.          End
  175.       End
  176.       Begin VB.Menu itmBorderStyle 
  177.          Caption         =   "Border&Style"
  178.          Begin VB.Menu itmBorders 
  179.             Caption         =   "&None"
  180.             Index           =   0
  181.          End
  182.          Begin VB.Menu itmBorders 
  183.             Caption         =   "&Single Line"
  184.             Checked         =   -1  'True
  185.             Index           =   1
  186.          End
  187.          Begin VB.Menu itmBorders 
  188.             Caption         =   "Single Line with &Rounded Corners"
  189.             Index           =   2
  190.          End
  191.       End
  192.    End
  193.    Begin VB.Menu mnuColors 
  194.       Caption         =   "&Colors"
  195.       Begin VB.Menu itmColor 
  196.          Caption         =   "&BorderColor"
  197.          Index           =   0
  198.       End
  199.       Begin VB.Menu itmColor 
  200.          Caption         =   "&FillColor"
  201.          Index           =   1
  202.       End
  203.       Begin VB.Menu itmColor 
  204.          Caption         =   "&LightColor"
  205.          Index           =   2
  206.       End
  207.       Begin VB.Menu itmColor 
  208.          Caption         =   "&ShadowColor"
  209.          Index           =   3
  210.       End
  211.       Begin VB.Menu itmColor 
  212.          Caption         =   "&TextColor"
  213.          Index           =   4
  214.       End
  215.    End
  216.    Begin VB.Menu mnuPictures 
  217.       Caption         =   "&Pictures"
  218.       Begin VB.Menu itmPix 
  219.          Caption         =   "&None"
  220.          Checked         =   -1  'True
  221.          Index           =   0
  222.       End
  223.       Begin VB.Menu itmPix 
  224.          Caption         =   "&Stretch picture to fit frame"
  225.          Index           =   1
  226.       End
  227.       Begin VB.Menu itmPix 
  228.          Caption         =   "&Maintain picture's original size"
  229.          Index           =   2
  230.       End
  231.       Begin VB.Menu itmPix 
  232.          Caption         =   "&Replicate picture"
  233.          Index           =   3
  234.       End
  235.    End
  236. Attribute VB_Name = "fMh3dFrame"
  237. Attribute VB_Creatable = False
  238. Attribute VB_Exposed = False
  239. Option Explicit
  240. Dim imDown As Integer
  241. Const im_TRUE = -1, im_FALSE = 0
  242. Const im_LEFT = 0, im_TOP = 0, im_RIGHT = 1, im_BOTTOM = 1, im_CENTER = 2
  243. Const im_BORDERCOLOR = 0, im_FILLCOLOR = 1, im_LIGHTCOLOR = 2, im_SHADOWCOLOR = 3, im_TEXTCOLOR = 4
  244. Const im_NONE = 0, im_SINGLE = 1, im_ROUNDED = 2
  245. Const im_LOWERED = 0, im_RAISED = 1, im_CHISELED = 2, im_SHADOWLEFT = 3, im_SHADOWRIGHT = 4
  246. Const im_STRETCH = 1, im_ATSIZE = 2, im_REPLICATE = 3
  247. Const im_LEAD = 0, im_ALIGN = 1, im_BEVEL = 2, im_COLOR = 3
  248. Const im_GRAY = &HC0C0C0
  249. Const im_BLACK = &H0&
  250. Const im_DARK_GRAY = &H808080
  251. Const im_WHITE = &HFFFFFF
  252. Const CC_PREVENTFULLOPEN = &H4&
  253. Sub cmdDecreasePercent_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  254. 'Allows for continuous decrease of the value of example control.
  255. 'Routine checks to make sure button is down, then it sets
  256. 'flag variable so we know when user quits pressing button
  257. 'Then it decreases value until limit reached or user quits
  258. 'Do loop and DoEvents keep things going
  259. 'Flag to quit thrown again in _MouseUp event
  260.     'If user is pressing the mouse button, set flag and do case
  261.     If Button Then
  262.         imDown = im_TRUE
  263.         'if there's already no discernable bevel, quit routine
  264.         If Mh3dFrame1.BevelSize < 0 Then
  265.             Exit Sub
  266.         End If
  267.         'Otherwise, reduce the bevel
  268.        Do While imDown And Mh3dFrame1.BevelSize - 1 >= 0
  269.             Mh3dFrame1.BevelSize = Mh3dFrame1.BevelSize - 1
  270.             DoEvents
  271.        Loop
  272.     End If
  273. End Sub
  274. Sub cmdDecreasePercent_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  275. 'Sets flag when user quits pressing button
  276.     imDown = im_FALSE
  277. End Sub
  278. Sub cmdIncreasePercent_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  279. 'Allows for continuous decrease of the value of example control.
  280. 'Routine checks to make sure button is down, then it sets
  281. 'flag variable so we know when user quits pressing button
  282. 'Then it decreases value until limit reached or user quits
  283. 'Do loop and DoEvents keep things going
  284. 'Flag to quit thrown again in _MouseUp event
  285.     'If user is pressing the mouse button, set flag and do case
  286.     If Button Then
  287.         imDown = im_TRUE
  288.         'if there's already no discernable bevel, quit routine
  289.         If Mh3dFrame1.BevelSize > 30 Then
  290.             Exit Sub
  291.         End If
  292.         'Otherwise, reduce the bevel
  293.         Do
  294.             Mh3dFrame1.BevelSize = Mh3dFrame1.BevelSize + 1
  295.             DoEvents
  296.        Loop While imDown And Mh3dFrame1.BevelSize < 30
  297.     End If
  298. End Sub
  299. Sub cmdIncreasePercent_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  300. 'Sets flag when user quits pressing button
  301.     imDown = im_FALSE
  302. End Sub
  303. Sub Form_Activate()
  304. 'Set focus for startup
  305.     cmdIncreasePercent.SetFocus
  306. End Sub
  307. Sub Form_Load()
  308. 'Because this is an example, we're setting all properties,
  309. 'execpt designtime-only properties such as the control name,
  310. 'through code.
  311.     'Set Mh3dFrame1 properties
  312.     Mh3dFrame1.FontTransparent = True
  313.     Mh3dFrame1.BevelSize = 1
  314.     Mh3dFrame1.AutoSize = False
  315.     'Set command button properties
  316.     cmdDecreasePercent.Caption = "Decrease Bevel"
  317.     cmdIncreasePercent.Caption = "Increase Bevel"
  318.     'Set Xplain properties
  319.     lblXplain.BevelSize = 0
  320.     lblXplain.BackColor = &HC0C0C0
  321.     lblXplain.MultiLine = True
  322.     lblXplain.BorderStyle = im_NONE
  323.     lblXplain.Caption = Xplain(im_LEAD)
  324.     ' center form to screen
  325.     Move Abs(Screen.Width - Width) \ 2, Abs(Screen.Height - Height) \ 2
  326. End Sub
  327. Sub itmAlign_Click(index As Integer)
  328. 'The control's horizontal alignment can be justified
  329. 'left, right and centered.
  330.     Dim iIndex As Integer
  331.     'Turn checks off
  332.     For iIndex = 0 To 2
  333.         itmAlign(iIndex).Checked = False
  334.     Next
  335.     'Make choice and set check
  336.     Select Case index
  337.         Case im_LEFT
  338.             Mh3dFrame1.Alignment = index
  339.             itmAlign(index).Checked = True
  340.         Case im_RIGHT
  341.             Mh3dFrame1.Alignment = index
  342.             itmAlign(index).Checked = True
  343.         Case im_CENTER
  344.             Mh3dFrame1.Alignment = index
  345.             itmAlign(index).Checked = True
  346.     End Select
  347.     lblXplain.Caption = Xplain(im_ALIGN)
  348. End Sub
  349. Sub itmBevels_Click(index As Integer)
  350. 'Routine picks bevel style for control
  351.     Dim iIndex As Integer
  352.     'if Bevelsize = 0, there's nothing else to set
  353.     'so we tell the user and then exit
  354.     If Mh3dFrame1.BevelSize = 0 Then
  355.         MsgBox "You must set .BevelSize to something other than zero for this property to have any effect.", 16, "MicroHelp"
  356.         Exit Sub
  357.     End If
  358.     'Turn all the checks off
  359.     For iIndex = 0 To 4
  360.         itmBevels(iIndex).Checked = False
  361.     Next
  362.     'Change style and check appropriate menu item
  363.     Select Case index
  364.         Case im_LOWERED
  365.             Mh3dFrame1.BevelStyle = index
  366.             itmBevels(index).Checked = True
  367.         Case im_RAISED
  368.             Mh3dFrame1.BevelStyle = index
  369.             itmBevels(index).Checked = True
  370.         Case im_CHISELED
  371.             Mh3dFrame1.BevelStyle = index
  372.             itmBevels(index).Checked = True
  373.         Case im_SHADOWLEFT
  374.             Mh3dFrame1.BevelStyle = index
  375.             itmBevels(index).Checked = True
  376.         Case im_SHADOWRIGHT
  377.             Mh3dFrame1.BevelStyle = index
  378.             itmBevels(index).Checked = True
  379.     End Select
  380.     lblXplain.Caption = Xplain(im_BEVEL)
  381. End Sub
  382. Sub itmBorders_Click(index As Integer)
  383. 'Sets border size for control
  384.     Dim iIndex As Integer
  385.     'Turn checks off
  386.     For iIndex = 0 To 2
  387.         itmBorders(iIndex).Checked = False
  388.     Next
  389.     'Makes selection and set appropriate check
  390.     Select Case index
  391.         Case im_NONE
  392.             Mh3dFrame1.BorderStyle = index
  393.             itmBorders(index).Checked = True
  394.         Case im_SINGLE
  395.             Mh3dFrame1.BorderStyle = index
  396.             itmBorders(index).Checked = True
  397.         Case im_ROUNDED
  398.             Mh3dFrame1.BorderStyle = index
  399.             itmBorders(index).Checked = True
  400.     End Select
  401.     lblXplain.Caption = Xplain(im_LEAD)
  402. End Sub
  403. Sub itmColor_Click(index As Integer)
  404. 'Routine calls up common color dialog so we can
  405. 'illustrate the color properties of the control.
  406. 'Note that we don't set .ForeColor or .BackColor
  407. 'even though they appear in the properties list.
  408. 'Changing them can cause bizarre color display and
  409. 'some controls may behave strangely. Leave those
  410. 'properties at their defaults
  411.     If index = 0 And Mh3dFrame1.BorderStyle = im_NONE Then
  412.         MsgBox "You must set Border Style to something other than none for this property to have any effect.", 16, "MicroHelp"
  413.         Exit Sub
  414.     End If
  415.     'Sets flag to prevent custom color palette from
  416.     'appearing, calls dialog and sets appropriate
  417.     'color property when dialog closes.
  418.     MhCommdl1.Flags = CC_PREVENTFULLOPEN
  419.     MhCommdl1.CancelError = True
  420.     On Error GoTo ColorError
  421.     MhCommdl1.Action = 3
  422.     Select Case index
  423.         Case im_BORDERCOLOR
  424.             Mh3dFrame1.BorderColor = MhCommdl1.Color
  425.         Case im_FILLCOLOR
  426.             Mh3dFrame1.FillColor = MhCommdl1.Color
  427.         Case im_LIGHTCOLOR
  428.             Mh3dFrame1.LightColor = MhCommdl1.Color
  429.         Case im_SHADOWCOLOR
  430.             Mh3dFrame1.ShadowColor = MhCommdl1.Color
  431.         Case im_TEXTCOLOR
  432.             Mh3dFrame1.TextColor = MhCommdl1.Color
  433.     End Select
  434.     lblXplain.Caption = Xplain(im_COLOR)
  435.     lblXplain.FillColor = Mh3dFrame1.FillColor
  436. Exit Sub
  437. ColorError:
  438.     Select Case index
  439.         Case im_BORDERCOLOR
  440.             Mh3dFrame1.BorderColor = im_BLACK
  441.         Case im_FILLCOLOR
  442.             Mh3dFrame1.FillColor = im_GRAY
  443.         Case im_LIGHTCOLOR
  444.             Mh3dFrame1.LightColor = im_WHITE
  445.         Case im_SHADOWCOLOR
  446.             Mh3dFrame1.ShadowColor = im_DARK_GRAY
  447.         Case im_TEXTCOLOR
  448.             Mh3dFrame1.TextColor = im_BLACK
  449.     End Select
  450.     Exit Sub
  451. End Sub
  452. Sub itmExit_Click()
  453. 'Dump form and end program
  454.     Unload fMh3dFrame
  455.     End
  456. End Sub
  457. Sub itmPix_Click(index As Integer)
  458. 'This routine places a picture in the frame area.
  459.     Dim iIndex As Integer
  460.     'Turn checks off
  461.     For iIndex = 0 To 3
  462.         itmPix(iIndex).Checked = False
  463.     Next
  464.     'Hide explanation label
  465.     lblXplain.Visible = False
  466.     'Place picture and check menu item
  467.     Select Case index
  468.         Case im_NONE
  469.             Mh3dFrame1.Picture = LoadPicture("")
  470.             itmPix(index).Checked = True
  471.             lblXplain.Visible = True
  472.         Case im_ATSIZE
  473.             Mh3dFrame1.Picture = Picture1.Picture
  474.             Mh3dFrame1.WallPaper = index - 1
  475.             itmPix(index).Checked = True
  476.         Case im_STRETCH
  477.             Mh3dFrame1.Picture = Picture1.Picture
  478.             Mh3dFrame1.WallPaper = index - 1
  479.             itmPix(index).Checked = True
  480.         Case im_REPLICATE
  481.             Mh3dFrame1.Picture = Picture1.Picture
  482.             Mh3dFrame1.WallPaper = index - 1
  483.             itmPix(index).Checked = True
  484.      End Select
  485. End Sub
  486. Sub mnuColors_Click()
  487. 'Show xplanation label if it's hidden
  488.     ShowXplain
  489. End Sub
  490. Sub mnuFile_Click()
  491. 'Show xplanation label if it's hidden
  492.     ShowXplain
  493. End Sub
  494. Sub mnuOptions_Click()
  495. 'Show xplanation label if it's hidden
  496.     ShowXplain
  497. End Sub
  498. Sub ShowXplain()
  499. 'Show explanation label if hidden
  500. 'and hide the picture
  501.     If lblXplain.Visible = False Then
  502.         Mh3dFrame1.Picture = LoadPicture("")
  503.         lblXplain.Visible = True
  504.     End If
  505. End Sub
  506. Function Xplain(choice As Integer)
  507.     Select Case choice
  508.         Case im_LEAD
  509.             Xplain = "MicroHelp's Mh3DFrame offers all the features of the Visual Basic frame plus added abilities that allow you to bind the frame to the database, provide a three-dimensional appearance to your application and control all other aspects of the control's appearance."
  510.         Case im_ALIGN
  511.             Xplain = "You can dynamically position the caption for the frame or even do away with it altogether. You also have complete control over the font style and characteristics of the caption."
  512.         Case im_BEVEL
  513.             Xplain = "Mh3DFrame gives the program a choice of five different bevel styles (as well as no bevel at all). You can alter the bevel at runtime if needed and control the colors of the pieces of the bevel as well."
  514.         Case im_COLOR
  515.             Xplain = "MicroHelp gives you total control over the colors of the Mh3DFrame. You can create traditional bevel effects or get as wild with your colors as you like. Even the color of the text can be highlighted"
  516.     End Select
  517. End Function
  518.