home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmTest
- Caption = "Chapter 20 Examples"
- ClientHeight = 2835
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 4485
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2835
- ScaleWidth = 4485
- Begin VB.CommandButton Command5
- Caption = "dwDeviceContext"
- Height = 495
- Left = 420
- TabIndex = 4
- Top = 2220
- Width = 1695
- End
- Begin VB.CommandButton Command4
- Caption = "dwSystem"
- Height = 495
- Left = 420
- TabIndex = 3
- Top = 1680
- Width = 1035
- End
- Begin VB.CommandButton Command3
- Caption = "dwWindow"
- Height = 495
- Left = 420
- TabIndex = 2
- Top = 1140
- Width = 1035
- End
- Begin VB.CommandButton Command2
- Caption = "dwMetrics"
- Height = 495
- Left = 420
- TabIndex = 1
- Top = 600
- Width = 1035
- End
- Begin VB.CommandButton Command1
- Caption = "dwRECT"
- Height = 495
- Left = 420
- TabIndex = 0
- Top = 60
- Width = 1035
- End
- Attribute VB_Name = "frmTest"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- ' Copyright (c) 1997 by Desaware.
- Private Sub Command1_Click()
- Dim rc As New dwRECT
- Dim rc2 As New dwRECT
- Dim rc3 As New dwRECT
- Dim pt As New dwPoint
- rc.SetRect 5, 5, 10, 10
- rc2.CopyRect rc
- Debug.Print "rc2: " & rc2.left, rc2.Top, rc2.right, rc2.bottom
- rc2.InflateRect 10, 10
- Debug.Print "rc2: " & rc2.left, rc2.Top, rc2.right, rc2.bottom
- rc3.IntersectRect rc, rc2
- Debug.Print "rc3: " & rc3.left, rc3.Top, rc3.right, rc3.bottom
- pt.x = 7
- pt.y = 7
- Debug.Print "pt in rect: " & rc3.PtInRect(pt)
- pt.x = 1
- Debug.Print "pt in rect: " & rc3.PtInRect(pt)
- End Sub
- Private Sub Command2_Click()
- Dim sysobject As New dwSystem
- MsgBox "Screen Resolution is: " & sysobject.Metrics.CXSCREEN & " X " & sysobject.Metrics.CYSCREEN
- End Sub
- Private Sub Command3_Click()
- Dim window1 As New dwWindow
- Dim window2 As New dwWindow
- ' This is how you would set up an instance of the dwWindow class.
- window1.hwnd = frmTest.hwnd
- window2.hwnd = Command3.hwnd
- ' Now you can perform actions on each window.
- ' For example, you can move and resize the button with the line:
- window2.MoveWindow 10, 10, 200, 100, True
- ' no cleanup needed
- End Sub
- Private Sub Command4_Click()
- Dim system1 As New dwSystem
- Dim pnt As New dwPoint
- Dim oldcolor&
- ' no setup needed
- ' Here is an example of how you would use a system class method.
- ' This gets the current position of the mouse cursor (in pixels).
- Set pnt = system1.GetCursorPos()
- Debug.Print "Cusor Position: " & pnt.x, pnt.y
- ' Here are examples of how you would use the sub objects.
- ' This sets the caption bar of the active window to red.
- oldcolor = system1.SysColor.ACTIVECAPTION
- system1.SysColor.ACTIVECAPTION = &HFF&
- MsgBox "Caption color changed"
- system1.SysColor.ACTIVECAPTION = oldcolor
- ' This gets the width of icons.
- Debug.Print "Icon width: " & system1.Metrics.CXICON
- ' no cleanup needed
- End Sub
- Private Sub Command5_Click()
- Dim window1 As New dwWindow
- Dim dContext1 As dwDeviceContext
- Dim ClientRect As dwRECT
- window1.hwnd = frmTest.hwnd
- Set dContext1 = window1.GetDC()
- ' You could also do this the other way around:
- ' Set dContext1 = new dwDeviceContext
- ' Call dContext.GetDC(window1)
- Set ClientRect = window1.GetClientRect
- dContext1.MoveTo MakePoint(0, 0)
- dContext1.LineTo MakePoint(ClientRect.right, ClientRect.bottom)
- End Sub
-