2

I'm trying to draw a rectangle corresponding to the perimeter of a window, but I have trouble to find documentation about the functions contained in win32gui.

My question is, how can I draw That rectangle around the window? I've drawn directly on screen DC or creating a bitmap (win32gui.CreateCompatibleBitmap) and that paint I to screen DC?

Rect = win32gui.GetWindowRect(window_handler)

dcBmp = win32gui.CreateCompatibleDC(0)
dcscrn = win32gui.GetDC(0)
c_bpm = win32gui.CreateCompatibleBitmap(dcscrn, x, y)
c_bpm_old = win32gui.SelectObject(dcBmp, c_bpm)
pen = win32gui.CreatePen(win32con.PS_GEOMETRIC, win32api.RGB(255,0,0))

At this point I don't know how I can draw the Rect in bitmpap and then Paint it on Screen?

Thank you, I'm quite confused.

Sorry for my awful English, I hope you can understand my question, thanks again for your patience.

Torxed
  • 22,866
  • 14
  • 82
  • 131
  • You cannot draw directly on the screen in any reliable way. The system will paint over what you draw. – David Heffernan Apr 20 '13 at 14:12
  • This is a Win32 question, not essentially a Python question. You should change the tags... – Armin Rigo Apr 21 '13 at 10:28
  • @ArminRigo I wish you hadn't done that, because I needed this information searching for "python win32gui drawrect", due to the missing tag - this came up WAY at the end of all search results. Added it back. – Torxed Jun 12 '20 at 10:21
  • 2
    This might be useful to whomever ends up here: https://stackoverflow.com/questions/62341134/how-to-draw-an-empty-rectangle-on-screen-with-python – Torxed Jun 12 '20 at 12:42

0 Answers0