موارد پایین تست شده ... البته اینها موارد ساده ای هستند و پیش پا افتاده
Public Function CallWindProc(ByVal hwnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Dim hdc As LongPtr
Select Case Msg
Case WM_PAINT
Dim cc As RECT
GetClientRect hwnd, cc
(hdc = GetDC(hwnd
((FillRect hdc, cc, CreateSolidBrush(RGB(255, 0, 255
Case WM_DESTROY
SetWindowLongPtr hwnd, GWL_WNDPROC, OldWindow
End Select
CallWindProc = CallWindowProc(OldWindow, hwnd,
(Msg, wParam, lParam,
End Function
(FillRect hdc, cc, GetSysColorBrush(5
(FillRect hdc, cc, GetSysColorBrush(16
TIMER
Case WM_TIMER
GetClientRect hwnd, rcClient
hdc
(GetDC(hwnd=
DrawText hdc, x, 2, rcClient, DT_CENTER
SetWindowTextA hwnd, x
x = x + 1
ترسیم مستطیل در InputBox
Case WM_TIMER
Dim Et As LongPtr
Dim WinRect As RECT
Et:Edit Handle,WinRect For Edit Control'
GetWindowRect Et, WinRect
( hdc = GetDC(hwnd
rc.Left = 10
rc.Top = 68
rc.right = 70
rc.bottom = 88
rcClear.Left = rc.Left: rcClear.right = GetUpdateRight
rcClear.Top = rc.Top - 3: rcClear.bottom = rc.bottom
rc.Left = rc.Left + x: rc.right = rc.right + x
Fill Rectangle'
( FillRect hdc, rcClear, GetSysColorBrush(15
Draw Rectangle'
Rectangle hdc, rc.Left, rc.Top, rc.right, rc.bottom
FillRect Again GetSysColorBrush(18) ' Black'
Use Offset And FillRect rc With Another Brush'
GetUpdateRight = rc.right + x
If rc.right > WinRect.right - WinRect.Left Then x = 0
احتملا Rec در پیام WMPAINT باید Global یا Static تعیین شود. تست نشده ولی روال بدین شکل است .
SM_CYSIZEFRAME = SM_CYFRAME SM_CXSIZEFRAME = SM_CXFRAME
win32api/reference/Message/WM_CTLCOLORDLG.htm
WM_CTLCOLORDLG
Static wBrush
If wBrush<>0 Then
(hBM=LoadImage(0,"tile.bmp",0,0,0,0x2010
(wBrush=CreatePatternBrush(hBM
Function=wBrush
ساب کلاس کردن کنترل ترسیمی ( تنها یک کنترل )
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
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,
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
تست شده
The WM_PAINT message is sent when the system or another application makes a request to paint a portion
of an application's window
The PAINTSTRUCT
structure contains information that can be used to paint the.client area of a window
حاوی اطلاعاتی برای استفاده در نقاشی ناحیه ی Client پنجره.
Case WM_PAINT
Dim ps As PAINTSTRUCT
( hdc = BeginPaint(lhwnd, ps
Dim rrc As RECT
GetClientRect lhwnd, rrc
(( FillRect hdc, rrc, CreateSolidBrush(RGB(100, 0, 100
SetTextColor hdc, vbRed
TextOutA hdc, 10, 10, "sa", 2
EndPaint lhwnd, ps
ReleaseDC lhwnd, hdc
البته غیر از پیام زیر میشود با پیام WM_CTLCOLORBTN هم رنگ باتن را تغییر داد که lParam میشود هندل باتن و wParam هم هندل DC میشود
Case WM_DRAWITEM
Dim pDIS As DRAWITEMSTRUCT
Dim state
(CopyMemory pDIS, ByVal lParam, Len(pDIS
( hdc = GetDC(pDIS.hdc
Dim p As RECT
p = pDIS.rcItem
state = pDIS.itemState
GetClientRect can, p
If pDIS.CtlID = 2 Then
If state = 272 Then
RoundRect hdc, p.Left, p.Top, p.Right, p.Bottom, 16, 16
ReleaseDC can, hdc
Else
RoundRect hdc, p.Left, p.Top, p.Right, p.Bottom, 4, 4
ReleaseDC can, hdc
End If
End If
(CopyMemory ByVal lParam, pDIS,Len(pDIS