Exemplo n.º 1
0
def write_debug_text(ctrl, text):
    "Write some debug text over the window"
    dc = win32functions.CreateDC(u"DISPLAY", None, None, None)

    if not dc:
        raise ctypes.WinError()

    rect = ctrl.Rectangle

    #ret = win32functions.TextOut(
    #    dc, rect.left, rect.top, unicode(text), len(text))
    ret = win32functions.DrawText(dc, unicode(text), len(text),
                                  ctypes.byref(rect),
                                  win32defines.DT_SINGLELINE)

    if not ret:
        raise ctypes.WinError()
Exemplo n.º 2
0
def draw_outline(ctrl,
                 colour='green',
                 thickness=2,
                 fill=win32defines.BS_NULL,
                 rect=None):
    "Draw an outline around the window"
    colours = {
        "green": 0x00ff00,
        "blue": 0xff0000,
        "red": 0x0000ff,
    }

    # if it's a known colour
    if colour in colours:
        colour = colours[colour]

    if not rect:
        rect = ctrl.Rectangle

    # create the pen(outline)
    hPen = win32functions.CreatePen(win32defines.PS_SOLID, thickness, colour)

    # create the brush (inside)
    brush = win32structures.LOGBRUSH()
    brush.lbStyle = fill
    brush.lbHatch = win32defines.HS_DIAGCROSS
    hBrush = win32functions.CreateBrushIndirect(ctypes.byref(brush))

    # get the Device Context
    dc = win32functions.CreateDC(u"DISPLAY", None, None, None)

    # push our objects into it
    win32functions.SelectObject(dc, hBrush)
    win32functions.SelectObject(dc, hPen)

    win32functions.Rectangle(dc, rect.left, rect.top, rect.right, rect.bottom)

    # Delete the brush and pen we created
    win32functions.DeleteObject(hBrush)
    win32functions.DeleteObject(hPen)

    # delete the Display context that we created
    win32functions.DeleteDC(dc)