MSG_BEFORE = 1 'Callback before the original WndProc
MSG_AFTER = 2 'Callback after the original WndProc
MSG_BEFORE_AFTER = MSG_BEFORE Or MSG_AFTER 'Callback before and after the original WndProc
End Enum
Private Const ALL_MESSAGES As Long = -1 'All messages callback
Private Const MSG_ENTRIES As Long = 32 'Number of msg table entries
Private Const WNDPROC_OFF As Long = &H38 'Thunk offset to the WndProc execution address
Private Const GWL_WNDPROC As Long = -4 'SetWindowsLong WndProc index
Private Const IDX_SHUTDOWN As Long = 1 'Thunk data index of the shutdown flag
Private Const IDX_HWND As Long = 2 'Thunk data index of the subclassed hWnd
Private Const IDX_WNDPROC As Long = 9 'Thunk data index of the original WndProc
Private Const IDX_BTABLE As Long = 11 'Thunk data index of the Before table
Private Const IDX_ATABLE As Long = 12 'Thunk data index of the After table
Private Const IDX_PARM_USER As Long = 13 'Thunk data index of the User-defined callback parameter data index
Private z_ScMem As Long 'Thunk base address
Private z_Sc(64) As Long 'Thunk machine-code initialised here
Private z_Funk As Collection 'hWnd/thunk-address collection
Private Declare Function CallWindowProcA Lib "USER32" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "USER32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function IsBadCodePtr Lib "kernel32" (ByVal lpfn As Long) As Long
Private Declare Function IsWindow Lib "USER32" (ByVal hWnd As Long) As Long
Private Declare Function SetWindowLongA Lib "USER32" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
Private Declare Function SetWindowRgn Lib "USER32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
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 X As Long, ByVal Y As Long, ByVal cX As Long, ByVal cY As Long, ByVal fuFlags As Long) As Long
Private Declare Function DrawStateText 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
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, Col As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function InflateRect Lib "USER32" (lpRect As Rect, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetRect Lib "USER32" (lpRect As Rect, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function IsRectEmpty Lib "USER32" (lpRect As Rect) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function FillRect Lib "USER32" (ByVal hdc As Long, lpRect As Rect, ByVal hBrush As Long) As Long
Public Property Let DisplayHand(newValue As Boolean)
m_DisplayHand = newValue
End Property
Public Property Get DisplayHand() As Boolean
DisplayHand = m_DisplayHand
End Property
'Description: Enable or disable the control
Public Property Let Enabled(bEnabled As Boolean)
On Error GoTo Handler
m_bEnabled = bEnabled
PropertyChanged "Enabled"
'/*** added
DrawButton (eNormal)
Handler:
End Property
Public Property Get Enabled() As Boolean
On Error GoTo Handler
Enabled = m_bEnabled
Refresh
Exit Property
Handler:
End Property
Public Property Let ColorScheme(newValue As eColorScheme)
Select Case newValue
Case Aqua
ColorButtonUp = &HD06720
ColorButtonHover = &HE99950
ColorButtonDown = &HA06710
ColorBright = &HFFEDB0
Case WMP10
ColorButtonUp = &HD09060
ColorButtonHover = &HE06000
ColorButtonDown = &HA98050
ColorBright = &HFFFAFA
Case DeepBlue
ColorButtonUp = &H800000
ColorButtonHover = &HA00000
ColorButtonDown = &HF00000
ColorBright = &HFF0000
Case DeepRed
ColorButtonUp = &H80&
ColorButtonHover = &HA0&
ColorButtonDown = &HF0&
ColorBright = &HFF&
Case DeepGreen
ColorButtonUp = &H8000&
ColorButtonHover = &HA000&
ColorButtonDown = &HC000&
ColorBright = &HFF00&
Case DeepYellow
ColorButtonUp = &H8080&
ColorButtonHover = &HA0A0&
ColorButtonDown = &HC0C0&
ColorBright = &HFFFF&
End Select
m_ColorScheme = newValue
PropertyChanged "m_ColorScheme"
DrawButton (eNormal)
End Property
Public Property Get ColorScheme() As eColorScheme
ColorScheme = m_ColorScheme
End Property
Public Property Let BorderBrightness(newValue As Long)
'* nOrdinal - Optional, ordinal index of the callback procedure. 1 = last private method, 2 = second last private method, etc.
'* oCallback - Optional, the object that will receive the callback. If undefined, callbacks are sent to this object's instance
'* bIdeSafety - Optional, enable/disable IDE safety measures. NB: you should really only disable IDE safety in a UserControl for design-time subclassing
Const CODE_LEN As Long = 260 'Thunk length in bytes
Const MEM_LEN As Long = CODE_LEN + (8 * (MSG_ENTRIES + 1)) 'Bytes to allocate per thunk, data + code + msg tables
Const PAGE_RWX As Long = &H40& 'Allocate executable memory
Const MEM_COMMIT As Long = &H1000& 'Commit allocated memory
Const MEM_RELEASE As Long = &H8000& 'Release allocated memory flag
Const IDX_EBMODE As Long = 3 'Thunk data index of the EbMode function address
Const IDX_CWP As Long = 4 'Thunk data index of the CallWindowProc function address
Const IDX_SWL As Long = 5 'Thunk data index of the SetWindowsLong function address
Const IDX_FREE As Long = 6 'Thunk data index of the VirtualFree function address
Const IDX_BADPTR As Long = 7 'Thunk data index of the IsBadCodePtr function address
Const IDX_OWNER As Long = 8 'Thunk data index of the Owner object's vTable address
Const IDX_CALLBACK As Long = 10 'Thunk data index of the callback method address
Const IDX_EBX As Long = 16 'Thunk code patch index of the thunk data
Const SUB_NAME As String = "sc_Subclass" 'This routine's name
Dim nAddr As Long
Dim nID As Long
Dim nMyID As Long
If IsWindow(lng_hWnd) = 0 Then 'Ensure the window handle is valid
zError SUB_NAME, "Invalid window handle"
Ex 'T0'Thipx 'T0'Thvalid wind2E safe,o0'T-u,a4 e44444444 safe---------------
$pIColor =UB_hen
hButtonReW03, 213, 214)
Line (uW - .mpWhe bf the Calcontrol is terminat uH :is terminat uH :is terminat uH :isg+1ine (u c .mp (u c .ion Then DeleteObject hBuW, 2), RGB(253, 216, 137)
End 4)) .ion Idpg) As BoWMf IsWindow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs Long = FicDow(lng_hAs 47
ggerm)'Ensure thr 'In Disabled state Color =0)
'aO 40
Co s Long = FO s O 94_r As Long)
Dim oldBrush As Long, newBrush As Long, newPen As Long, oldPen As LonOed As Boolean
hMod = GetModuC O 94_r As Long'Thunk data index of the CallWindowProc function address
ConwProc function afunction addresabled stx of tan(uW -ctiongng uH)method, etc.IePaRGB Theng, CryDePaRGB zError SUB_NAME, 77LonOed As Boolean
hMod = GetModuC4 Theng, CryDePaRGBect hn Disabled state Color =0)
'aO 40
----------i Get,lingng nb= 2End I-------ist IDX_FREE Af the SetWindowsLob= 2oaded ALd I---eng-----------roc function adiLoneb2s we're rusdBrush AsC22222222AALd s Belr-----g As Long = &H40& t uH :isg+1-roc function adistalParam As tCrystalPi0ram As tHeigW-roc m AA----E As Long = 3 Lon-roc functed memory flag
ConstCigWIdpg) As BoWMf IsWindow(lng_hAs Long = 10 7 LoWord = lDWord And &HFFFF&
1ubclass
ECam (Brush As Als-E iA1ubclass
ECam (Brush As Als-thiiiiiiiiii*****w&HFFTrue) As D=icDow(lnss
If IuR ee the wi,Tcrl.Fb. NB: you hugdreeoWorae IDX_SWLelY e dm.Ref_Left = (CornerRadius \ 3) - 1
**-------mldBrusY e dm.Ref_Left = mA 4TElInHighHighLiteeh
Y, lWidth4 / uH) + uW, 1), RGB(206, 231, 255)
= C19sja= .<.s9'1)- 47ao ornerRadius \ g---i Get,lingng nb= te = rom Scal a, ElseIfcT0Gou hugdreeoWorae IDX_Se e dm.Ref_Left = (CornerRadius \ 3) - 1
**- TElInHighLite (CornerRawColor As Longrae ft = (Cal452dialGXPershoeng, CryDeFFHong. NB: yoe (b- ttonRegio
s Lonafety As lV hadi---s9sjaF00&y_reeugdry_r II--(rI0ng nb= 0ng nb= 0ngPRiograeCorne--(t
d I-------ist IDX_FREE Als-:patch index of ar)z.r)' u an WMPensit - 4 + i)-(uW, uH - 4 + i), RGB(r"st IDX_FREE Als-:patch y_reB(r"st IDX_FREE Als-:patch y_reB(r"st IDX_FREE Als-:patch y_reB(r"st IDX_FREE Als-:patch y_reB(r"st IDX_FREE Als-:patch y_reB(r"st IDX_FREE E Als-:::: 'TGush As Long, newBrush As LonduddMsgte = rom Scal a, I2EE Als-:g = FicDow(lng_hAs Long = FicDow(lng_hsh As L,dow handlB e = WMP Then 'WMn)
DDow(lng_hsh Al,oWMf IsWindow(lB_def_Fo e = Whs--- As ne =ni0000000BplB_de e = Whs--- As ne =ni0000P s-t / (uH B_d= 2End I------- g---i Get,lingng nb= te = rom S ad= 2En(uH Bl452dialGXPer 4nGXPer t / ( ee the wi,TcXPer 3Val lng_hWnd As Long, _
riib If hButtonRegio
ECam A h) CrystalPa \ g---i Get,lingng nOtonRegp hWndPwhoeng, CroPwhoeng, CroPwhoeng, Cro3oCroPWMn)w p IDXo3Aaoeng, Crobmsl _
3Val lng_aM ee the wi,TcXPer 3Val lng_hWnd As Long, _l lda
Rr For i = 0""""""""a"""sa"""sa""h"""Monbd mtam.R 'B: )--------lddial4r)--------ldW2224taB""""""Pensit hW- " --ypassed fug zErrorbnIeddial BF1 '9""""" the wi,Tc GoTLnd If
)s= Wdial4r 'B: )--------lddolorButtonHover,r For iai &HFFHong. Nf wCog_h NPCig""""
1te PercesB(2j *""" --lzErrorbnIallbackmASC --lzErrorb=d"sauAI.e iainnes &e ialorButtonHovSconHiglnHover,r '1esed fug zErrorbnIeddial BF1 '9""""" the wi,Tc GoTLnd If
'a 1, Scalngion 4WidLr"-l4cty bag - also, a good place to start thICpt\CiI-eohli i- 1) the wi,Tc GoTLFim224t(he wi,Tc GoTLFim224t As ne =ni000rushsart thICpt\CiI-eohli i- 1)ag - al(eEvPriy"Us,Dn", start thICp""""""2 Thir,r d Region
If hButtonRegion Then DeleteObject hButtonRegion
Select Case m_Style
Case Crystal, WMP, Mac_Variation
lCornerRad = s,r "",se leaving the, 100)
Nf w
s1dCoCorn"",f 0""""FHong. Nf w
s1dCoCorn"",f 0""""FHong. Nf w
s1dCoCorn""rI r"O I,"" 0""""FHonga.- As n
- 1rYHg the, 100A
- 1rYHg the, 100A
- 1rYHg thee Region
0
- 1rYor t, Nneld """"""2 Tha(r\r4""", 2-uif
- 1)
DectRgn(Crystala 'Thunk data index of rI0iibs,r ForriwG4r)--------ldW2224taB3 CasrableeeeeihA-eohl 0"""Hong. Nf w
oulS)' unkNo)lXt_repeTE_umXt=nRGsci3SulSE_LEAVE2222ASB: lOMMe""",Sa(ver,rpeTE_umXt=nRGsci3SulSE_LEAVE2OMMLo Delet2222AS)lXt_sM2OMrb dBrush As """)oxo""",Sa(ver,rpeTE_umXt=nRGsci audePixehiFc_t=nRGsci3SulSE_LEAVBGL oc T 'Thunk code pat-)t ,SNo)lXt_repeTE_Colo-eohli i- 1) the wi,Tc GoTLFim224t(he wi, oulS)' unkNo)llS)' LEAVBoc T 'T:
s1dCoCorn""""C
(CvI) DeTE_sd-)t ,SNo)ld_LEAVE2222
cnNum2222
cnNum2222
lf222
Frt, 2nReSOLonH aun"9ic T9ic T9ic T9ic N2222
- 1
_'repeTcaleWneeeeeeeeee the wiic T9ic N224VE222al-)tonRsV.a<ECrjDleWneeeeeeeeee the wiieTE_Colo-Thuciic 2al-)P-pl"""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he wi, oulS)'t(hiiI-eri4ex of thesg, X1 As Long,c TtaB3 ic 2al-)P-pl"""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he wi, oulS thrpeTE_uyUts9ic T9ic N1A
DsC c Tta""2 Tf
If m
--
-- ' theer,rpeTE CasrableeeeeihA-eohl 0"""Hong. Nf w
s1dCoCoB)tonRs Lonvn1) the wi,Tc wlg 11B""""""PenogUvTddt = 0wi,T11A
DshiFc_defeeee thc Nf wF
-- p,SNoR3rfe""""P, Nf w)tonRs Lonvn1) the wi,Tc GoTLFim224t(he,SNoR3rfe""""P, ""rI(he,SNoR3rfe""SNoR3rfe"MMLo Delet2222A)
iSc T9iHeikweigh.ReadProaaD(2j "oTLFim224t(he,SNoR3rfe""""P, ""rI(he,SNo-ea=gh.ReadProaaD(2j "oTLdProaaD(2j "oTLFim224t(he,SNoB24t(he,SNoB2-(rI0ng nbd mem1)hiic T9ic Ng nbd mem1)hiic T9ic Ng ee"1,"" 0""""FHonga.- As n