Is it possible to render a winform directly to a memory device context
instead of rendering to a display device context ? 6 5366
On Thu, 12 Jun 2008 18:22:00 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
Is it possible to render a winform directly to a memory device context
instead of rendering to a display device context ?
In .NET, you render to a Graphics instance, not a DC. So technically, you
can do neither.
Depending on what you are _really_ trying to do, you may find the
Control.DrawToBitmap() method useful. Googling this newsgroup for other
threads that mention that method will turn up other techniques as well,
including Graphics.CopyFromScreen() and using p/invoke with the WM_PRINT
message.
Pete
Hi Peter, Thanks
The graphics object has a method called GetHdc() that gets a handle to the
current device context which then I can use in a win32 call to
createcompompatipledc.....
but I want to capture the form without it displaying to the physical display
if at all possible. I played around with Control.DrawToBitmap but the form is
still rendered to the physical display, I was just hoping I could change the
Device Context or something similar, whether in managed or unmanged code, so
that the Form would be rendered to a different type of device, so that the
form is captured but never seen on the display.
I went as far as to instantiate the new form call the show() method, capture
the
screen, then set the form to .visible = false; You don't see the form but
there is a
definite ugliness of seeing the screen flicker.
"Peter Duniho" wrote:
On Thu, 12 Jun 2008 18:22:00 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
Is it possible to render a winform directly to a memory device context
instead of rendering to a display device context ?
In .NET, you render to a Graphics instance, not a DC. So technically, you
can do neither.
Depending on what you are _really_ trying to do, you may find the
Control.DrawToBitmap() method useful. Googling this newsgroup for other
threads that mention that method will turn up other techniques as well,
including Graphics.CopyFromScreen() and using p/invoke with the WM_PRINT
message.
Pete
On Thu, 12 Jun 2008 18:56:06 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
The graphics object has a method called GetHdc() that gets a handle to
the
current device context which then I can use in a win32 call to
createcompompatipledc.....
Yes it does and yes you can. And yet, that has nothing to do with your
question.
but I want to capture the form without it displaying to the physical
display
if at all possible. I played around with Control.DrawToBitmap but the
form is
still rendered to the physical display,
DrawToBitmap() does not itself prevent the form from being shown
on-screen. In fact, it is generally limited to drawing the form as it's
shown on-screen, including any clipping that might occur (I know for
controls within a form this is true, and it might be for the whole form
too).
I was just hoping I could change the
Device Context or something similar, whether in managed or unmanged
code, so
that the Form would be rendered to a different type of device, so that
the
form is captured but never seen on the display.
I mentioned WM_PRINT. That might accomplish what you want, if you send it
to a form that's not visible but has otherwise been created. You may have
to call Control.CreateControl() first since you're not actually showing
the form.
I prefer not to second-guess, but the fact is what you're trying to do is
pretty unusual (as evidenced by lack of support in the API for it). I
don't know what your ultimate goal here is, but you may want to rethink
it. :)
Pete
Hi Peter,
What I meant by the first statement was a nice way of saying that a Device
Context does exist in .net, and the Graphics object does encapsulate it's
functionality, that's all I meant by that scenario.
I do like your second option with WM_PAINT, though.
On MSDN documentation it says that there are 4 types of Device Contexts, 2
obvious
Display, Printer, the third being a memory DC.......
The documentation states that if you use a memory DC and have your
application write to this vs a Display DC, the output is rendered, captured
and never shows, because you by-passed the Display device. Maybe I read to
much into this, but it sounded as though there was a way to set this Device
Context so that your app renders to a device of choosing. Unfortunitley the
documentation pretty much stopped there, and not going into how to change the
default funtionality of rendering to a Display DC.
Thanks
Nick
"Peter Duniho" wrote:
On Thu, 12 Jun 2008 18:56:06 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
The graphics object has a method called GetHdc() that gets a handle to
the
current device context which then I can use in a win32 call to
createcompompatipledc.....
Yes it does and yes you can. And yet, that has nothing to do with your
question.
but I want to capture the form without it displaying to the physical
display
if at all possible. I played around with Control.DrawToBitmap but the
form is
still rendered to the physical display,
DrawToBitmap() does not itself prevent the form from being shown
on-screen. In fact, it is generally limited to drawing the form as it's
shown on-screen, including any clipping that might occur (I know for
controls within a form this is true, and it might be for the whole form
too).
I was just hoping I could change the
Device Context or something similar, whether in managed or unmanged
code, so
that the Form would be rendered to a different type of device, so that
the
form is captured but never seen on the display.
I mentioned WM_PRINT. That might accomplish what you want, if you send it
to a form that's not visible but has otherwise been created. You may have
to call Control.CreateControl() first since you're not actually showing
the form.
I prefer not to second-guess, but the fact is what you're trying to do is
pretty unusual (as evidenced by lack of support in the API for it). I
don't know what your ultimate goal here is, but you may want to rethink
it. :)
Pete
Hey Peter,
Lets take this from a different angle. Lets say I have Device X, and I've
created
a device driver for device X, how do I get a .Net application to render it's
contents to Device X .VS. the default device the Display ?
Thanks
Nick
"Peter Duniho" wrote:
On Thu, 12 Jun 2008 18:56:06 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
The graphics object has a method called GetHdc() that gets a handle to
the
current device context which then I can use in a win32 call to
createcompompatipledc.....
Yes it does and yes you can. And yet, that has nothing to do with your
question.
but I want to capture the form without it displaying to the physical
display
if at all possible. I played around with Control.DrawToBitmap but the
form is
still rendered to the physical display,
DrawToBitmap() does not itself prevent the form from being shown
on-screen. In fact, it is generally limited to drawing the form as it's
shown on-screen, including any clipping that might occur (I know for
controls within a form this is true, and it might be for the whole form
too).
I was just hoping I could change the
Device Context or something similar, whether in managed or unmanged
code, so
that the Form would be rendered to a different type of device, so that
the
form is captured but never seen on the display.
I mentioned WM_PRINT. That might accomplish what you want, if you send it
to a form that's not visible but has otherwise been created. You may have
to call Control.CreateControl() first since you're not actually showing
the form.
I prefer not to second-guess, but the fact is what you're trying to do is
pretty unusual (as evidenced by lack of support in the API for it). I
don't know what your ultimate goal here is, but you may want to rethink
it. :)
Pete
On Fri, 13 Jun 2008 06:59:00 -0700, ncolosi
<nc*****@discussions.microsoft.comwrote:
Lets take this from a different angle. Lets say I have Device X, and
I've created
a device driver for device X, how do I get a .Net application to render
it's
contents to Device X .VS. the default device the Display ?
That depends on what you mean by "contents". If it's your own class, you
just draw to the appropriate DC at the appropriate time.
If it's some other class, you hope that it supports WM_PRINT. Because if
it doesn't, short of somehow hooking into Windows's own screen
invalidation and redraw implementation, you don't have enough control over
those other classes.
Pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Abd |
last post by:
Hiiiiiii
I am programming in Visual C++ 6.0
I want to get RGB percent of all of pixls of screen, and so I need to
get Device Context of entire screen.
I know that CClientDC dc(this) gets a divice...
|
by: Rahul |
last post by:
Hi All,
We are invoking a method exposed by thrid party DLL (Non COM), the method
expects one of the parameter as handle to device context of vb.net form. As
form object is changed in .Net, we...
|
by: Ben Taylor |
last post by:
Hi
Does anybody have any code examples of using C# to draw to a window using
device contexts, more specifically, erasing the entire window by painting a
background color in the OnPaint / OnDraw...
|
by: sandy_pt_in |
last post by:
I am very new to C#... i have one VC++ dll using that i have to
display video frames in
picture box but VC++ dll function asking device context... how can I
get device context of
picture box as i...
|
by: Dennis |
last post by:
I'm using VS 2003 my project uses COM interop and the Tao Framework.
I have a custom control derived from UserControl. It implements many
functions similar to the Tao's SimpleOpenGLControl, for...
| |
by: Jigar Mehta |
last post by:
Hye Friends..
Jigar Mehta from India.. Currently I want to load one BMP and show it
onto device context.. So, has anyone done the thing? I have loaded the Image
by CBitmap, but how to get it in...
|
by: Metallicraft |
last post by:
I have a vb6 application. On the main form is a picture
box with one or two images and several pieces of text
displayed in it. These are created on the fly using gdi32
routines that are all in a...
|
by: Joergen Bech |
last post by:
Suppose I have
Dim bm As New Bitmap(16, 16,Imaging.PixelFormat.Format8bppIndexed)
I cannot use
Dim g As Graphics = Graphics.FromImage(bmdest)
Dim hdc As IntPtr = g.GetHdc()
as the...
|
by: =?Utf-8?B?bmNvbG9zaQ==?= |
last post by:
Is it possible to render a winform directly to a memory device context
instead of rendering to a display device context ?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |