VB Code:
Public Sub ChildColorBorder(frmChild As Form, lngColor As Long) 'Change the Active Child Border Color #If kDEBUGON Then Debug.Print "Begin ColorBorder" #End If Dim hWindowDC As Long Dim hOldPen As Long Dim nLeft As Long Dim nRight As Long Dim nTop As Long Dim nBottom As Long Dim Ret As Long Dim hMyPen As Long Dim WidthX As Long 'Pen Styles Const PS_SOLID = 0 '------------ WidthX = 8 'hWindowDC = frmChild.hDC 'this draws inside the form (client) hWindowDC = GetWindowDC(frmChild.hwnd) 'this draws outside the form (non-client) hMyPen = CreatePen(PS_SOLID, WidthX, lngColor) 'Initialize misc variables nLeft = 0 nTop = 0 nRight = frmChild.Width / Screen.TwipsPerPixelX nBottom = frmChild.Height / Screen.TwipsPerPixelY hOldPen = SelectObject(hWindowDC, hMyPen) Ret = LineTo(hWindowDC, nLeft, nBottom) Ret = LineTo(hWindowDC, nRight, nBottom) Ret = LineTo(hWindowDC, nRight, nTop) Ret = LineTo(hWindowDC, nLeft, nTop) Ret = SelectObject(hWindowDC, hOldPen) Ret = DeleteObject(hMyPen) Ret = ReleaseDC(frmChild.hwnd, hWindowDC) #If kDEBUGON Then Debug.Print "End ColorBorder" '; hWindowDC #End If End Sub


Reply With Quote