예제 #1
0
def OnPaint_1(hwnd, msg, wp, lp):
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    br = win32gui.CreateSolidBrush(win32api.RGB(255, 0, 0))
    win32gui.SelectObject(dc, br)
    angle = win32gui.GetWindowLong(hwnd, win32con.GWL_USERDATA)
    win32gui.SetWindowLong(hwnd, win32con.GWL_USERDATA, angle + 2)
    r_angle = angle * (math.pi / 180)
    win32gui.SetWorldTransform(
        dc, {
            'M11': math.cos(r_angle),
            'M12': math.sin(r_angle),
            'M21': math.sin(r_angle) * -1,
            'M22': math.cos(r_angle),
            'Dx': 250,
            'Dy': 250
        })
    win32gui.MoveToEx(dc, 250, 250)
    win32gui.BeginPath(dc)
    win32gui.Pie(dc, 10, 70, 200, 200, 350, 350, 75, 10)
    win32gui.Chord(dc, 200, 200, 850, 0, 350, 350, 75, 10)
    win32gui.LineTo(dc, 300, 300)
    win32gui.LineTo(dc, 100, 20)
    win32gui.LineTo(dc, 20, 100)
    win32gui.LineTo(dc, 400, 0)
    win32gui.LineTo(dc, 0, 400)
    win32gui.EndPath(dc)
    win32gui.StrokeAndFillPath(dc)
    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #2
0
def OnPaint(hwnd, msg, wp, lp):
    global dx
    font = win32gui.LOGFONT()
    font.lfFaceName = "Consolas"
    font.lfHeight = 48
    # font.lfWidth=font.lfHeight
    # font.lfWeight=150
    # font.lfItalic=1
    # font.lfUnderline=1
    hfont = win32gui.CreateFontIndirect(font)
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    l, t, r, b = win32gui.GetClientRect(hwnd)
    br = win32gui.CreateSolidBrush(win32api.RGB(0, 0, 255))
    bitmap = win32gui.CreateBitmap(20, 5, 4, 1, None)
    win32gui.SelectObject(dc, bitmap)
    win32gui.SelectObject(dc, br)
    win32gui.SelectObject(dc, hfont)
    win32gui.SetTextColor(
        dc, win32api.RGB(randint(1, 255), randint(1, 255), randint(1, 255)))
    win32gui.DrawText(dc, 'hello', -1, (100, 100, 300, 300), 0)
    win32gui.FillRect(dc, (200 + dx, 200 + dx, 100 + dx, 100 + dx), br)
    dx = (dx + 10) % 100
    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #3
0
def OnPaint_2(hwnd, msg, wp, lp):
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    l, t, r, b = win32gui.GetClientRect(hwnd)

    for x in range(25):
        vertices = (
            {'x': int(random.random() * r),
             'y': int(random.random() * b),
             'Red': int(random.random() * 0xff00),
             'Green': 0,
             'Blue': 0,
             'Alpha': 0},
            {'x': int(random.random() * r),
             'y': int(random.random() * b),
             'Red': 0,
             'Green': int(random.random() * 0xff00),
             'Blue': 0,
             'Alpha': 0},
            {'x': int(random.random() * r),
             'y': int(random.random() * b),
             'Red': 0,
             'Green': 0,
             'Blue': int(random.random() * 0xff00),
             'Alpha': 0},
        )
        mesh = ((0, 1, 2),)
        win32gui.GradientFill(
            dc, vertices, mesh, win32con.GRADIENT_FILL_TRIANGLE)
    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #4
0
def onPaint(hwnd, msg, wp, lp):
    hDc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(hDc, win32con.GM_ADVANCED)

    codghostdrawing.drawSoldiers(hDc, container, globalLock)

    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #5
0
파일: bf4main.py 프로젝트: ieralt/GLHF
def onPaint(hwnd, msg, wp, lp):
    hDc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(hDc, win32con.GM_ADVANCED)
    bf4drawing.setTextColor(hDc)

    bf4drawing.drawCrossHair(hDc, centerX, centerY, size=10)
    bf4drawing.drawSoldiers(hDc, dataContainer, globalLock, centerX, centerY)

    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #6
