Re: Paint outside of WNDPROC
Once a window handle is generated by the OS, it represents that window for the duration of it's existence, until it's destroyed.
There are many ways to provide access to that or the encapsulating object that represents a window (assuming you're using some kind of framework). A global variable is not the better choice, but it would work if you chose to use it.
The general topic you're considering, it seems to me, is known as a client DC - typically used for painting at times other than paint message.
Re: Paint outside of WNDPROC
Quote:
My question is, is it possible to save the windows handle global, or is it changing all the time, and if it is, are there any other optios to paint a window outside of it's WindowProc?
Thanks in advance
No need to declare the Window handle itself Global. Instead you can have a dummy temp HWND variable as global, and just assign the Handle to it. So, you can use the copy of original hWnd variable for global uses like use in Functions etc.
It cannot be confirmly said that a Windows handle remains constant, as it may vary ofcourse at some instance, if Sufficient memory is not available and the paging is used.
Re: Paint outside of WNDPROC
You can retrieve the current windows handle with GetActiveWindow(), e.g.
Code:
HWND hwnd;
HDC hdc;
hwnd = GetActiveWindow();
hdc = GetDC(hwnd);
....
ReleaseDC(hwnd, hdc);
Re: Paint outside of WNDPROC
Quote:
Originally Posted by
CoolPG
No need to declare the Window handle itself Global. Instead you can have a dummy temp HWND variable as global, and just assign the Handle to it.
I don't see the difference between storing a window handle in a global variable, or a copy of that handle.
Quote:
Originally Posted by
CoolPG
It cannot be confirmly said that a Windows handle remains constant, as it may vary ofcourse at some instance, if Sufficient memory is not available and the paging is used.
This is incorrect. Window handle doesn't change ever, not even while paging.
Re: Paint outside of WNDPROC
Quote:
Originally Posted by
olivthill2
You can retrieve the current windows handle with GetActiveWindow()...
What is "current window"? You can get *active* window handle with tht call, may not be the one you wanted to paint.
Re: Paint outside of WNDPROC
Quote:
Originally Posted by
VladimirF
This is incorrect. Window handle doesn't change ever, not even while paging.
OK Vlad.. can you be a lil more specific? :)
because i have read somewhere that a Window's handle can change dynamically... i hope, its in an MSDN article or somewhere...
So, can you please provide correct info? :)