// EDITSTYLE class parts and states | |
// | |
#define VSCLASS_EDITSTYLE L"EDITSTYLE" | |
#define VSCLASS_EDIT L"EDIT" | |
enum EDITPARTS { | |
EP_EDITTEXT = 1, | |
EP_CARET = 2, | |
EP_BACKGROUND = 3, | |
EP_PASSWORD = 4, | |
EP_BACKGROUNDWITHBORDER = 5, | |
EP_EDITBORDER_NOSCROLL = 6, | |
EP_EDITBORDER_HSCROLL = 7, | |
EP_EDITBORDER_VSCROLL = 8, | |
EP_EDITBORDER_HVSCROLL = 9, | |
}; | |
#define EDITSTYLEPARTS EDITPARTS; | |
enum EDITTEXTSTATES { | |
ETS_NORMAL = 1, | |
ETS_HOT = 2, | |
ETS_SELECTED = 3, | |
ETS_DISABLED = 4, | |
ETS_FOCUSED = 5, | |
ETS_READONLY = 6, | |
ETS_ASSIST = 7, | |
ETS_CUEBANNER = 8, | |
}; | |
enum BACKGROUNDSTATES { | |
EBS_NORMAL = 1, | |
EBS_HOT = 2, | |
EBS_DISABLED = 3, | |
EBS_FOCUSED = 4, | |
EBS_READONLY = 5, | |
EBS_ASSIST = 6, | |
}; | |
enum BACKGROUNDWITHBORDERSTATES { | |
EBWBS_NORMAL = 1, | |
EBWBS_HOT = 2, | |
EBWBS_DISABLED = 3, | |
EBWBS_FOCUSED = 4, | |
}; استفاده در OpenThemaData و DrawThemBackground |
The button's width has to to be correct, the height gets adjusted afterwards. When handling WM_INITDIALOG,
:call a single function
,reinterpret_cast<UINT_PTR>(hWndButton)
((((reinterpret_cast<DWORD_PTR>(hWndButton
return(FALSE); // Enforce WM_NCCALCSIZE| SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER,
;((SWP_FRAMECHANGED
{تنظیم حاشیه در کنترل EDIT
: wparam
EC_LEFTMARGIN=&H1
EC_RIGHTMARGIN=&H2
: Msg
EM_SETMARGINS=211 '&HD3
دسیمال 211 تبدیل به هگزا - ->> عدد دسیمال تقسیم بر 16 میشود 13 معادل آن D و حاصل تفریق عدد211 و حاصلضرب 13 در 16 میشود 3 .... نهایتا از کنار هم گذاشتن آنها D3 بدست می آید ، در تابع زیر پارامتر هندل Et ذکر شده و منظور گرفتن هندل Edit است که با FindWindowEx انجام شده.
SendMessageA Et, 211, &H1, ByVal 25
SendMessageA Et, 211, &H2, ByVal 65536 * 50
تست شده طبق شکل زیر که تمام تکست داخل EDIT BOX با Ctrl+A انتخاب شده در نتیجه مارجین یا حاشیه مشخص است . البته باید دید تغییر فونت چه تاثیری خواهد گذاشت .
SWP_FRAMECHANGED 0x0020
Applies new frame styles set using the SetWindowLongfunction. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZEis sent only when the window's size is being changed.
Fully redraw the window in its new
.position
SWP_FRAMECHANGED Sends a WM_NCCALCSIZEmessage to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
ارسال آیکون به باتن با پیام BM_SETIMAGE و تابع ارسال پیام به دیالوگ باکس و آیدی باتن که یک است. image_icon=1 , un1=1
EC_LEFTMARGIN =&H1 EC_RIGHTMARGIN =&H2
EM_SETMARGINS=&HD3
: lParam
The HIWORD specifies the new width of the right margin, in pixels. This value is ignoredif wParam does
.notinclude EC_RIGHTMARGIN
ExcludeClipRect(aMessage.WParam, fButton.Left,
top + 1,
fButton.Left + fButton.Width,
fButton.Height);
عدد پی تقسیم بر سینوس یک درجه
3.141592/0.01745240643?
180.009101472661
تمام منابع خارجی
Dim px As POINTAPI
GetCursorPos px
'ClientToScreen hwnd, px
MoveToEx hdc, 120, 30, px
LineTo hdc, 140, 30
MoveToEx hdc, 120, 30, px
LineTo hdc, 135, 15
' Quarter
MoveToEx hdc, 120, 30, px
LineTo hdc, 134, 44
MoveToEx hdc, 120, 30, px
LineTo hdc, 120, 50
' Quarter
MoveToEx hdc, 120, 30, px
LineTo hdc, 105, 44
MoveToEx hdc, 120, 30, px
LineTo hdc, 120, 10
' Quarter
MoveToEx hdc, 120, 30, px
LineTo hdc, 105, 14
MoveToEx hdc, 120, 30, px
LineTo hdc, 100, 30
Rotate
using WM_TIMER
Dim tt As RECT
Static Deg
Deg = Deg + 5
If Deg > 360 Then Deg = 0
Dim xl, yt
xl = 120: yt = 30
tt.Left = 99: tt.Top = 5: tt.right = 141: tt.bottom = 55
(FillRect hdc, tt, GetSysColorBrush(15
طول خط 20
در ربع اول If 0 < Deg < 90 Then ' Quarter
Newx = xl + Sin(Deg * Sin1) * 20
Newy = yt - Cos(Deg * Sin1) * 20
End If
در ربع دوم If 90 < Deg < 180 Then
Newx = xl + Cos(Deg * Sin1) * 20
Newy = yt + Sin(Deg * Sin1) * 20
End If
در ربع سوم If 180 < Deg < 270 Then
Newx = xl - Sin(Deg * Sin1) * 20
Newy = yt + Cos(Deg * Sin1) * 20
End If
در ربع چهارم If 270 < Deg < 360 Then
Newx = xl - Cos(Deg * Sin1) * 20
Newy = yt - Sin(Deg * Sin1) * 20
End If
MoveToEx hdc, 120, 30, px
LineTo hdc, Newx, Newy
xl = 120: yt = 30
tt.Left = 100: tt.Top = 5: tt.right = 140: tt.bottom = 55
(FillRect hdc, tt, GetSysColorBrush(15
Arc hdc, 100, 10, 140, 50, 0, 0, 0, 0
SelectObject hdc, HoldPen
Arc hdc, 115, 25, 125, 35, 0, 0, 0, 0
SelectObject hdc, HoldPen1
Newx = xl + Sin(Deg * Sin1) * 16
Newy = yt - Cos(Deg * Sin1) * 16
MoveToEx hdc, 120, 30, px
LineTo hdc, Newx, Newy
Deg = Deg + 10
DeleteObject HoldPen
DeleteObject HoldPen1
موارد پایین تست شده ... البته اینها موارد ساده ای هستند و پیش پا افتاده
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
WM_MOUSEMOVE
Dim p As POINTAPI
GetCursorPos p
ScreenToClient hwnd, p
Dim ff As RECT
Dim ff1 As RECT
SetRect ff, p.x, p.y, p.x, p.y
ff.Left = p.x - 15
ff.Top = p.y - 15
ff.right = p.x + 35
ff.bottom = p.y + 30
DrawFrameControl GetDC(hwnd), ff, DFC_BUTTON, DFCS_BUTTONPUSH
RoundRect GetDC(hwnd), ff.Left, ff.Top, ff.right, ff.bottom, 16, 16
( FillRect GetDC(hwnd), ff, GetSysColorBrush(16
Sleep 100
InvalidateRect hwnd, ff, 1
UpdateWindow hwnd
(ReleaseDC hwnd, GetDC(hwnd
انتقال کرسر به مختصات صفحه ی مشخص شده.
Moves the cursor to the specified screen coordinates. If the new coordinates are not within the screen rectangle set by the most recent ClipCursor function call, the system automatically adjusts the coordinates
.so that the cursor stays within the rectangle
در BS_OWNERDRAW یا خود Button کار نمی کند نتیجتا ترسیم شد ( منظور ناحیه ای که در تصویر پایین داخلش تکست Inside ترسیم شده) . DrawEdge و DrawTextA
dim rr as RECT
If wMsg = WM_PAINT Then
z1.Left = 285 + GetSystemMetrics(SM_CYFRAME) * 3 ' 296
z1.right = 348 + GetSystemMetrics(SM_CYFRAME) * 2 ' 355
z1.Top = 63 + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) * 2 ' 95
z1.bottom = 86 + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) + 2 ' 115
(WindProc = DrawEdge(GetWindowDC(hwnd), z1, EDGE_RAISED, BF_RECT + BF_ADJUST
End If
If wMsg = WM_LBUTTONDOWN Then 'WM_MOUSEMOVE
Dim cp As POINTAPI
SetRect rr, 285, 63, 348, 86
GetCursorPos cp
ScreenToClient hwnd, cp
rr.Left = rr.Left + 2
rr.right = rr.right - 2
rr.Top = rr.Top - cp.y + 2
rr.bottom = rr.bottom - cp.y - 2
If PtInRect(rr, cp.x, cp.y) Then
End If
اگر شکل را مشاهده کنید زمان فشردن باتن سمت چپ ماوس در مستطیل موردنظر با مختصات صفحه در قسمت کپشن ویندو هم IN ارسال میشود
کدام درست و منطقی تر است ؟
SWP_FRAMECHANGED &H20
Applies new frame styles set using the SetWindowLongfunction. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZEis sent only when the window's size is being changed
If you have changed certain window data using SetWindowLong, you must call SetWindowPos for the changes to take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED
.
(GWL_USERDATA (-21
Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
(SetWindowLong(hWnd,GWL_USERDATA,Value