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 / samples4 / ch20 / tstrect.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1997-02-17  |  4.3 KB  |  127 lines

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