I am making my own flat command button and I'm stopped on how to manage mouse movement. Similar to explorer buttons when you hover them, the borders appear when it enters the button region and disappears otherwise.
I've made some reading on callbacks and some API functions and came across with PeekMessage().
What I thought over is I monitor my control's messages, particularly mouse's, and wait for WM_MOUSELEAVE.
At the PeekMessage line, it always returns zero.
Here's a draft of my 'project'
At Usercontrol_ReadProperties() event,
At Module1,
TIA
I've made some reading on callbacks and some API functions and came across with PeekMessage().
What I thought over is I monitor my control's messages, particularly mouse's, and wait for WM_MOUSELEAVE.
At the PeekMessage line, it always returns zero.
Here's a draft of my 'project'
At Usercontrol_ReadProperties() event,
Code:
If Ambient.Usermode then
If mbTimerInit Then
mlngID = SetTimer(UserControl.hWnd, 0&, 200, _
AddressOf TimeProc)
mbTimerInit = True 'module level boolean
End If
End If
At Module1,
Code:
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Const WM_QUIT = &H12
Private Const PM_NOREMOVE = &H0
Private Const WM_USER = &H400
Private Const WM_MOUSELEAVE As Long = WM_USER + 2
Private Const WM_MOUSEFIRST = &H200
Private Const WM_MOUSELAST = &H209
Private Const CLASSNAME = "ThunderUserControlDC"
Private Const CLASSSIZE = 4096
Sub Main()
End Sub
Public Sub TimerProc(ByVal hwnd As Long, ByVal uiMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
'Peek message for my usercontrol defined by hwnd
Dim plng_val As Long
Dim lp_MSG As MSG
plng_val = PeekMessage(lp_MSG, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)
If plng_val = 0 Then 'at this point, it failed
Debug.Print hwnd, lp_MSG.message
Exit Sub
End If
'test for mouse message
Select Case lp_MSG.message
Case WM_QUIT
Exit Sub
Case WM_MOUSELEAVE
'Debug.Print "Elvis has left the building"
Case Else
'Debug.Print "none"
End Select
End Sub
TIA