دادن ابعاد مستطیل پنجره ی مشخص شده ( ابعاد در مختصات صفحه داده میشود ) در ClientRect عدد x و y گوشه ی بالایی صفر است
Retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left
.corner of the screen
برای اضافه کردن باتن ازCreateWindowEx استفاده میشود . در زمان ساب کلاس کردن و قرار دادن در پیام SHOWWINDOW و استفاده از استایل WS_CHILD OR WS_VISIBLE اگر بخواهیم میتوان از BS_OWNERDRAW استفاده کرد و باتن خود را در پیام CTLCOLORBTB ( که lparam هندلی است برای هندل باتن ) ترسیم کرد .
فرضا اگر به InputBox در زیر باتن کنسل بخواهیم باتنی اضافه کنیم می توانیم با GetWindowRect موقعیت باتن کنسل را بگیریم منظور X و Y گوشه بالایی و با GetClientRect عرض و طول باتن Cancel را بدست آوریم ( همانطور که گفته شد GetClientRect گوشه بالایی هر کنترلی را صفر میدهد )
Dim WinRect As RECT
Dim BtnWinRect As RECT
Dim BtnClientRect As RECT
Dim CyFrame As Long
(CyFrame=GetSystemMetrics(SM_CYFRAME
(CyCaption=GetSystemMetrics(SM_CYCAPTION
GetWindowRect Hwnd,WinRect
GetWindowRect BtnHandle,BtnRect
GetClientRect BtnHandle,BtnClientRect
ابعاد زیر میشود پارامترهایی که باید در آرگومانهای تابع CreateWindowEx قراردهیم x1,y1 میشود مختصات گوشه ی بالایی سمت چپ و cx ( عرض ) و cy ( ارتفاع ) یا x2 و y2 میشود مختصات گوشه پایینی سمت راست
LeftBound=(BtnWinRect.Left-WinRect.Left)+CyFrame
TopBound=(BtnWinRect.Top-WinRect.Top)+CyFrame
(CyCaption/2)+
RightBound'
Width=BtnClientRect.Rigth-BtnClientRect.Left
BottomBound'
Height=BtnClientRect.Bottom-BtnClientRect.Top
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) and (not
WS_CAPTION) or WS_THICKFRAME)
WM_COMMAND
section of your callback, use ShowWindow(hwnd, SW_MAXIMIZE)
and ShowWindow(hwnd, SW_RESTORE)
. That's all there is to it.1) Do not use BeginPaint/EndPaint in WM_ERASEBKGND. Move that code in a WM_PAINT handler.
احتملا Rec در پیام WMPAINT باید Global یا Static تعیین شود. تست نشده ولی روال بدین شکل است .
SM_CYSIZEFRAME = SM_CYFRAME SM_CXSIZEFRAME = SM_CXFRAME
Option Compare Database
Public WinProcOld As LongPtr
(Public Function SubClassWnd(hwnd As LongPtr
( WinProcOld = SetWindowLongPtr(hwnd, GWL_WNDPROC, AddressOf WindProc
End Function
(Public Function UnSubclassWnd(hwnd As LongPtr
SetWindowLongPtr hwnd, GWL_WNDPROC, WinProcOld
WinProcOld = 0
End Function
'This is your subclassed window procedure
Public Function WindProc(ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
'WM_COMMAND message is sent to parent window to notify of a button click
'The lParam parameter tells the hWnd of the button
'If wMsg = WM_CTLCOLORBTN Then WindProc = CreateSolidBrush(RGB(0, 0, 10))
If wMsg = WM_COMMAND Then
If lParam = GetDlgItem(hwnd, 4) Then MsgBox "Button was clicked!"
If lParam = GetDlgItem(hwnd, 1) Then MsgBox "Button was clicked!"
End If
If wMsg = WM_DESTROY Then
UnSubclassWnd hwnd
End If
WindProc = CallWindowProc(WinProcOld, hwnd, wMsg, wParam, ByVal lParam)
End Functionc
CW_USEDEFAULT = &80000000TTM_ADDTOOL = &404TTM_TRACKACTIVATE = &411TTM_UPDATETIPTEXT = &40CTTS_BALLOON = 64TTS_ALWAYSTIP = 1TTS_NOPREFIX = 2WS_POPUP = &80000000
بسته شدن پنجره زمانیکه کپشن به عدد 10 رسید.
: 64BIT
Declare PtrSafe Function SetTimer Lib "user32" Alias "SetTimer" (ByVal hWnd As LongPtr, ByVal nIDEvent As LongPtr, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Declare PtrSafe Function KillTimer Lib "user32" Alias "KillTimer" (ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private Const TIMER1 = 1001
SetTimer hWndMainWnd,TIMER1,1000,0
(WndProc(HWND hWnd,UINT uMsg,WPARAM
Static xtimer
Select Case uMsg
xtimer=xtimer+1
case WM_TIMER
if wParam = TIMER1
SetWindowTextA hwnd, xtimer
If xtimer = 10 Then SendMessageA hwnd, WM_CLOSE, 0, 0: xtimer = 0
End if
عدم نمایش شورتکات در ادیت کنترل در ساب کلاس کردن Case WM_CONTEXTMENU
Exit Function
Case WM_DESTROY, WM_NCDESTROY
KillTimer hwnd, TIMER1
xtimer = 0
کار سختی نیست از منبعی که در انتهای صفحه آمده استفاده شده که تابع ویندوزی است
Declare PtrSafe Function PtInRect Lib "user32" (lpRect As RECT, pt As POINTAPI) As Long'
Use Belows Only
Declare PtrSafe Function PtInRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
If PtInRect(nn, p.x, p.y) Then
" ... MsgBox "You Clicked Me
End If
.....RedrawWindow
مورد بالا تست شده
در 32 بیت
ارسال تکست به کپشن پنجره در صورت فشردن باتن Ok در صورتیکه تعداد کاراکتر داخل کنترل ادیت بیشتر از 13 باشد
WndProc
Case WM_COMMAND
Case 1
(InputDataLen=SendDlgItemMessage(hwnd,EM_LINELENGTH,0,0
if InputDataLen>14 Then
"....SetWindowTextA hwnd,"Exceed Data
Sleep 1000
End If
Case 2
Case 4900
End Select
این پیام هنگامی ارسال میشود که یوزر اقدام به تغییر متن در کنترل EDIT کرده است. ( منظور پیام EN_CHANGE )
Type RECT
left As Long
right As Long
top As Long
bottom As Long
End Typd
Type NCCALCSIZE_PARAMS
rgrc(3) As RECT
lppos As WINDOWPOS
End Type
Type WINDOWPOS
x As Long
y As Long
cx As Long ' width
cy As Long ' heigth
End Type
EM_SHOWBALLOONTIP
displays a balloon tip associated with an edit control
Parameters
: wParam
Not used; must be zero
lParam
Tooltip iconsconst
TTI_NONE = 0
TTI_INFO = 1
TTI_WARNING = 2
TTI_ERROR = 3
TTI_INFO_LARGE = 4
TTI_WARNING_LARGE = 5
TTI_ERROR_LARGE = 6
ارسال توسط تابع SendMessageA :
SendMessageA hwndEdit,EM_SETCUEBANNER,0,ByVal
"User Name"
EM_SETCUEBANNER
.user clicks in the control
.display as the textual cue
دراکسس در قسمت پراپرتی Format تکست باکس @ و بعد SemiColon و تکست موردنظر در داخل دابل کوتیشن ها
EM_SETRECT
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