Results 1 to 4 of 4

Thread: Window Border

  1. #1
    ChimpFace9000
    Guest

    Post

    How do i draw a border around the window the mouse is over? I want to do this so the user knows which window hes getting info about.

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I have it in VB. It is not to hard to translate it:
    Code:
    Public Sub DrawBorder(hWnd As Long)
    Dim hDC As Long
    Dim rc As RECT
    Dim hPen As Long
    Dim retval As Long
    retval = GetWindowRect(hWnd, rc)
    hDC = GetWindowDC(hWnd)
    retval = SaveDC(hDC)
    retval = SetROP2(hDC, R2_NOT)
    hPen = CreatePen(PS_INSIDEFRAME, 3 * GetSystemMetrics(SM_CXBORDER), RGB(0, 0, 0))
    retval = SelectObject(hDC, hPen)
    retval = SelectObject(hDC, GetStockObject(NULL_BRUSH))
    retval = Rectangle(hDC, 0, 0, rc.Right - rc.Left, rc.Bottom - rc.Top)
    retval = RestoreDC(hDC, -1)
    retval = ReleaseDC(hwndsubject, hDC)
    retval = DeleteObject(hPen)
    End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    ChimpFace9000
    Guest
    I dont know VB, so could you post the translation?

  4. #4
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    Code:
    void DrawBorder(HWND hwnd)
    {
         HDC hdc;
         RECT rc;
         long hPen;
         
         GetWindowRect(hwnd, rc);
         hdc =  GetWindowDC(hwnd);
         SaveDC(hdc);
         SetROP2(hdc, R2_NOT);
         hPen = CreatePen(PS_INSIDEFRAME, 3 * GetSystemMetrics(SM_CXBORDER), RGB(0,0,0));
         SelectObject(hdc, hPen);
         SelectObject(hdc, GetStockObject(NULL_BRUSH));
         Rectangle(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top);
         RestoreDC(hdc, -1);
         ReleaseDC(hwnd, hdc);
         DeleteObject(hPen);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width