Benny,
Correct would be to use CreateGraphics method of the control class
e.g. Graphics g = this.CreateGraphics();
All other methods are meant to be used in some rear cases like for example
you receive handle to device context form a windows message (overridding
WndProc method), subclassing windows control (NativeWindow class), PInvoke,
etc.
Normally you shouldn't use those methods, there are sign that you may use
unmanaged code.
As long as it goes for Graphics.FromHwnd and Graphics.FromHdc I believe they
differ in their application. You may have HDC without having HWND like
memory device context or printers.
I don't know what is User32 that you are referring to, but I guess it is
some kind of a wrapper for PInvoke (unamanged API calls) in this case I'll
go for FromHwnd because the solution is at least managed.
--
Stoitcho Goutsev (100) [C# MVP]
"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:up**************@TK2MSFTNGP15.phx.gbl...
I've seen both used... FromHwnd can be called like this
FromHwnd(this.Handle). FromHdc needs a call to
User32.GetWindowDC(this.Handle) - so my assumption is that FromHwnd is
better because it's less calls, but what's really the case?