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.
Printable View
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.
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 dont know VB, so could you post the translation?
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);
}