vbAccelerator - Contents of code file: frmSimple.frmVERSION 5.00
Begin VB.Form frmSimple
BorderStyle = 0 'None
Caption = "Form1"
ClientHeight = 3735
ClientLeft = 0
ClientTop = 0
ClientWidth = 6285
Icon = "frmSimple.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3735
ScaleWidth = 6285
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox picBackground
AutoSize = -1 'True
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1980
Left = 4080
Picture = "frmSimple.frx":1272
ScaleHeight = 1920
ScaleWidth = 1920
TabIndex = 5
Top = 1020
Width = 1980
End
Begin VB.CommandButton cmdCreate
Caption = "&Create"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 4080
TabIndex = 4
Top = 3060
Width = 1335
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 240
TabIndex = 2
Top = 600
Width = 1515
End
Begin VB.CommandButton cmdOK
BackColor = &H00FF6633&
Caption = "OK"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1020
MaskColor = &H00FFFFFF&
Style = 1 'Graphical
TabIndex = 1
Top = 1020
Width = 735
End
Begin VB.CommandButton cmdReset
BackColor = &H00FF6633&
Caption = "&Reset"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 240
Style = 1 'Graphical
TabIndex = 0
Top = 1020
Width = 735
End
Begin VB.Label lblInfo
Caption = $"frmSimple.frx":D2B4
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 2760
TabIndex = 6
Top = 120
Width = 3315
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "Enter Code:"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 195
Left = 240
TabIndex = 3
Top = 360
Width = 1395
End
End
Attribute VB_Name = "frmSimple"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SendMessageLong Lib "USER32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long
Private Declare Function ReleaseCapture Lib "USER32" () As Long
Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MOVE = &HF010&
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Declare Function GetWindowLong Lib "USER32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
'Requires Windows 2000 or later:
Private Const WS_EX_LAYERED = &H80000
Private Type BLENDFUNCTION
BlendOp As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
'//
'// currently defined blend function
'//
Private Const AC_SRC_OVER = &H0
'//
'// alpha format flags
'//
Private Const AC_SRC_ALPHA = &H1
Private Const AC_SRC_NO_PREMULT_ALPHA = &H1
Private Const AC_SRC_NO_ALPHA = &H2
Private Const AC_DST_NO_PREMULT_ALPHA = &H10
Private Const AC_DST_NO_ALPHA = &H20
Private Declare Function SetLayeredWindowAttributes Lib "USER32" _
(ByVal hWnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Declare Function UpdateLayeredWindow Lib "USER32" _
(ByVal hWnd As Long, ByVal hdcDst As Long, pptDst As Any, _
psize As Any, ByVal hdcSrc As Long, _
pptSrc As Any, crKey As Long, _
ByVal pblend As Long, ByVal dwFlags As Long) As Long
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Declare Function RedrawWindow Lib "USER32" (ByVal hWnd As Long,
lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Private Const RDW_ALLCHILDREN = &H80
Private Const RDW_ERASE = &H4
Private Const RDW_FRAME = &H400
Private Const RDW_INVALIDATE = &H1
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdCreate_Click()
Me.Width = picBackground.ScaleWidth
Me.Height = picBackground.ScaleHeight
Set Me.Picture = picBackground.Picture
Dim transColor As Long
transColor = &H8000FF
Me.BackColor = transColor
Dim lStyle As Long
lStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong hWnd, GWL_EXSTYLE, lStyle
SetLayeredWindowAttributes Me.hWnd, transColor, 220, LWA_COLORKEY Or
LWA_ALPHA
End Sub
Private Sub cmdOK_Click()
Unload Me
End Sub
Private Sub cmdReset_Click()
Dim lStyle As Long
Dim lhWnd As Long
lhWnd = Me.hWnd
lStyle = GetWindowLong(lhWnd, GWL_EXSTYLE)
lStyle = lStyle And Not WS_EX_LAYERED
SetWindowLong lhWnd, GWL_EXSTYLE, lStyle
RedrawWindow lhWnd, 0, 0, RDW_ERASE Or RDW_INVALIDATE Or RDW_FRAME Or
RDW_ALLCHILDREN
Me.BackColor = vbButtonFace
Me.Width = picBackground.Left + picBackground.Width + 4 *
Screen.TwipsPerPixelX
Me.Height = cmdCreate.Top + cmdCreate.Height + 4 * Screen.TwipsPerPixelY
End Sub
Private Sub Form_Load()
'
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y
As Single)
' A better (more flexible) way of doing this is to use
' the vbAccelerator WM_NCHITTEST interception library.
' but if you want minimal code, here is the quick way!
If Button = vbLeftButton Then
'Fake a mouse down on the titlebar so form can be moved...
ReleaseCapture
SendMessageLong Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
Form_MouseDown Button, Shift, X, Y
End Sub
|
|