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

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

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

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

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

ترسیم ناحیه TitleBar



BOOL IsWindowEnabled( [in] HWND hWnd



Declare PtrSafe  Functuon IsWindowEnabled lib "user32" (ByVal hWnd As LongPtr) As Boolean


If idHook = HCBT_ACTIVATE Then
If IsWindowEnabled(GetParent(wParam)) Then
UnhookWindowsHookEx lHook
MsgBox "You can't format a Modeless Userform.", vbCritical
Exit Function
End If



'Put Inside WindowProc


Dim tPt As POINTAPI, tClientRect As RECT
Dim loword As Long, hiword As Long
GetClientRect hwnd, tClientRect
Select Case Msg
Case WM_NCLBUTTONDOWN SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE Case WM_ACTIVATE
If wParam = 0 Then
SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
SetWindowLong hwnd, GWL_STYLE, (GetWindowLong(hwnd, GWL_STYLE) And Not WS_SYSMENU)
DrawTitleBar(hwnd, lTitleBarColor)
InvalidateRect hwnd, tClientRect, 0
Case WM_EXITSIZEMOVE
DrawTitleBar(hwnd, lTitleBarColor)
InvalidateRect hwnd, tClientRect, 0
Case WM_NCPAINT
If bDrawn = False Then bDrawn = True: DrawTitleBar(hwnd, lTitleBarColor)
Exit Function

Case WM_SYSCOMMAND
GetHiLoword CLng(lParam), loword, hiword
tPt.x = loword : tPt.y = hiword
Dim lngPtr As LongPtr
CopyMemory lngPtr, tPt, LenB(tPt)
If PtInRect(tUpdatedCloseButtonRect, lngPtr) Then
If PtInRect(tUpdatedCloseButtonRect, tPt.x, tPt.y) Then
If PtInRect(tUpdatedCloseButtonRect, tPt.x, tPt.y) Then

DrawTitleBar(hwnd, lTitleBarColor, True) Do DoEvents
Loop Until GetAsyncKeyState(vbKeyLButton) = 0
GetCursorPos tPt

CopyMemory lngPtr, tPt, LenB(tPt)

If PtInRect(tUpdatedCloseButtonRect, lngPtr) Then
If PtInRect(tUpdatedCloseButtonRect, tPt.x, tPt.y) Then
If PtInRect(tUpdatedCloseButtonRect, tPt.x, tPt.y) Then
If bCloseButtonPressed Then Sleep 200 Unload oForm
End If
End If

If bCloseButtonPressed Then
DrawTitleBar hwnd, lTitleBarColor InvalidateRect hwnd, tClientRect, 0
End If

Case WM_DESTROY
SetWindowLong hwnd, GWL_WNDPROC, lPrevWinProc
SetClassLong hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) And Not CS_DROPSHADOW


'DrawTitleBar function

Dim p1 As POINTAPI, p2 As POINTAPI
Dim tFormRect As RECT, tFillRect As RECT
Dim tPs As PAINTSTRUCT

BeginPaint hwnd, tPs
hdc = GetWindowDC(hwnd)
Color = CaptionColor
hBrush = CreateBrushIndirect(Color)
Call GetWindowRect(hwnd, tFormRect)


bCloseButtonPressed = PressedCloseButton

If Not PressedCloseButton Then
SetRect tFormRect, 0, 0, tFormRect.Right, tFormRect.Bottom
SetRect tFillRect, 0, 5, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE) + tFormRect.Bottom
OffsetRect tFillRect, tWinRect.Right - tWinRect.Left - GetSystemMetrics(SM_CXSIZE), 0
FillRect hdc, tFormRect, hBrush
DeleteObject(hBrush)
DrawFrameControl hdc, tCloseRect, DFC_CAPTION, DFCS_CAPTIONCLOSE Else
DrawFrameControl hdc, tCloseRect, DFC_CAPTION, DFCS_CAPTIONCLOSE + DFCS_PUSHED
End If

If bDropShadow Then
SetClassLong hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) Or CS_DROPSHADOW
End If

SetBkMode hdc, 1
SetTextColor hdc, lFontColor
CreateFont(hdc) 'CreateFontIndirect
TextOut hdc, 4, 4, sCaptionText, Len(sCaptionText)
GetClientRect hwnd, tCloseRect
With tCloseRect
.Bottom = GetSystemMetrics(SM_CYCAPTION)
.Left = .Right - 20
.Right = .Right + 3
.Top = .Top + 4
End With

With tCloseRect
p1.x = .Left - 2: p1.y = .Top - 2
p2.x = .Right: p2.y = .Bottom - GetSystemMetrics(SM_CYCAPTION) - 2 End With

ClientToScreen hwnd, p1
ClientToScreen hwnd, p2

With tUpdatedCloseButtonRect
.Left = p1.x: .Top = p1.y - GetSystemMetrics(SM_CYCAPTION)
.Right = p2.x: .Bottom = p2.y
End With

ReleaseDC hwnd, hdc
EndPaint hwnd, tPs





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