home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch20 / tstrect.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1997-02-17  |  4.2 KB  |  124 lines

  1. VERSION 5.00
  2. Begin VB.Form frmTest 
  3.    Caption         =   "Chapter 20 Examples"
  4.    ClientHeight    =   2835
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   4485
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   2835
  11.    ScaleWidth      =   4485
  12.    Begin VB.CommandButton Command5 
  13.       Caption         =   "dwDeviceContext"
  14.       Height          =   495
  15.       Left            =   420
  16.       TabIndex        =   4
  17.       Top             =   2220
  18.       Width           =   1695
  19.    End
  20.    Begin VB.CommandButton Command4 
  21.       Caption         =   "dwSystem"
  22.       Height          =   495
  23.       Left            =   420
  24.       TabIndex        =   3
  25.       Top             =   1680
  26.       Width           =   1035
  27.    End
  28.    Begin VB.CommandButton Command3 
  29.       Caption         =   "dwWindow"
  30.       Height          =   495
  31.       Left            =   420
  32.       TabIndex        =   2
  33.       Top             =   1140
  34.       Width           =   1035
  35.    End
  36.    Begin VB.CommandButton Command2 
  37.       Caption         =   "dwMetrics"
  38.       Height          =   495
  39.       Left            =   420
  40.       TabIndex        =   1
  41.       Top             =   600
  42.       Width           =   1035
  43.    End
  44.    Begin VB.CommandButton Command1 
  45.       Caption         =   "dwRECT"
  46.       Height          =   495
  47.       Left            =   420
  48.       TabIndex        =   0
  49.       Top             =   60
  50.       Width           =   1035
  51.    End
  52. Attribute VB_Name = "frmTest"
  53. Attribute VB_GlobalNameSpace = False
  54. Attribute VB_Creatable = False
  55. Attribute VB_PredeclaredId = True
  56. Attribute VB_Exposed = False
  57. Option Explicit
  58. ' Copyright (c) 1997 by Desaware.
  59. Private Sub Command1_Click()
  60.     Dim rc As New dwRECT
  61.     Dim rc2 As New dwRECT
  62.     Dim rc3 As New dwRECT
  63.     Dim pt As New dwPoint
  64.     rc.SetRect 5, 5, 10, 10
  65.     rc2.CopyRect rc
  66.     Debug.Print "rc2: " & rc2.left, rc2.Top, rc2.right, rc2.bottom
  67.     rc2.InflateRect 10, 10
  68.     Debug.Print "rc2: " & rc2.left, rc2.Top, rc2.right, rc2.bottom
  69.     rc3.IntersectRect rc, rc2
  70.     Debug.Print "rc3: " & rc3.left, rc3.Top, rc3.right, rc3.bottom
  71.     pt.x = 7
  72.     pt.y = 7
  73.     Debug.Print "pt in rect: " & rc3.PtInRect(pt)
  74.     pt.x = 1
  75.     Debug.Print "pt in rect: " & rc3.PtInRect(pt)
  76. End Sub
  77. Private Sub Command2_Click()
  78.     Dim sysobject As New dwSystem
  79.     MsgBox "Screen Resolution is: " & sysobject.Metrics.CXSCREEN & " X " & sysobject.Metrics.CYSCREEN
  80. End Sub
  81. Private Sub Command3_Click()
  82.     Dim window1 As New dwWindow
  83.     Dim window2 As New dwWindow
  84.     ' This is how you would set up an instance of the dwWindow class.
  85.     window1.hwnd = frmTest.hwnd
  86.     window2.hwnd = Command3.hwnd
  87.     ' Now you can perform actions on each window.
  88.     ' For example, you can move and resize the button with the line:
  89.     window2.MoveWindow 10, 10, 200, 100, True
  90.     ' no cleanup needed
  91. End Sub
  92. Private Sub Command4_Click()
  93.     Dim system1 As New dwSystem
  94.     Dim pnt As New dwPoint
  95.     Dim oldcolor&
  96.     ' no setup needed
  97.     ' Here is an example of how you would use a system class method.
  98.     ' This gets the current position of the mouse cursor (in pixels).
  99.     Set pnt = system1.GetCursorPos()
  100.     Debug.Print "Cusor Position: " & pnt.x, pnt.y
  101.     ' Here are examples of how you would use the sub objects.
  102.     ' This sets the caption bar of the active window to red.
  103.     oldcolor = system1.SysColor.ACTIVECAPTION
  104.     system1.SysColor.ACTIVECAPTION = &HFF&
  105.     MsgBox "Caption color changed"
  106.     system1.SysColor.ACTIVECAPTION = oldcolor
  107.     ' This gets the width of icons.
  108.     Debug.Print "Icon width: " & system1.Metrics.CXICON
  109.     ' no cleanup needed
  110. End Sub
  111. Private Sub Command5_Click()
  112.     Dim window1 As New dwWindow
  113.     Dim dContext1 As dwDeviceContext
  114.     Dim ClientRect As dwRECT
  115.     window1.hwnd = frmTest.hwnd
  116.     Set dContext1 = window1.GetDC()
  117.     ' You could also do this the other way around:
  118.     ' Set dContext1 = new dwDeviceContext
  119.     ' Call dContext.GetDC(window1)
  120.     Set ClientRect = window1.GetClientRect
  121.     dContext1.MoveTo MakePoint(0, 0)
  122.     dContext1.LineTo MakePoint(ClientRect.right, ClientRect.bottom)
  123. End Sub
  124.