0
def OnPaint(hwnd, msg, wp, lp):
	global dx
	dc, ps=win32gui.BeginPaint(hwnd)
	win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
	l,t,r,b=win32gui.GetClientRect(hwnd)
	br=win32gui.CreateSolidBrush(win32api.RGB(0,0,255))
	win32gui.SelectObject(dc, br)
	win32gui.FillRect(dc,(200+dx,200+dx,100+dx,100+dx),br)
	dx=(dx+10)%100
	win32gui.EndPaint(hwnd, ps)
	return 0
예제 #7
0
def OnPaint_2(hwnd, msg, wp, lp):
    dc, ps = win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    l, t, r, b = win32gui.GetClientRect(hwnd)

    for x in range(25):
        vertices = (
            {
                "x": int(random.random() * r),
                "y": int(random.random() * b),
                "Red": int(random.random() * 0xFF00),
                "Green": 0,
                "Blue": 0,
                "Alpha": 0,
            },
            {
                "x": int(random.random() * r),
                "y": int(random.random() * b),
                "Red": 0,
                "Green": int(random.random() * 0xFF00),
                "Blue": 0,
                "Alpha": 0,
            },
            {
                "x": int(random.random() * r),
                "y": int(random.random() * b),
                "Red": 0,
                "Green": 0,
                "Blue": int(random.random() * 0xFF00),
                "Alpha": 0,
            },
        )
        mesh = ((0, 1, 2), )
        win32gui.GradientFill(dc, vertices, mesh,
                              win32con.GRADIENT_FILL_TRIANGLE)
    win32gui.EndPaint(hwnd, ps)
    return 0
