کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

OffsetRect / جابجائی



Type INSTBUT
uCmdId ' WM_COMMAND message
uState As Integer
fButtonDown ' ?button up/down
fMouseDown As Boolean
WNDPROC oldproc ' need to remember the old window procedure

 cxLeftEdge As Long
cxRightEdge As Long
cyTopEdge As Long
cyBottomEdge As Long
End Type 

SubClass Edit Control

(BOOL InsertButton(hwnd,uCmdId
Dim pbut As InsBut
((pbut=heapalloc(GetProcessHeap(),0, Len(InsBut
if Not pbut  Then InsertButton=False
pbut.uCmdId=uCmdId
pbut.fButtonDown=FALSE
replace the old window procedure with our new one'
pbut.oldproc=SetWindowLong(hwnd,
(GWL_WNDPROC,InsButProc,
associate our button state structure with the window '
(SetWindowLong(hwnd,GWL_USERDATA, pbut
force the edit control to update its non-client area'
SetWindowPos(hwnd,0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOZORDER)
InsertButton=True


GetButtonRect(ByRef pbut As InsBut,ByRef rc As RECT 

)

rc.right=rc.right-pbut.cxRightEdge
rc.top=rc.top+pbut.cyTopEdge
rc.bottom=rc.bottom-pbut.cyBottomEdge
(rc.left=rc.right-GetSystemMetrics(SM_CXVSCROLL
'take into account any scrollbars in the edit control
if(rc.cxRightEdge>rc.cxLeftEdge) Then  OffsetRect rc,pbut.cxRightEdge-pbut.cxLeftEdge,0
End if

Dim rc As RECT
Dim pt As POINT

Dim prect As RECT
Dim oldrect As RECT
'get the button state structure InsBut *pbut = (InsBut *)GetWindowLong(hwnd, GWL_USERDATA)

case WM_NCCALCSIZE
prect =(RECT *)lParam
oldrect= *prect
let the old wndproc allocate space for the borders or' 
.any other non-client space
CallWindowProc(pbut.oldproc,hwnd,msg, 
(wParam,lParam,
calculate what the size of each window border is'
we need to know where the button is going to live
pbut.cxLeftEdge=prect.left-oldrect.left pbut.cxRightEdge=oldrect.right-prect.right
pbut.cyTopEdge=prect.top-oldrect.top
pbut.cyBottomEdge=oldrect.bottom
prect.bottom-
now we can allocate additional space by deflating the' 
rectangle even further. Our button will go on the right-hand side and will be the same width as a scrollbar button
-prect.right=prect.right
(GetSystemMetrics(SM_CXVSCROLL
'that's it! Easy or what!
return 0



case WM_NCLBUTTONDOWN
'get the screen coordinates of the mouse
(pt.x=GET_X_LPARAM(lParam
(pt.y=GET_Y_LPARAM(lParam
'get the position of the inserted button'
GetWindowRect hwnd,rc
GetButtonRect pbut,rc
check that the mouse is within the inserted button'
if(PtInRect(rc, pt)) Then
SetCapture hwnd
pbut.uState=1
pbut.fMouseActive=TRUE
redraw the non-client area to reflect the change'
RedrawNC hwnd
End If


Dim rc As RECT
Dim pt As POINT
Dim oldstate

case WM_MOUSEMOVE
...if(pbut.fMouseActive=FALSE) Exit 
get the CLIENT coordinates of the mouse'
(pt.x=GET_X_LPARAM(lParam
pt.y=GET_Y_LPARAM(lParam)
ClientToScreen hwnd,pt
get the position of the inserted button'
GetWindowRect hwnd,rc
GetButtonRect pbut,rc
oldstate=pbut.uState
check that the mouse is within the inserted button'
if(PtInRect(rc,pt)) Then
pbut.uState=1
else
pbut.uState=0
End if
redraw the non-client area to reflect the change'
to prevent flicker, we only redraw the button if its state'
has changed if(oldstate<>pbut.uState Then'
RedrawNC hwnd



Dim rc As RECT
Dim pt As POINT
Dim oldstate As Integer

case WM_LBUTTONUP
...if(pbut.fMouseActive=FALSE) Exit
get the CLIENT coordinates of the mouse'
(pt.x=GET_X_LPARAM(lParam
(pt.y=GET_Y_LPARAM(lParam
ClientToScreen hwnd,pt
get the position of the inserted button'
GetWindowRect hwnd,rc
GetButtonRect pbut,rc
check that the mouse is within the inserted button'
if(PtInRect(rc,pt)) Then
PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(pbut.uCmdId, BN_CLICKED),0)
ReleaseCapture
pbut.uState = 0
pbut.fMouseDown=FALSE
.redraw the non-client area to reflect the change'
RedrawNC hwnd


case WM_NCHITTEST
get the screen coordinates of the mouse'
(pt.x=GET_X_LPARAM(lParam
(pt.y=GET_Y_LPARAM(lParam
get the position of the inserted button'
GetWindowRect hwnd,rc
GetButtonRect pbut,rc
check that the mouse is within the inserted button'
 if(PtInRect(rc,pt)) Then
return HTBORDER
else
...Exit
End if 

case WM_NCDESTROY
oldproc=pbut.oldproc
HeapFree(GetProcessHeap(),0, pbut)
return CallWindowProc(oldproc, hwnd,msg, wParam,
(lParam,

نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد