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

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