예제 #8
0
        def wnd_proc(h_wnd, message, w_param, l_param):
            """Displays a transparent window with some graphic elements
			Displays a transparent window with some graphic elements
			:param h_wnd: an input argument
			:returns: nothing
			"""
            if message == win32con.WM_QUIT:
                # print("Closing the window overlay")
                win32gui.PostQuitMessage(0)
                return 0

            if message == win32con.WM_PAINT:
                hdc, paint_struct = win32gui.BeginPaint(h_wnd)
                win32gui.SetGraphicsMode(hdc, win32con.GM_ADVANCED)
                win32gui.BringWindowToTop(h_wnd)

                for r in self.graphical_elements:

                    if 'geometry' in r:
                        geometry = r['geometry']
                    else:
                        geometry = None
                    if 'x' in r:
                        x = r['x'] - self.x_min
                    else:
                        x = 0
                    if 'y' in r:
                        y = r['y'] - self.y_min
                    else:
                        y = 0
                    if 'width' in r:
                        width = r['width']
                    else:
                        width = 100
                    if 'height' in r:
                        height = r['height']
                    else:
                        height = 100
                    if 'xyrgb_array' in r:
                        xyrgb_array = r['xyrgb_array']
                    else:
                        xyrgb_array = ((15, 15, 255, 0, 0), (15, 45, 0, 255,
                                                             0), (45, 30, 0, 0,
                                                                  255))
                    if 'color' in r:
                        color_r = r['color'][0]
                        color_g = r['color'][1]
                        color_b = r['color'][2]
                    else:
                        color_r = 255
                        color_g = 0
                        color_b = 0

                    if 'thickness' in r:
                        thickness = r['thickness']
                    else:
                        thickness = 0

                    if 'angle' in r:
                        angle = r['angle']
                    else:
                        angle = 0

                    if 'geometry' in r and r['geometry'] is Shape.triangle:
                        vertices = ()
                        for xyrgb in xyrgb_array:
                            vertices = vertices + (
                                {
                                    'x': int(round(xyrgb[0])) - self.x_min,
                                    'y': int(round(xyrgb[1])) - self.y_min,
                                    'Red': xyrgb[2] * 256,
                                    'Green': xyrgb[3] * 256,
                                    'Blue': xyrgb[4] * 256,
                                    'Alpha': 0
                                }, )
                        mesh = ((0, 1, 2), )
                        win32gui.GradientFill(hdc, vertices, mesh,
                                              win32con.GRADIENT_FILL_TRIANGLE)

                    if 'brush_color' in r:
                        brush_color_r = r['brush_color'][0]
                        brush_color_g = r['brush_color'][1]
                        brush_color_b = r['brush_color'][2]
                    else:
                        brush_color_r = 255
                        brush_color_g = 255
                        brush_color_b = 255

                    if thickness == 0:
                        color_r = brush_color_r
                        color_g = brush_color_g
                        color_b = brush_color_b

                    if 'font_size' in r:
                        font_size = r['font_size']
                    else:
                        font_size = 18

                    if 'font_name' in r:
                        font_name = r['font_name']
                    else:
                        font_name = "Arial"

                    my_brush = None
                    if 'brush' in r and width > 1 and height > 1:
                        brush = r['brush']
                        brush_color = win32api.RGB(brush_color_r,
                                                   brush_color_g,
                                                   brush_color_b)
                        if brush is Brush.solid:
                            my_brush = win32gui.CreateSolidBrush(brush_color)
                        elif brush is Brush.b_diagonal:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_BDIAGONAL, brush_color)
                        elif brush is Brush.cross:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_CROSS, brush_color)
                        elif brush is Brush.diag_cross:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_DIAGCROSS, brush_color)
                        elif brush is Brush.f_diagonal:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_FDIAGONAL, brush_color)
                        elif brush is Brush.horizontal:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_HORIZONTAL, brush_color)
                        elif brush is Brush.vertical:
                            my_brush = win32gui.CreateHatchBrush(
                                win32con.HS_VERTICAL, brush_color)

                        old_brush = win32gui.SelectObject(hdc, my_brush)
                    pen = win32gui.CreatePen(
                        win32con.PS_GEOMETRIC, thickness,
                        win32api.RGB(color_r, color_g, color_b))
                    old_pen = win32gui.SelectObject(hdc, pen)

                    if 'center_of_rotation' in r:
                        center_of_rotation_x = r['center_of_rotation'][0]
                        center_of_rotation_y = r['center_of_rotation'][1]
                    else:
                        center_of_rotation_x = 0
                        center_of_rotation_y = 0

                    if angle != 0:
                        r_angle = angle * (math.pi / 180)
                        Py_XFORM = win32gui.GetWorldTransform(hdc)
                        win32gui.SetWorldTransform(
                            hdc, {
                                'M11': math.cos(r_angle),
                                'M12': math.sin(r_angle),
                                'M21': math.sin(r_angle) * -1,
                                'M22': math.cos(r_angle),
                                'Dx': x,
                                'Dy': y
                            })
                        x, y = -center_of_rotation_x, -center_of_rotation_y

                    if 'text_format' in r:
                        text_format = eval(r['text_format'])
                    else:
                        text_format = win32con.DT_CENTER | win32con.DT_SINGLELINE | win32con.DT_VCENTER

                    if 'geometry' in r:
                        if r['geometry'] is Shape.rectangle:
                            win32gui.Rectangle(hdc, int(round(x)),
                                               int(round(y)),
                                               int(round(x + width)),
                                               int(round(y + height)))
                        elif r['geometry'] is Shape.ellipse:
                            win32gui.Ellipse(hdc, int(round(x)), int(round(y)),
                                             int(round(x + width)),
                                             int(round(y + height)))
                        elif r['geometry'] is Shape.arrow:
                            a = thickness
                            t = ((x - int(a * 1.4), y), (x - a * 4, y + a * 3),
                                 (x, y), (x - a * 4, y - a * 3),
                                 (x - int(a * 1.4), y), (x - a * 9, y))
                            win32gui.Polyline(hdc, t)
                        elif r['geometry'] is Shape.image:
                            hicon = r['hicon']
                            win32gui.DrawIconEx(hdc, x, y, hicon, 0, 0, 0,
                                                None, 0x0003)
                        elif r['geometry'] is Shape.triangle and thickness > 0:
                            t = ()
                            for xyrgb in xyrgb_array:
                                t = t + ((int(round(
                                    xyrgb[0])), +int(round(xyrgb[1]))), )
                            t = t + ((int(round(xyrgb_array[0][0])),
                                      int(round(xyrgb_array[0][1]))), )
                            win32gui.Polyline(hdc, t)
                        if angle != 0:
                            win32gui.SetWorldTransform(hdc, Py_XFORM)
                        win32gui.SelectObject(hdc, old_pen)

                    if 'brush' in r and width > 1 and height > 1:
                        win32gui.SelectObject(hdc, old_brush)

                    if 'text' in r:
                        text = r['text']
                        lf = win32gui.LOGFONT()
                        lf.lfFaceName = font_name
                        lf.lfHeight = font_size
                        lf.lfWeight = win32con.FW_NORMAL
                        lf.lfQuality = win32con.ANTIALIASED_QUALITY
                        hf = win32gui.CreateFontIndirect(lf)
                        old_font = win32gui.SelectObject(hdc, hf)

                        if 'text_color' in r:
                            text_color_r = r['text_color'][0]
                            text_color_g = r['text_color'][1]
                            text_color_b = r['text_color'][2]
                        else:
                            text_color_r = 0
                            text_color_g = 0
                            text_color_b = 0
                        win32gui.SetTextColor(
                            hdc,
                            win32api.RGB(text_color_r, text_color_g,
                                         text_color_b))

                        if 'text_bg_color' in r:
                            text_bg_color_r = r['text_bg_color'][0]
                            text_bg_color_g = r['text_bg_color'][1]
                            text_bg_color_b = r['text_bg_color'][2]
                        else:
                            text_bg_color_r = brush_color_r
                            text_bg_color_g = brush_color_g
                            text_bg_color_b = brush_color_b
                        win32gui.SetBkMode(hdc, win32con.TRANSPARENT)
                        win32gui.SetBkColor(
                            hdc,
                            win32api.RGB(text_bg_color_r, text_bg_color_g,
                                         text_bg_color_b))
                        tuple_r = tuple([
                            int(round(x)),
                            int(round(y)),
                            int(round(x + width)),
                            int(round(y + height))
                        ])
                        win32gui.DrawTextW(hdc, text, -1, tuple_r, text_format)
                        win32gui.SelectObject(hdc, old_font)
                win32gui.EndPaint(h_wnd, paint_struct)
                return 0
            else:
                return win32gui.DefWindowProc(h_wnd, message, w_param, l_param)
