WParwm : LBUTTON Or RBUTTON
lParam
Lo مختصات x کرسر را مشخص میکند . مختصات مرتبط با گوشه چپ بالایی از منطقه Client
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area
ho مختصات y کرسر را مشخص میکند . مختصات مرتبط با گوشه چپ بالایی منطقه Client
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area
در کل مختصات x و y گوشه چپ بالایی منطقه Client را مشخص می نماید.
Case WM_MOUSEMOVE
Dim rw As RECT
Dim rc As RECT
Dim pp As POINTAPI
GetWindowRect BtnOk, rw
pp.x = rw.left
pp.y = rw.top
ClientToScreen BtnOk, pp
GetCursorPos pp
If Not PtInRect(rw, pp) Then'
' MsgBox "rt'
'End If'
SetWindowTextA hwnd, pp.x & "," & pp.y & "...." & rw.left & "," & rw.top
اگر ازGetClientRect استفاده کنید مختصات left و Topرا صفر میدهد.
dim rw As RECT
GetWindowRect hwndBtnOk,rw
dim pp as POINTAPI
(pp.x = LoWord(lParam
( pp.y = HiWord(lParam
MoveWindow hwndBtnOk, pp.x, pp.y, (rw.right - rw.left), (rw.bottom - rw.top), 1
اولین مستطیل یا Rectangle حاوی مختصات جدید پنجره که جابجا یا تغییر سایز شده است طبق داکیومنت زیر
When the window procedure receives
the WM_NCCALCSIZE message, the first rectangle contains the new coordinates of a window that has been moved or resized, that is, it is the proposed new window coordinates. The second contains the coordinates of the window before it was moved or resized. The third contains the coordinates of the window's client area before the window was moved or resized
افزایش عرض یا طول مستطیل ( Rectangle )
InflateRect lprc,dx,dy
یک مستطیل را به منطقه به روز رسانی پنجره مشخص اضافه می کند
InvalidateRect hWnd,lpRect,bErase
Also Read offsetrect
WM_NCCALCSIZE return flags Global Const WVR_ALIGNTOP = &H0010 Global Const WVR_ALIGNLEFT = &H0020 Global Const WVR_ALIGNBOTTOM = &H0040 Global Const WVR_ALIGNRIGHT = &H0080 Global Const WVR_HREDRAW = &H0100 Global Const WVR_VREDRAW = &H0200 Global Const WVR_REDRAW = (WVR_HREDRAW Or WVR_VREDRAW) Global Const WVR_VALIDRECTS = &H0400 WM_NCCALCSIZE parameter structure' Type NCCALCSIZE_PARAMS rgrc As Long lppos As Long End Type Global Const MA_NOACTIVATEANDEAT = 4
allow to drag & move userform via control Label1)
Private Declare Function ReleaseCapture Lib "user32" () As Long Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Dim hWndForm As Long Private Sub UserForm_Initialize() hWndForm = FindWindow("ThunderDFrame", Me.Caption) End Sub Private Sub lb1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) If Button = xlPrimaryButton Then Call ReleaseCapture Call SendMessage(hWndForm, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&) End If End Sub
مختصات صفحه Screen Coordinate
برای تعیین اینکه چه بخشی از پنجره با یک مختصات صفحه خاص مطابقت دارد به عنوان مثال ، هنگامی که مکان نما حرکت می کند ، وقتی دکمه ماوس را فشار داده یا آزاد می شود
این پیام از طریق تابع WindowProc خودش دریافت می شود.
در صورتیکه ماوس تسخیر نشود ، پیام به پنجره ای که زیر مکان نما است ارسال می شود. در غیر این صورت ، این پیام به پنجره ای که ماوس را تسخیر کرده است ، ارسال می شود.
مقدار برگشتی تابع DefWindowProc یکی از مقادیر زیر است که نشانگر موقعیت نقطه داغ مکان نما است.
ساب کلاس کردن کنترل ترسیمی ( تنها یک کنترل )
Type cz As SIZE
cx As Long ' Width
cy As Long ' Height
End Type
WM_MOUSEACTIVATE=&H21
case WM_MOUSEACTIVATE
SetFocus hwnd
return MA_ACTIVATE
در WIN32 :
تست نشده ولی جواب خواهد داد توابع برای استفاده در Win32 است در Win64 نحوه ی اظهار توابع فرق میکند که در لینک توابع API در [ پیوندها ] ، نحوه ی صحیح آن در سایت خارجی درج شده.
Const GWL_EXSTYLE = -20
Const GWL_HINSTANCE = -6Const GWL_HWNDPARENT = -8Const GWL_ID = -12Const GWL_STYLE = -16Const GWL_USERDATA = -21Const GWL_WNDPROC = -4Const DWL_DLGPROC = 4Const DWL_MSGRESULT = 0Const DWL_USER = 8
در ویندوز ۳۲ بیتی :
HWND CreateWindowExA
dwExStyle
lpClassName
lpWindowName
dwStyle
X
Y
nWidth
nHeight
hWndParent
hMenu
hInstance
lpParam
WS_EX_WINDOWEDGE=&H100
WS_EX_TOOLWINDOW=&H80
: Window Styles
WS_BORDER=&H800000
WS_CHILD=&H40000000
WS_POPUP=&H80000000
: Note
The windows is a pop-up window. This style cannot'be used with the WS_CHILDstyle
Case WM_CREATE/SHOWWINDOW
: case WM_CREATE
"hButton = CreateWindow("button","Label,
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
100, 200,
50 ,20,
hWnd,(HMENU) BUTTON_ID,
0,0,
if message=WM_CTLCOLOREDIT Then
HDC hdcChild=(HDC)wParam
variable for text color
((SetTextColor hdcChild,RGB(0,0,0
End if
(OnSetFocus(pOldWnd
(m_BackColor=RGB(255,255,0
Type CHANGENOTIFY
dwChangeType : CN_TEXTCHANGED
End Type
wParam
.This parameter is not used; it must be zero
case WM_CTLCOLORSTATIC
HDC hdcStatic = (HDC) wParam
(SetTextColor hdcStatic,RGB(0,0,255
(SetBkColor hdcStatic,RGB(250,250,0
((Function=CreateSolidBrush(RGB(250,250,0
case WM_CTLCOLOREDIT
HDC hdcStatic = (HDC) wParam
(SetTextColor hdcStatic,RGB(0,0,255
(SetBkColor hdcStatic,RGB(0,230,0
((Function=CreateSolidBrush(RGB(0,230,0
)
nidEvent می تواند WM_MOUSELEAVE باشد یعنی SetTimer در MOUSEMOVE تنظیم شود اگر Msg گرفته شده در TIMEPROC برابر MOUSELEAVE شد کاری انجام شده و بعد KillTimer اعمال گردد.
trackmouseevent :Posts messages when the mouse pointer leaves window or hovers over a window for a specified amount of time
پست کردن پیام هایی به پرنت ویندو وقتی نشانگر ماوس پنجره را ترک کرده ( هندل به ویندو ) یا روی یک پنجره برای مدتی از زمان بصورت شناور است ( می پلکد- یا روی آن محدوده).
API Declarations'
Public Type udtTrackMouseEvent
cbSize As Long
dwFlags As Long
hwndTrack As Long
dwHoverTime As Long
End Type
Public Declare Function TrackMouseEvent Lib "comctl32" Alias "_TrackMouseEvent" (lpEventTrack As udtTrackMouseEvent) As Long
getdlgctrlid : Retrieves the identifier of the
.specified control
بر گرفته از فروم خارجی ( بررسی موقعیت ماوس در باتن موردنظر )
1-find your button rectangle
GetWindowRect BtnHwnd,BtnRect
WM_SETCURSOR
. Do not change anything, just detect if wParam is HWND of your button. If it is, then set a #define WM_SETCURSOR 0x0020