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 / ch08 / ex8a.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  5.8 KB  |  166 lines

  1. VERSION 4.00
  2. Begin VB.Form frmex8a 
  3.    Caption         =   "Additional Examples"
  4.    ClientHeight    =   3240
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   5685
  8.    Height          =   3645
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   216
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   379
  14.    Top             =   1170
  15.    Width           =   5805
  16.    Begin VB.CommandButton Command4 
  17.       Caption         =   "DrawFrameControl"
  18.       Height          =   375
  19.       Left            =   3780
  20.       TabIndex        =   4
  21.       Top             =   1260
  22.       Width           =   1755
  23.    End
  24.    Begin VB.CommandButton Command3 
  25.       Caption         =   "DrawEdge"
  26.       Height          =   375
  27.       Left            =   3780
  28.       TabIndex        =   3
  29.       Top             =   900
  30.       Width           =   1755
  31.    End
  32.    Begin VB.CommandButton Command2 
  33.       Caption         =   "Pattern Brush"
  34.       Height          =   375
  35.       Left            =   3780
  36.       TabIndex        =   2
  37.       Top             =   540
  38.       Width           =   1755
  39.    End
  40.    Begin VB.PictureBox Picture1 
  41.       Height          =   255
  42.       Left            =   5100
  43.       Picture         =   "EX8A.frx":0000
  44.       ScaleHeight     =   225
  45.       ScaleWidth      =   285
  46.       TabIndex        =   1
  47.       Top             =   2940
  48.       Width           =   315
  49.    End
  50.    Begin VB.CommandButton Command1 
  51.       Caption         =   "AngleArc"
  52.       Height          =   375
  53.       Left            =   3780
  54.       TabIndex        =   0
  55.       Top             =   180
  56.       Width           =   1755
  57.    End
  58. Attribute VB_Name = "frmex8a"
  59. Attribute VB_Creatable = False
  60. Attribute VB_Exposed = False
  61. Option Explicit
  62. ' Copyright 
  63.  1997 by Desaware Inc. All Rights Reserved
  64. Private Type POINTAPI
  65.     x As Long
  66.     y As Long
  67. End Type
  68. Private Type RECT
  69.         Left As Long
  70.         Top As Long
  71.         Right As Long
  72.         Bottom As Long
  73. End Type
  74. Private Declare Function AngleArc& Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal dwRadius As Long, ByVal eStartAngle As Single, ByVal eSweepAngle As Single)
  75. Private Declare Function MoveToEx Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
  76. Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
  77. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  78. Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
  79. Private Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  80. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  81. Private Declare Function DrawEdge& Lib "user32" (ByVal hDC As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long)
  82. Private Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
  83. Private Declare Function DrawFrameControl Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
  84. Const pi = 3.141578
  85. Private Const EDGE_BUMP = &H9&
  86. Private Const EDGE_ETCHED = &H6&
  87. Private Const EDGE_RAISED = &H5&
  88. Private Const EDGE_SUNKEN = &HA&
  89. Private Const BF_ADJUST = &H2000
  90. Private Const BF_BOTTOM = &H8
  91. Private Const BF_BOTTOMLEFT = &H9
  92. Private Const BF_BOTTOMRIGHT = &HC
  93. Private Const BF_DIAGONAL = &H10
  94. Private Const BF_FLAT = &H4000
  95. Private Const BF_LEFT = &H1
  96. Private Const BF_MIDDLE = &H800
  97. Private Const BF_MONO = &H8000
  98. Private Const BF_RECT = &HF
  99. Private Const BF_RIGHT = &H4
  100. Private Const BF_SOFT = &H1000
  101. Private Const BF_TOP = &H2
  102. Private Const BF_TOPLEFT = &H3
  103. Private Const BF_TOPRIGHT = &H6
  104. Private Const DFC_BUTTON = 4
  105. Private Const DFC_CAPTION = 1
  106. Private Const DFC_MENU = 2
  107. Private Const DFC_SCROLL = 3
  108. Private Const DFCS_BUTTON3STATE = &H8
  109. Private Const DFCS_BUTTONCHECK = &H0
  110. Private Const DFCS_BUTTONRADIO = &H4
  111. Private Const DFCS_BUTTONRADIOIMAGE = &H1
  112. Private Const DFCS_BUTTONRADIOMASK = &H2
  113. Private Const DFCS_CAPTIONCLOSE = &H0
  114. Private Const DFCS_CAPTIONHELP = &H4
  115. Private Const DFCS_CAPTIONMAX = &H2
  116. Private Const DFCS_CAPTIONMIN = &H1
  117. Private Const DFCS_CAPTIONRESTORE = &H3
  118. Private Const DFCS_CHECKED = &H400
  119. Private Const DFCS_FLAT = &H4000
  120. Private Const DFCS_INACTIVE = &H100
  121. Private Const DFCS_MENUARROW = &H0
  122. Private Const DFCS_MENUARROWRIGHT = &H4
  123. Private Const DFCS_MENUBULLET = &H2
  124. Private Const DFCS_MENUCHECK = &H1
  125. Private Const DFCS_MONO = &H8000
  126. Private Const DFCS_PUSHED = &H200
  127. Private Const DFCS_SCROLLCOMBOBOX = &H5
  128. Private Const DFCS_SCROLLDOWN = &H1
  129. Private Const DFCS_SCROLLLEFT = &H2
  130. Private Const DFCS_SCROLLRIGHT = &H3
  131. Private Const DFCS_SCROLLSIZEGRIP = &H8
  132. Private Const DFCS_SCROLLSIZEGRIPRIGHT = &H10
  133. Private Const DFCS_SCROLLUP = &H0
  134. Private Sub Command1_Click()
  135.     Dim di&
  136.     Dim pt As POINTAPI
  137.     di = MoveToEx(hDC, 0, 0, pt)
  138.     di = AngleArc(hDC, 100, 100, 50, 90, 90)
  139. End Sub
  140. Private Sub Command2_Click()
  141.     Dim rc As RECT
  142.     Dim di&
  143.     Dim newbrush&
  144.     di = GetClientRect(hwnd, rc)
  145.     newbrush = CreatePatternBrush(Picture1.Picture)
  146.     di = FillRect(hDC, rc, newbrush)
  147.     di = DeleteObject(newbrush)
  148. End Sub
  149. Private Sub Command3_Click()
  150.     Dim di&
  151.     Dim rc As RECT
  152.     di = GetClientRect(hwnd, rc)
  153.     di = InflateRect(rc, -5, -5)
  154.     di = DrawEdge(hDC, rc, EDGE_RAISED, BF_TOPLEFT)
  155.     di = DrawEdge(hDC, rc, EDGE_RAISED, BF_BOTTOMRIGHT)
  156. End Sub
  157. Private Sub Command4_Click()
  158.     Dim di&
  159.     Dim rc As RECT
  160.     rc.Left = 20
  161.     rc.Top = 20
  162.     rc.Right = 40
  163.     rc.Bottom = 40
  164.     di = DrawFrameControl(hDC, rc, DFC_BUTTON, DFCS_BUTTONCHECK Or DFCS_CHECKED)
  165. End Sub
  166.