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

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

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

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

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

CreatePen ساخت قلم برای ترسیم



HPEN CreatePen( int iStyle, int cWidth, COLORREF color );


()Edit::OnNcPaint

pDC=GetDC( ) ? GetWindowDC
GetWindowRect Edithwnd,Crect 
OffsetRect Crect,-rect.left,-rect.top
'Draw a single line around the outside
(brush=RGB( 255, 0, 0
FrameRect pDC,Crect,brush ReleaseDC hwnd,pDC


Const PS_SOLID = 0
Const PS_DASH = 1
Const PS_DOT = 2
Const PS_DASHDOT = 3
Const PS_DASHDOTDOT = 4
Const PS_NULL = 5
Const PS_INSIDEFRAME = 6



((hPen=CreatePen(PS_DASH,0,RGB(0,255, 0
(hOldPen=SelectObject(hDC,hPen
Ellipse hDC, 100, 150, 350, 300
SelectObject hDC, hOldPen
DeleteObject hPen




مورد زیر طبق شکل تست شده 


حتما در WndProc در پیام SHOWWINDOW تابع زیر اعمال گردد
SetWindowPos hwnd,0,0,0,0,0,SWP_FRAMECHANGED 

ساب کلاس کردن  کنترل  Edit 

Public Function SubClassEdit(ByVal hwnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, _
                            ByVal lParam As LongPtr, ByVal uId As LongPtr, ByVal dwData As LongPtr) As Long
Dim nccsp As NCCALCSIZE_PARAMS
Select Case Msg

Case WM_NCPAINT
     (hdc = GetDC(hwnd
     Dim rClient As RECT
     GetClientRect hwnd, rClient
    ( hpen = CreatePen(ps_solid, 2, vbRed
    ( holdpen = SelectObject(hdc, hpen
     RoundRect hdc, rClient.Left - 2, rClient.Top - 2, rClient.right + 2, rClient.bottom + 2, 6, 6
     ReleaseDC hwnd, hdc
     DeleteObject holdpen
Case WM_DESTROY
      RemoveWindowSubclass hwnd, SubClassEdit, 0
      End Select
      
(SubClassEdit = DefSubclassProc(hwnd, Msg, wParam, ByVal lParam
                            
End Function


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







محصور کردن کرسر به منطقه مستطیل شکل در صفحه




ClipCurSor 
.Confines the cursor to a rectangular area on the screen

Parameters

lpRect

Type: const RECT*

A pointer to the structure that contains the screen coordinates of the upper-left and lower-right corners of the confining rectangle. If this parameter is NULL, 
.the cursor is free to move anywhere on the screen



Dim ptClientUL As POINTAPI  'client area upper lef corner 
Dim ptClientLR As POINTAPI 'client area lower right corner 
Static rcBmp As RECT 

WM_CREATE

(hdc=GetDC(hwnd
(hdcCompat=CreateCompatibleDC(hdc
SelectObject hdcCompat, hbmp
((hpenDot=CreatePen(PS_DOT,1,RGB(0, 0, 0
SetRect rcBmp, 1, 1, 34, 34

WM_PAINT

BeginPaint hwnd,ps
Rectangle ps.hdc,rcBmp.left,rcBmp.top,rcBmp.right, rcBmp.bottom
StretchBlt ps.hdc,rcBmp.left+1,rcBmp.top+1,(rcBmp.right-rcBmp.left)-2,(rcBmp.bottom-rcBmp.top)-2, hdcCompat,0,0,32,32,SRCCOPY
EndPaint hwnd,ps

WM_MOVE,WM_SIZE

'Convert the client coordinates of the client-area rectangle to screen coordinates and save them in a rectangle.The rectangle is passed to the ClipCursor function during WM_LBUTTONDOWN processing. 

GetClientRect hwnd,rcClient
ptClientUL.x = rcClient.left
ptClientUL.y = rcClient.top
ptClientLR.x = rcClient.right
ptClientLR.y = rcClient.bottom ClientToScreen hwnd,ptClientUL ClientToScreen hwnd,ptClientLR
SetRect rcClient,ptClientUL.x, ptClientUL.y,ptClientLR.x,ptClientLR.y)

WM_LBUTTONDOWN

ClipCursor rcClient
pt.x = (LONG) LOWORD(lParam) 
pt.y = (LONG) HIWORD(lParam)
if (PtInRect(&rcBmp, pt)) Then 
hdc=GetDC(hwnd)
SelectObject hdc,hpenDot
Rectangle hdc,rcBmp.left,rcBmp.top, rcBmp.right,rcBmp.bottom)
fDragRect=TRUE
ReleaseDC hwnd,hdc

WM_LBUTTONUP

' Release the mouse cursor.
ClipCursor  0

Gradient Button ( باتن با سطح شیب دار) / DrawCloseButton ( رسم باتن کلوز )



Dim rc As RECT
rc.left = 0
rc.top = 0
rc.right = 260
rc.bottom = 80
Dim hpen
draw gradient button'
Dim i As Integer
i=0
Do
((hpen=CreatePen(PS_SOLID,4,RGB(150-i,0,0
SelectObject hdc, hpen
Rectangle hdc, 0, 0 + i, 262, 1 + i
DeleteObject hpen
(SetBkColor hdc,RGB(130,0,0
(SetTextColor hdc, RGB(255,255,255
TextOut hdc,90,27,"Hello World",11
i=i+1
Loop Until i<80

PS_SOLID=0
PS_DASH=1
PS_DOT=2
PS_DASHDOT=3
PS_DASHDOTDOT=4
PS_INSIDEFRAME=6
PS_GEOMETRIC=65536
PS_ENDCAP_FLAT=512
PS_ENDCAP_MASK=3840
PS_JOIN_BEVEL=4096
PS_JOIN_MITER=8192



(DrawCloseButton(HDC hdc
RECT rc
rc.left=0
rc.top=0
rc.right=30
rc.bottom=30
((br=CreateSolidBrush(RGB(0, 0, 0
FillRect hdc,rc,br
(SetBkColor hdc, RGB(0, 0, 0
(SetTextColor hdc,RGB(255, 255, 255
(TextOut hdc,10,8,"X",1