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

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