VB Code:
  1. Public Sub ChildColorBorder(frmChild As Form, lngColor As Long)
  2. 'Change the Active Child Border Color
  3.  
  4.    #If kDEBUGON Then
  5.        Debug.Print "Begin ColorBorder"
  6.    #End If
  7.  
  8.     Dim hWindowDC As Long
  9.     Dim hOldPen As Long
  10.     Dim nLeft As Long
  11.     Dim nRight As Long
  12.     Dim nTop As Long
  13.     Dim nBottom As Long
  14.     Dim Ret As Long
  15.     Dim hMyPen As Long
  16.     Dim WidthX As Long
  17.    
  18.     'Pen Styles
  19.     Const PS_SOLID = 0
  20.    
  21.     '------------
  22.     WidthX = 8
  23.  
  24.     'hWindowDC = frmChild.hDC                'this draws inside the form (client)
  25.     hWindowDC = GetWindowDC(frmChild.hwnd)   'this draws outside the form (non-client)
  26.    
  27.     hMyPen = CreatePen(PS_SOLID, WidthX, lngColor)
  28.    
  29.     'Initialize misc variables
  30.     nLeft = 0
  31.     nTop = 0
  32.     nRight = frmChild.Width / Screen.TwipsPerPixelX
  33.     nBottom = frmChild.Height / Screen.TwipsPerPixelY
  34.    
  35.     hOldPen = SelectObject(hWindowDC, hMyPen)
  36.    
  37.     Ret = LineTo(hWindowDC, nLeft, nBottom)
  38.     Ret = LineTo(hWindowDC, nRight, nBottom)
  39.     Ret = LineTo(hWindowDC, nRight, nTop)
  40.     Ret = LineTo(hWindowDC, nLeft, nTop)
  41.  
  42.     Ret = SelectObject(hWindowDC, hOldPen)
  43.     Ret = DeleteObject(hMyPen)
  44.     Ret = ReleaseDC(frmChild.hwnd, hWindowDC)
  45.    
  46.     #If kDEBUGON Then
  47.         Debug.Print "End ColorBorder"    '; hWindowDC
  48.     #End If
  49.  
  50. End Sub