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 / ex8b.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  8.8 KB  |  230 lines

  1. VERSION 4.00
  2. Begin VB.Form frmex8B 
  3.    Caption         =   "Additional Examples"
  4.    ClientHeight    =   2865
  5.    ClientLeft      =   1845
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6765
  8.    Height          =   3270
  9.    Left            =   1785
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   191
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   451
  14.    Top             =   1140
  15.    Width           =   6885
  16.    Begin VB.CommandButton Command3 
  17.       Caption         =   "DrawState Complex"
  18.       Height          =   435
  19.       Left            =   4980
  20.       TabIndex        =   11
  21.       Top             =   1200
  22.       Width           =   1575
  23.    End
  24.    Begin VB.CommandButton Command2 
  25.       Caption         =   "DrawState Text"
  26.       Height          =   435
  27.       Left            =   4980
  28.       TabIndex        =   9
  29.       Top             =   720
  30.       Width           =   1575
  31.    End
  32.    Begin VB.CommandButton Command1 
  33.       Caption         =   "DrawState Bitmap"
  34.       Height          =   435
  35.       Left            =   4980
  36.       TabIndex        =   8
  37.       Top             =   240
  38.       Width           =   1575
  39.    End
  40.    Begin VB.Frame Frame1 
  41.       Caption         =   "Effect"
  42.       Height          =   2175
  43.       Left            =   2820
  44.       TabIndex        =   2
  45.       Top             =   120
  46.       Width           =   1995
  47.       Begin VB.CheckBox chkRight 
  48.          Caption         =   "Right"
  49.          Height          =   255
  50.          Left            =   180
  51.          TabIndex        =   7
  52.          Top             =   1800
  53.          Width           =   1515
  54.       End
  55.       Begin VB.OptionButton optEffect 
  56.          Caption         =   "Disabled"
  57.          Height          =   255
  58.          Index           =   3
  59.          Left            =   180
  60.          TabIndex        =   6
  61.          Top             =   1380
  62.          Width           =   1695
  63.       End
  64.       Begin VB.OptionButton optEffect 
  65.          Caption         =   "Mono"
  66.          Height          =   255
  67.          Index           =   2
  68.          Left            =   180
  69.          TabIndex        =   5
  70.          Top             =   1020
  71.          Width           =   1695
  72.       End
  73.       Begin VB.OptionButton optEffect 
  74.          Caption         =   "Union"
  75.          Height          =   255
  76.          Index           =   1
  77.          Left            =   180
  78.          TabIndex        =   4
  79.          Top             =   660
  80.          Width           =   1695
  81.       End
  82.       Begin VB.OptionButton optEffect 
  83.          Caption         =   "Normal"
  84.          Height          =   255
  85.          Index           =   0
  86.          Left            =   180
  87.          TabIndex        =   3
  88.          Top             =   300
  89.          Value           =   -1  'True
  90.          Width           =   1695
  91.       End
  92.    End
  93.    Begin VB.PictureBox Picture2 
  94.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  95.          Name            =   "Arial"
  96.          Size            =   15.75
  97.          Charset         =   0
  98.          Weight          =   700
  99.          Underline       =   0   'False
  100.          Italic          =   -1  'True
  101.          Strikethrough   =   0   'False
  102.       EndProperty
  103.       Height          =   1155
  104.       Left            =   60
  105.       ScaleHeight     =   75
  106.       ScaleMode       =   3  'Pixel
  107.       ScaleWidth      =   171
  108.       TabIndex        =   1
  109.       Top             =   1320
  110.       Width           =   2595
  111.    End
  112.    Begin VB.PictureBox Picture1 
  113.       Height          =   1095
  114.       Left            =   60
  115.       Picture         =   "EX8B.frx":0000
  116.       ScaleHeight     =   1065
  117.       ScaleWidth      =   2565
  118.       TabIndex        =   0
  119.       Top             =   120
  120.       Width           =   2595
  121.    End
  122.    Begin Cbkd.Callback Callback1 
  123.       Left            =   5400
  124.       Top             =   2160
  125.       _Version        =   262144
  126.       _ExtentX        =   847
  127.       _ExtentY        =   847
  128.       _StockProps     =   0
  129.       Type            =   38
  130.    End
  131.    Begin VB.Label Label1 
  132.       Caption         =   "Note: All combinations are using a red brush."
  133.       Height          =   255
  134.       Left            =   60
  135.       TabIndex        =   10
  136.       Top             =   2520
  137.       Width           =   3555
  138.    End
  139. Attribute VB_Name = "frmex8B"
  140. Attribute VB_Creatable = False
  141. Attribute VB_Exposed = False
  142. Option Explicit
  143. ' Copyright 
  144.  1997 by Desaware Inc. All Rights Reserved
  145. Private Type POINTAPI
  146.     x As Long
  147.     y As Long
  148. End Type
  149. Private Type RECT
  150.         Left As Long
  151.         Top As Long
  152.         Right As Long
  153.         Bottom As Long
  154. End Type
  155. 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)
  156. Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
  157. Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
  158. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  159. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  160. Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
  161. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  162. Private Declare Function DrawEdge& Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long)
  163. Private Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
  164. Private Declare Function DrawFrameControl Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
  165. Private Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As Long, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long
  166. Private Declare Function DrawStateByString Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As String, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long
  167. Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
  168. Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
  169. Const pi = 3.141578
  170. Private Const DSS_DISABLED = &H20
  171. Private Const DSS_MONO = &H80
  172. Private Const DSS_NORMAL = &H0
  173. Private Const DSS_RIGHT = &H8000
  174. Private Const DSS_UNION = &H10
  175. Private Const DST_BITMAP = &H4
  176. Private Const DST_COMPLEX = &H0
  177. Private Const DST_ICON = &H3
  178. Private Const DST_PREFIXTEXT = &H2
  179. Private Const DST_TEXT = &H1
  180. Private Sub Callback1_cbxLLLLL(lval1 As Long, lval2 As Long, lval3 As Long, lval4 As Long, lval5 As Long, retval As Long)
  181.     Dim usebrush&
  182.     Dim di&
  183.     Dim rc As RECT
  184.     rc.Left = 0
  185.     rc.Top = 0
  186.     rc.Right = lval4 \ 2
  187.     rc.Bottom = lval5 \ 2
  188.     ' We have to draw into the device context provided
  189.     ' Draw a green rectangle in the upper left corner
  190.     usebrush& = CreateSolidBrush(RGB(0, 255, 0))
  191.     di = FillRect(lval1, rc, usebrush)
  192.     di = DeleteObject(usebrush)
  193.     ' Just throw some text out
  194.     di = TextOut(lval1, 5, 5, "Hello", 5)
  195.     ' We don't need lparam and wParam here - so they are ignored
  196.     ' You can pass the values if you wish
  197.     Debug.Print lval2, lval3
  198. End Sub
  199. Private Sub Command1_Click()
  200.     Dim di&
  201.     Dim hbr&
  202.     Picture2.Cls
  203.     hbr& = CreateSolidBrush(RGB(255, 0, 0))
  204.     di = DrawState(Picture2.hdc, hbr&, 0, Picture1.Picture, 0, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, DST_BITMAP Or GetEffect())
  205. End Sub
  206. Public Function GetEffect&()
  207.     Dim x%
  208.     Dim eff&
  209.     If optEffect(0).Value <> 0 Then eff = DSS_NORMAL
  210.     If optEffect(1).Value <> 0 Then eff = DSS_UNION
  211.     If optEffect(2).Value <> 0 Then eff = DSS_MONO
  212.     If optEffect(3).Value <> 0 Then eff = DSS_DISABLED
  213.     If chkRight.Value <> 0 Then eff = eff Or DSS_RIGHT
  214.     GetEffect = eff
  215. End Function
  216. Private Sub Command2_Click()
  217.     Dim di&
  218.     Dim hbr&
  219.     Picture2.Cls
  220.     hbr& = CreateSolidBrush(RGB(255, 0, 0))
  221.     di = DrawStateByString(Picture2.hdc, hbr&, 0, "A String", 8, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, DST_TEXT Or GetEffect())
  222. End Sub
  223. Private Sub Command3_Click()
  224.     Dim di&
  225.     Dim hbr&
  226.     Picture2.Cls
  227.     hbr& = CreateSolidBrush(RGB(255, 0, 0))
  228.     di = DrawState(Picture2.hdc, hbr&, Callback1.ProcAddress, 195, 42, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, DST_COMPLEX Or GetEffect())
  229. End Sub
  230.