예제 #9
0
def OnPaint_2(hwnd, msg, wp, lp):
    global display_value
    def num2vertices(num, off_x=30, off_y=30, red=0xff00, green=0, blue=0, alpha=0):
        global num_xy
        lines = [(
            {'x':p['x0']+off_x, 'y':p['y0']+off_y, 'Red':red, 'Green':green, 'Blue':blue, 'Alpha':alpha},
            {'x':p['x1']+off_x, 'y':p['y1']+off_y, 'Red':red, 'Green':green, 'Blue':blue, 'Alpha':alpha},
            ) for p in num_xy]
        if num==9:
            return [lines[0], lines[1], lines[2], lines[3], lines[5], lines[6]]
        if num==8:
            return lines
        if num==7:
            return [lines[0], lines[2], lines[5]]
        if num==6:
            return [lines[0], lines[1], lines[3], lines[4], lines[5], lines[6]]
        if num==5:
            return [lines[0], lines[1], lines[3], lines[5], lines[6]]
        if num==4:
            return [lines[1], lines[2], lines[3], lines[5]]
        if num==3:
            return [lines[0], lines[2], lines[3], lines[5], lines[6]]
        if num==2:
            return [lines[0], lines[2], lines[3], lines[4], lines[6]]
        if num==1:
            return [lines[2], lines[5]]
        if num==0:
            return [lines[0], lines[1], lines[2], lines[4], lines[5], lines[6]]
        return [lines[3]]
            
    dc, ps=win32gui.BeginPaint(hwnd)
    win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
    l,t,r,b=win32gui.GetClientRect(hwnd)

    # 1st num
    val1 = display_value // 1000 if display_value else 10
    off_x1 = off_x
    for vertices in num2vertices(val1, off_x1, off_y):
        mesh=((0,1),)
        win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_RECT_H)
    # 2nd num
    val2 = (display_value // 100) % 10 if display_value else 10
    off_x2 = off_x + (2*num_w + num_spa) + (off_padding)
    for vertices in num2vertices(val2, off_x2, off_y):
        mesh=((0,1),)
        win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_RECT_H)
    # 3rd num
    val3 = (display_value // 10) % 10 if display_value else 10
    off_x3 = off_x + (4*num_w + 2*num_spa) + (2*off_padding)
    for vertices in num2vertices(val3, off_x3, off_y):
        mesh=((0,1),)
        win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_RECT_H)
    # 4th num
    val4 = display_value % 10 if display_value else 10
    off_x4 = off_x + (6*num_w + 3*num_spa) + (3*off_padding)
    for vertices in num2vertices(val4, off_x4, off_y):
        mesh=((0,1),)
        win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_RECT_H)
        
    win32gui.EndPaint(hwnd, ps)
    return 0