c++ - Why do graphics drawn with GetDC(0); disappear as soon as a window moves over them? -


if use following code draw rectangle rectangle goes away moves on it.

#include "stdafx.h" #include <windows.h> #include <iostream> using namespace std;  int _tmain(int argc, _tchar* argv[]) {     hdc screendc = ::getdc(0);     ::rectangle(screendc, 200, 200, 300, 300);      int exit; cin >> exit;     return 0; } 

is there way receive callback when rectangle gets destroyed can repaint it? there way change color of rectangle? there good comprehensive tutorial covers this?

this because screen being updated. things being redrawn on rectangle , why it's disappearing. (such window)

edit: can draw rectangle in loop keep there. can use loop application logic , event handling if needed.

note: should depend on application does. leave method last resort because quite cpu intensive. (it less cpu intensive sleeps in loop, can't guarantee sleep give correct pause time.)


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -