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 / ch18 / btntest.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-16  |  2.3 KB  |  64 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Button Test"
  4.    ClientHeight    =   2505
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   3675
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   2505
  11.    ScaleWidth      =   3675
  12.    Begin VB.CommandButton Command2 
  13.       Caption         =   "Sticky"
  14.       Height          =   615
  15.       Left            =   240
  16.       TabIndex        =   2
  17.       Top             =   1200
  18.       Width           =   1395
  19.    End
  20.    Begin VB.PictureBox Picture1 
  21.       Height          =   555
  22.       Left            =   2460
  23.       Picture         =   "btntest.frx":0000
  24.       ScaleHeight     =   525
  25.       ScaleWidth      =   525
  26.       TabIndex        =   1
  27.       Top             =   240
  28.       Width           =   555
  29.    End
  30.    Begin VB.CommandButton Command1 
  31.       Caption         =   "Image"
  32.       Height          =   675
  33.       Left            =   240
  34.       TabIndex        =   0
  35.       Top             =   240
  36.       Width           =   1395
  37.    End
  38. Attribute VB_Name = "Form1"
  39. Attribute VB_GlobalNameSpace = False
  40. Attribute VB_Creatable = False
  41. Attribute VB_PredeclaredId = True
  42. Attribute VB_Exposed = False
  43. Option Explicit
  44. ' copyright 
  45.  1997 by Desaware Inc. All Rights Reserved
  46. Private Const BM_SETIMAGE = &HF7
  47. Private Const BM_SETSTYLE = &HF4
  48. Private Const BS_ICON = &H40&
  49. Private Const BS_BITMAP = &H80&
  50. Private Const BM_SETSTATE = &HF3
  51. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  52. Private Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  53. Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
  54. Private Sub Command1_Click()
  55.     ' Does not work for VB buttons.
  56.     Call SendMessageBynum(Command1.hwnd, BM_SETSTYLE, BS_BITMAP, True)
  57.     Call SendMessageBynum(Command1.hwnd, BM_SETIMAGE, 0, Picture1.Picture)
  58. End Sub
  59. Private Sub Command2_Click()
  60.     Static downstate&
  61.     downstate = Not downstate
  62.     Call SendMessageBynum(Command2.hwnd, BM_SETSTATE, downstate, 0)
  63. End Sub
  64.